mongodb - Not able to find a document When I insert a Ensure index query -


  1. i create document db.duplicate.ensureindex ({"a": 1}, {"unique": "true"})
  2. to create unique index on a
  3. when search document don't find value (db.duplicate.find())
  4. ideally should create document _id & = 1 ? approach right?

the ensureindex function creates index collection, not document. increase performance when querying documents a index.

for creating documents, try insert:

db.duplicate.insert({'a': 1}) 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -