documentcloud/backbone — Issue #816: request: Collection .save / .destroy
Author: pyparadigm
Created: 2011-12-25 13:32:28+00:00
State: open

It would be nice, if just as if you can call .fetch on a collection, or a model, that you may also call .save and .destroy on a collection as well, thus:

READ
model.fetch() ~ GET /collection/id
collection.fetch() ~ GET /collection
CREATE/UPDATE
model.save() ~ POST/PUT /collection/id
collection.save() ~ POST/PUT /collection
DELETE
model.destroy() ~ DELETE /collection/id
collection.destroy() ~ DELETE /collection

Currently, you may collection.fetch and the server will respond with an array of models. For calling .save() on a collection it can send an array of models to save to the server. For calling .destroy() on a collection it can send an array of IDs to delete from the system. This would unify the CRUD between models and collections.