Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. {
  2. nome: "ale",
  3. skills: ["mongo", "db2", "oracle"]
  4. },
  5. {
  6. nome: "massimo",
  7. skills: ["monngo", "sqlserver"]
  8. },
  9. {
  10. nome: "fabio",
  11. skills: ["db2", "mysql"]
  12. },
  13. {
  14. nome: "gianluca",
  15. skills: ["db2", "oracle"]
  16. },
  17. {
  18. nome: "bob",
  19. skills: ""
  20. }
  21.  
  22. //utenti che hanno sia mongo che db2
  23. db.collezione.find(
  24. {
  25. skills: {$all: ["mongo", "db2"]}
  26. }
  27. )
  28. // utenti con almeno 3 skills
  29. db.collezione.find(
  30. {
  31. skills: {$size: 3}
  32. }
  33. )
  34. // utenti che non hanno skills
  35. db.collezione.find(
  36. {
  37. skills: null
  38. }
  39. )
  40. // oppure
  41. db.collezione.find(
  42. {
  43. skills: {$exists: false}
  44. }
  45. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement