batmanjs/batman — pull request #981 by rmosolgo (2014-02-18 18:15:45+00:00)
Title: Model.createFromJSON accepts an Array

I want to load a bunch of records from JSON without calling `Model.loaded.itemsWereAdded` for each one. I didn't see a way to do it, am I missing something?

My solution would be for `Model.createFromJSON` to accept an array of attributes as well as just an object.

I want to add this feature because right now I'm doing this:

```coffeescript
model = MyModel
recordsJSON = [{ ... }, { ... }, { ... }] # from XHR request
model.get('loaded').prevent('itemsWereAdded')
modelPrimaryKey = model.get('primaryKey')
loadedIds = model.get('loaded').mapToProperty('id')
addedRecords = []
for recordJSON in recordsJSON
if recordsJSON[modelPrimaryKey] not in loadedIds
record = model.createFromJSON(recordJSON)
addedRecords.push(record)
model.get('loaded').allowAndFire('itemsWereAdded', addedRecords, null)
```

It would be nice to let the framework handle that :)