Guest User

Untitled

a guest
Sep 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. my collection recored for mongodb
  2. {
  3. "_id" : ObjectId("5ba60b805f13dc37a5377302"),
  4. "clientID" : "5ba49a5b58db5fb63b282565",
  5. "propertyID" : "77f3d86a9842afa8ee7a64f3bf958ef4",
  6. "emod" : [
  7. {
  8. "audience" : "Mobile",
  9. "emodID" : "5ba5e0f47b07641eeebfad37",
  10.  
  11. },
  12. {
  13. "audience" : "Laptop",
  14. "emodID" : "5ba5e0f47b07641eeebfad37",
  15. },
  16. {
  17. "audience" : "Games",
  18. "emodID" : "5ba5e0f47b07641eeebfad37"
  19. }]
  20. }
  21. --------------------------------------------------
  22. find record query
  23.  
  24. var audienceList = ["Mobile","Laptop"];
  25.  
  26. predictionCollection.findOne({
  27. "clientID": '5ba49a5b58db5fb63b282565',
  28. }, {
  29. emod: {
  30. $elemMatch: {
  31. 'audience': {"$in":audienceList}
  32. }
  33. },
  34.  
  35. }).exec(function (err, predictionData) {
  36. //get output for predictionData
  37. emod: [ { audience: 'Mobile', emodID: [Array] } ] }
  38.  
  39.  
  40. // but i required output for
  41. emod: [ { audience: 'Mobile', emodID: [Array] },
  42. { audience: 'Laptop', emodID: [Array] }
  43. ] }
  44.  
  45. });
Add Comment
Please, Sign In to add comment