1602 / 1602/jugglingdb

Create multiple relation from owner

Offen
#353 1 Kommentar 0 Reaktionen 1 zugewiesene Person Beansprucht von @1602 Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
2k
Forks
238
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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() {}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Look at the hasMany relation implementation in jugglingdb's source code, likely in lib/relation.js or similar. Find the create method for associations and see how it handles single objects. The task is to extend it to accept an array of objects. Check existing tests for relations to understand the expected behavior and add a test for the new array feature.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, nodejs
Bereich
backend, databases
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.