Create multiple relation from owner
- Lenguaje dominante
- JavaScript
- Estrellas
- 2k
- Forks
- 238
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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() {}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, nodejs
- Área
- backend, databases
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100