mongodb creating unique index: significance of ": 1" -
following how unique constraint created in mongodb:
db.members.createindex( { "user_id": 1 }, { unique: true } )
what significance of "1" in above command. above command seems bit counter-intuitive me because of "1"
directly documentation:
a value of 1 specifies index orders items in ascending order. value of -1 specifies index orders items in descending order.
so creates index on user_id field in ascending order , values can unique.
Comments
Post a Comment