I am getting one error related to mongodb.Actually i have one collection whose datas are given below.
"_id" : ObjectId("55bd9b7adfa5d64c057de74f"),
"username" : "admin",
"emailid" : "*****************************",
"password" : "adminuser",
"image" : "images/Image0895.jpg",
"firstname" : "subhrajyoti",
"lastname" : "pradhan"
Here i want to keep the username document as unique.For that i wrote the commanddb.collectionname.createIndex( {"username":"admin"},{unique:true}).But it gave me the following error.
Error:
"ok" : 0,
"errmsg" : "bad index key pattern { username: \"admin\" }: Unknown index
plugin 'admin'",
"code" : 67
Please help me to resolve this error keep my one document as unique for this collection.