longshotlabs / simpl-schema

A JavaScript schema validation package that supports direct validation of MongoDB update modifier objects
https://www.npmjs.com/package/simpl-schema
MIT License
560 stars 114 forks source link

feat: support mongodb array update operator $[] #442

Open kfritsch opened 3 years ago

kfritsch commented 3 years ago

fixes #378

This pr adds support for the mongodb array update operator $[] by updating mongo-object to the newest version. mongo-object received an update lately specifically to support this feature in the way described in https://github.com/longshotlabs/simpl-schema/issues/378#issuecomment-689840464.

This pr only adds tests to show that the update operator works with this version of mongo-object.

Please feel free to move, change and extend the tests and edit the commit message.

kfritsch commented 3 years ago

While this allows validating updates using arrayFilters, it does not validate the arrayFilter specification itself, which is not even part of the update object. Not sure if this would be worth adding to the docs.

derwaldgeist commented 2 years ago

Any chance to get this into simpl-schema? Being able to update multiple entries in an array is not a super rare use-case.