mongoose-findorcreate
mongoose-findorcreate copied to clipboard
When removing query operators, only remove keys starting with dollar.
The changes introduced in #6 were intended to allow callers to do things like the following:
Model.findOrCreate({ key: '0', value: { $exists: false } })
However, its implementation prevented values contining the dollar sign from being included.
This change preserves the behavior of removing query operators by recursively finding any property starting with a dollar and removing it. This allows values containing the dollar sign to be upserted while still omiting query operators.
Fixes #30.