Open nfleury opened 10 years ago
If we have a relation like this :
Book = db.define('Book', {name: String}); Chapter = db.define('Chapter', {name: {type: String}}); Book.hasMany(Chapter); Chapter.belongsTo(Book);
To add multiple chapters in a book, we have to do something like this:
book.chapters.create({name: 'a'}, function() { book.chapters.create({name: 'z'}, function() { book.chapters.create({name: 'c'}, function() { }); }); });
Or something like this:
book.save(function(e,b){ Chapter.create([{name:'a',bookId:b.id},{name:'b',bookId:b.id}],function(){}); });
So, it would be nice if we could directly store multiple child objects like this:
book.chapters.create([ {name: 'a'},{name: 'v'} ], function() {}
That makes sense.
If we have a relation like this :
To add multiple chapters in a book, we have to do something like this:
Or something like this:
So, it would be nice if we could directly store multiple child objects like this: