Guest User

Untitled

a guest
Aug 5th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. mongodb-php update $pull
  2. {
  3. "_id": ObjectId("4f1950f0e902edfc3e000001"),
  4. "coupons": {
  5. "4f1950b7e902edf23e000001": {
  6. "_id": ObjectId("4f1950b7e902edf23e000001"),
  7. "couponID": ObjectId("4f15c7d8e902edb667000000")
  8. },
  9. "4f1950bfe902ed843f000000": {
  10. "_id": ObjectId("4f1950bfe902ed843f000000"),
  11. "couponID": ObjectId("4f171f33e902ed4f4f000002")
  12. }
  13. },
  14. "recipients": [
  15. {
  16. "email": "test1@gmail.com",
  17. "get": "?auth=ZG1pdHJ5LnZvbG9zbmloaW5AZ21haWwuY29tfDA5OGY2YmNkNDYyMWQzNzNjYWRlNGU4MzI2MjdiNGY2"
  18. },
  19. {
  20. "email": "test2@gmail.com",
  21. "get": "?auth=ZGpyb3VibGVAZ21haWwuY29tfDA5OGY2YmNkNDYyMWQzNzNjYWRlNGU4MzI2MjdiNGY2"
  22. },
  23. {
  24. "email": "test3@gmail.com",
  25. "get": "?auth=a2FsaWJyb3YxQGdtYWlsLmNvbXwwOThmNmJjZDQ2MjFkMzczY2FkZTRlODMyNjI3YjRmNg=="
  26. }
  27. ],
  28. "title": "test"
  29. }
  30.  
  31. $result = $mongoDB->emailDeliveryActive->update(
  32. array('_id' => $emailDelivery['_id']),
  33. array(
  34. '$pull'=>array(
  35. 'recipients.$.email' => 'test1@gmail.com'
  36. )
  37. )
  38. );
  39.  
  40. $result = $mongoDB->emailDeliveryActive->update(
  41. array('_id' => $emailDelivery['_id']),
  42. array(
  43. '$pull'=> array('recipients' => array('email' => 'test1@gmail.com'))
  44. )
  45. );
Add Comment
Please, Sign In to add comment