i am new to Shell Scripting, Actually i am writing a shell Script for mongo to find specific document, this Shell Script Except a Argument and use in Find Query, So i had write a simple find query:
mongo poc --eval "printjson(db.users.find().toArray())"
That Working Fine, But now problem is that when i want to find Specific document by Passing Users id That provide null record , So here is my Shell Script:
mongo poc --eval "printjson(db.users.find({"userid":"$1"}).toArray())"
i don't know what is wrong, please help so that i m able to write also for update and remove query.
mongo poc --eval "printjson(db.users.find({"userid":"1"}).toArray())"
Does it still return NULL value? Does This record (userid=x)exists inside the database? I'm not sure it's a shell script issue. – lese Jun 9 at 8:27use poc
> switched to db pocdb.getCollectionNames()
> [ ]db.users.find({"userid":"1"})
> this does not return nothing, neither NULL document [ ] – lese Jun 9 at 9:08