我是MongoDB的新手.我只是关注tutorialspoint.com来学习mongoDB.
我完全执行了这两个命令:
db.test.save( { a: 1 } )
db.test.find(){ "_id" : ObjectId(5879b0f65a56a454), "a" : 1 }
Run Code Online (Sandbox Code Playgroud)
我收到错误SyntaxError:Unexpected Token {
任何帮助表示赞赏.谢谢.
您的查询:
test.find() { "_id" : ObjectId(5879b0f65a56a454), "a" : 1 }
Run Code Online (Sandbox Code Playgroud)
正确的查询:
test.find( { "_id" : ObjectId("5879b0f65a56a454"), "a" : 1 })
Run Code Online (Sandbox Code Playgroud)
你需要在圆括号中加入花括号,如({})第二个用引号括起id,请参考mongodb手册
http://docs.mongodb.org/manual/reference/method/db.collection.find/