I assume other DBs behave the same way -
{
Collection: db.Collection(VibeChatUser),
Index: &mongo.IndexModel{
Keys: bson.M{
"Email": 1, // specify the field name and order (1 for ascending, -1 for descending)
},
Options: options.Index().SetUnique(true), // additional index options like uniqueness
},
},
here I create an index on the email field - however it really doesn't matter what order they appear? Or maybe it does if binary search is used - not sure.
I am just surprised their isn't an index that allows for zero (unordered) - like so:
Keys: bson.M{
"Email": 0, // zero for unordered - this isn't real
},
I don't know enough about indexes to understand this for sure - anyone know why an unordered index wouldn't be an option?