I am having an issue when saving a model fails with mongo error: MongoError: Unknown modifier: $pushAll.
I have one array field subDomains
in my schema and which will get saved as default with subdomain as like follows.
// already Domain instance get availble
Domain.subDomains.push({'name': 'default' , 'role': 'xyz', ...});
// save domain with default fileds
Domain.save()
System Info as like as follows:
➜ ~ node --version
v9.4.0
➜ ~ npm --version
5.6.0
➜ ~
➜ ~ mongo --version
MongoDB shell version v3.6.2
git version: ......
OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
➜ ~
Please help me to sort out this one.
The $pushAll
operator is no longer supported in Mongo 3.6.2 (or any newer versions from 3.6.x+).
You can do the following:
add the usePushEach: true
option the Schema definition as in:
new mongoose.Schema({
username: String
}, {
usePushEach: true
});
downgrade to Mongo 3.4.11(or any 3.4.x version)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With