After installation process, the following lines should be entered in mongo shell (client terminal).
> db.world.insert({ "speech" : "Hello World!" });
> cur = db.world.find();x=cur.next();print(x["speech"]);
Hello World!
Explanation:
{ key : value }
paired document in the default database test
and in the collection named world
.cur
. Then by the next()
function, we retrieved the first and only document and kept it in another js variable named x
. Then printed the value of the document providing the key.