Phalcon mongodb update $pull -


{_id : objectid(...), name : "name", ids : [44, 1, 9, 11, 15, 66]}

how remove, example, 15 form ids ???

is possible use $pull http://docs.mongodb.org/manual/reference/operator/update/pull/ ?

phalcon docs http://docs.phalconphp.com/en/latest/reference/odm.html#creating-updating-records

from manual:

your collection:

{_id : objectid(...), name : "name", ids : [44, 1, 9, 11, 15, 66]} 

you can remove, "15" above "ids" array simple update:

db.yourcollection.update(                { ids: "15" },                { $pull: { ids: "15" } },                { multi: true }              ) 

the update consists of

  • { ids: "15" }: find of these in ids array.
  • { $pull: { ids: "15" } }: "the $pull operator removes existing array instances of value or values match specified query" -- in case value 15
  • { multi: true } : simple multi flag remove multiple occurrences found.

hope helps.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -