graphiti-api / spraypaint.js

Graphiti Client / Javascript ORM / JSONAPI
MIT License
107 stars 69 forks source link

Adds constructor assignment for collections #109

Open blefevre opened 2 years ago

blefevre commented 2 years ago

This PR extends the existing feature allowing the creation of associations with bare objects, e.g:

 const author = new Author({ genre: { name: "Horror" } })

to allow collections to be created:

const author = new Author({
      books: [{ title: "The Shining" }, { title: "The Darkening" }]
})

Currently the above snippet would result in books being an empty array, where-as now it will correctly create the two Book objects.