mongoose-findorcreate
mongoose-findorcreate copied to clipboard
Why are the properties that contain the dollar sign eliminated?
Hello, i have this question , in a part of index.js have:
// If the value contain '$' remove the key value pair
var keys = Object.keys(conditions);
for (var z = 0; z < keys.length; z++) {
var value = JSON.stringify(conditions[keys[z]]);
if (value && value.indexOf('$') !== -1) {
delete conditions[keys[z]];
}
}
I need to save
message = { text: "the price is $550"}
and I can't, have any solution?
This was added in pull #6. It looks like the intention was to omit any properties which are obviously non-data query operators. However, the implementation to do this incorrectly checks the values of properties instead of just the property names.
Since #6 was accepted to mongoose-findorcreate, it is now part of the API. The intention is to remove any keys beginning with $, so at least that behavior must be preserved. But I think fixing it to ignore values would be correct/accepted.