Closed dombesz closed 11 years ago
I would usually recommend creating a separate backend for each "content type". Posts and comments, however, may be an exception since comments usually belong to a particular post. You could nest the comments inside the post model and handle saving both in a single backend. The "right" approach to take will likely depend on how you're storing the data, etc. Does this answer your question?
Sorry, my explanation wasn't the clearest. So my problem is that the req.model
attribute is not for what i'm looking for, its either empty []
on the case of model binding or contains an array of objects in case of collection binding. So on the server side cant really rely on the model attribute. And my question is that, how the req.model
attribute supposed to work?
The req.model
will contain the data that was sent to Backbone.sync. The middleware layers can do whatever they like with it, save it to disk, modify it, etc.
Hi,
I'm trying to set up backbone.io with multiple models. I saw that the request contains a model attribute. But if I'm syncing a model with backbone.io the
req.model
will be[]
. If I'm trying to sync collections with the server thereq.model
contains all the objects that I have in the collection. What I'm trying to achieve is to handle thecrud
actions on the server side depending on the model type. So for example if I have aposts
and acomments
model I'd like to handle them in separate middlewares on the serverside. Something like:Another option I see is to have separate backends for each model and bind the appropiate backend to each model/collection on the backbone frontend.
Can you point me to the right direction please? Thanks.