aldinokemal

MongoDB - Element Operator

Mar 27th, 2022
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // select * from products where category is null
  2. db.products.find({
  3.     category: {
  4.         $exists: false
  5.     }
  6. });
  7.  
  8. // select * from products where type(category) = "string"
  9. db.products.find({
  10.     category: {
  11.         $type: "string"
  12.     }
  13. });
  14.  
  15. // select * from products where type(price) in ("int", "long")
  16. db.products.find({
  17.     price: {
  18.         $type: ["int", "long"]
  19.     }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment