Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stocks:
- {"_id" : ObjectId("xxx"),"scrip" : "xxxxx2" }
- {"_id" : ObjectId("xxy"),"scrip" : "xxxxx3" }
- {"_id" : ObjectId("xyy"),"scrip" : "..." }
- [xxxxx7,xxxxx8]
- db.stocks.find({
- "scripid": {"$nin": ["xxxxx7","xxxxx2","xxxxx3","xxxxx8"]}
- }).toArray().map(stock => stock.scripid)
- {"scripid" : "xxxxx2" }
- {"scripid" : "xxxxx3" }
- {"scripid" : "xxxxx4" }
- db.stocks.aggregate([ {
- $group :{_id : null, scripids: {$push : '$scripid'}}
- },{ "$project": { _id:0 , "inputArrayNINscripts": { "$setDifference": [ ['xxxxx7','xxxxx2','xxxxx3','xxxxx8'] , "$scripids" ] } } } ])
- {
- "inputArrayNINscripts" : [
- "xxxxx7",
- "xxxxx8"
- ]
- }
- db.stocks.find({
- "scripid": {"$nin": ["xxxxx7","xxxxx2","xxxxx3","xxxxx8"]}
- }).toArray().map(scriptsNINArray => scriptsNINArray.scripid)
- /* 1 */
- [
- "xxxxx4"
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement