1602 / 1602/jugglingdb

Create multiple relation from owner

Aperta
#353 1 commento 0 reazioni 1 assegnatario Rivendicata da @1602 Vedi su GitHub
Lingua principale
JavaScript
Stelle
2k
Fork
238
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
backend, databases
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.