I'm trying to launch a search from a bash shell like that.
root@mongo01:~# mongo mydb --quiet --shell --eval "printjson(db.userContests.find({linkId: {$ne: null}}, {linkId: 1}).pretty())"
type "help" for help
2015-02-23T14:45:09.256+0100 SyntaxError: Unexpected token :
As you can see, I get an error.
However, launching the same from mongo shell works.
root@axn-mongo01:~# mongo mydb
MongoDB shell version: 2.6.7
connecting to: mydb
> db.userContests.find({linkId: {$ne: null}}, {linkId: 1}).pretty()
{
"linkId" : "_guid_F5BDEJFk2hvxyamKIVePEw==",
"_id" : ObjectId("546dc5e47d479b1d0d8b45aa")
}
{
"linkId" : "_guid_F5BDEJFk2hvxyamKIVePEw==",
"_id" : ObjectId("546debdf7d479b686f8b458d")
}
{
"linkId" : "_guid_EcWY0_RmDs8wA2T9LuVAGtiDfUHf8i-jLxTrhDXjzo8=",
"_id" : ObjectId("546df6237d479b62698b45be")
Someone knows what's happening? Thanks.