Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. stocks:
  2.  
  3. {"_id" : ObjectId("xxx"),"scrip" : "xxxxx2" }
  4. {"_id" : ObjectId("xxy"),"scrip" : "xxxxx3" }
  5. {"_id" : ObjectId("xyy"),"scrip" : "..." }
  6.  
  7. [xxxxx7,xxxxx8]
  8.  
  9. db.stocks.find({
  10. "scripid": {"$nin": ["xxxxx7","xxxxx2","xxxxx3","xxxxx8"]}
  11. }).toArray().map(stock => stock.scripid)
  12.  
  13. {"scripid" : "xxxxx2" }
  14. {"scripid" : "xxxxx3" }
  15. {"scripid" : "xxxxx4" }
  16.  
  17. db.stocks.aggregate([ {
  18. $group :{_id : null, scripids: {$push : '$scripid'}}
  19. },{ "$project": { _id:0 , "inputArrayNINscripts": { "$setDifference": [ ['xxxxx7','xxxxx2','xxxxx3','xxxxx8'] , "$scripids" ] } } } ])
  20.  
  21. {
  22. "inputArrayNINscripts" : [
  23. "xxxxx7",
  24. "xxxxx8"
  25. ]
  26. }
  27.  
  28. db.stocks.find({
  29. "scripid": {"$nin": ["xxxxx7","xxxxx2","xxxxx3","xxxxx8"]}
  30. }).toArray().map(scriptsNINArray => scriptsNINArray.scripid)
  31.  
  32. /* 1 */
  33. [
  34. "xxxxx4"
  35. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement