You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the newest mongoose version (4.11.0) and node 6.11.0
I created a simple example where an animal should be added to my database. Therefor I am using th push-function.
When I check the database I expect an item with cat 'Zildjian' and an other cat 'Zohan' but the second one has both cats.
This seems to be a bug to me.
Can someone please help how to solve that problem?
Here is my code:
let mongoose = require('mongoose');
let catSchema = new mongoose.Schema({
name: {type: String, required: true}
});
let animalSchema = new mongoose.Schema({
sound: {type: String, required: true},
animals: {
type: {
cat: [catSchema],
},
required: true,
default: {
cat: [],
dog: []
}
}
});
exports.default = mongoose.model('animalSchema', animalSchema);
let mongoose = require('mongoose');
mongoose.connect('mongodb://test1/test');
let animalModel = require('./model').default;
function enterThings(house, name) {
let animal = new animalModel({sound: house});
animal.animals.cat.push({name: name});
animal.save(function (err) {
if (err)
console.log(err);
else
console.log('Yay!');
});
}
setTimeout(function() {
enterThings('miaow', 'Zildjian')
}, 1000);
setTimeout(function() {
enterThings('woof', 'Zohan')
}, 2000);
setTimeout(function() {
process.exit(0);
}, 3000);
The text was updated successfully, but these errors were encountered:
Hi,
I am using the newest mongoose version (4.11.0) and node 6.11.0
I created a simple example where an animal should be added to my database. Therefor I am using th push-function.
When I check the database I expect an item with cat 'Zildjian' and an other cat 'Zohan' but the second one has both cats.
This seems to be a bug to me.
Can someone please help how to solve that problem?
Here is my code:
The text was updated successfully, but these errors were encountered: