Sunday, October 11, 2020

How to create composite key in mongodb

 Please use below as reference to create composite key:

db.coll.createIndex({'k1':1,'k2':1},{unique:true});

{

"createdCollectionAutomatically" : false,

"numIndexesBefore" : 1,

"numIndexesAfter" : 2,

"ok" : 1

}

No comments:

Post a Comment