Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Additional Update Operators #9

Closed
17 tasks done
aldeed opened this issue Aug 22, 2013 · 6 comments · Fixed by #17
Closed
17 tasks done

Support Additional Update Operators #9

aldeed opened this issue Aug 22, 2013 · 6 comments · Fixed by #17

Comments

@aldeed
Copy link
Collaborator

aldeed commented Aug 22, 2013

This is to track progress adding support for additional update operators beyond $set and $unset.

The following operators need to be parsed and understood (but not necessarily validated) by the validation and cleanup functions in simple-schema:

  • $setOnInsert (treat this just like $set, merge contents with contents of $set)
  • $rename
  • $inc
  • $addToSet
  • $push
  • $pushAll (deprecated but might still work?)
  • $pull
  • $pullAll
  • $pop
  • $each (used with $push or $addToSet; probably remove the $each and treat like setting directly)
  • $slice

The following operators need to be validated as best they can by simple-schema:

  • $setOnInsert (treat this just like an insert)
  • $rename (make sure old name is not required and new name is in schema)
  • $addToSet (check allowed values and validate each item)
  • $push (check allowed values and validate each item)
  • $pushAll (deprecated but might still work?) (throw error)
  • $each (used with $push or $addToSet; probably remove the $each and treat like setting directly)

And all except $setOnInsert will probably need some extended validation added in the collection2 package.

@Lepozepo
Copy link

:'( $pushAll doesn't work, why deprecated? I have a list of products with tags, validation looks like this (coffeescript):

tags:
    type:[String]
    optional:true

Am I doing something wrong?

@aldeed
Copy link
Collaborator Author

aldeed commented Oct 29, 2013

@Lepozepo, are you using an old version of mongo? If you're using 2.4+, $pushAll is deprecated and you should use $push with $each instead. Minimongo supports $each, too.

@Lepozepo
Copy link

Oh wow, I didn't know that, lol. But now when I do $pullAll it resets the entire document >_<. I tried that with an each as well but got nothing :/. Looks like I have Mongo 2.4.6. Thanks for helping me out!

aldeed added a commit that referenced this issue Oct 29, 2013
@aldeed
Copy link
Collaborator Author

aldeed commented Oct 29, 2013

@Lepozepo, $pullAll handling was an issue and is now fixed. I also revised the handling of $pushAll so that the clean method cleans it by converting it to $push+$each for you. So you should be able to use $pushAll now, but it's still better to start using the new $each format.

($pull does not support $each and $pullAll is still correct for pulls)

@Lepozepo
Copy link

Sweet, thanks!

@dandv
Copy link
Contributor

dandv commented Aug 15, 2015

Any chance to get a quick doc update for setOnInsert? It's not documented anywhere but it uses in the example at https://github.com/aldeed/meteor-collection2#autovalue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants