MongoDB Command

pleng
Oct 15, 2021

--

For beginner

  1. select specific column use Project Fields
db.inventory.find( { status: "A" }, { item: 1, status: 1, _id: 0 } )
  • 1 is mean display
  • 0 is mean not display

2. check field exits

db.inventory.find( { b: { $exists: true } } )

3. not equal

db.inventory.find( { qty: { $ne: 20 } } )

4. in array

db.inventory.find( { qty: { $in: [ 5, 15 ] } } )

--

--