“Knowing others is intelligence; knowing yourself is true wisdom. Mastering others is strength; mastering yourself is true power.” - Arvind Toorpu
Wednesday, July 22, 2015
Querying data from Mongodb
-- limit output where position : Center results --
db.player.find(
{"position" : "Center"}
)
-- limit output where position : Center results & display only name values --
db.player.find(
{"position" : "Center"},
{"name":1}
)
-- limit output to 3 results --
db.player.find(
{"position" : "Center"},
{"name":1,_id:0}
).limit(3)
-- skip first 3 results --
db.player.find(
{"position" : "Center"},
{"name":1,_id:0}
).skip(3)
-- output to 2 values per doc & search criteria is filtered by position "or" id --
db.player.find(
{
$or:[{"position":"Right Wing"},
{"id":8475761}]
},{"name":1}
).pretty()
Subscribe to:
Posts (Atom)