Creating multiple records

I’m wondering if there’s a way to create multiple records in Ember. For my application, I’ll need to create several thousand records.

That sorta depends on what you mean. You can create as many records as you want in the Ember Data store using store.createRecord. If you want to persist those records to a server you just call <record>.save(). You could do that in parallel (though you probably wouldn’t want to do thousands of individual saves in parallel. Ember Data has no built in “batch save” because that’s less conventional from an API standpoint. That said if you already have a batch create API endpoint it’s not difficult to write some code that would make a save request and then, if you wanted, serialize the response into the Ember store in one batch (you could use store.pushPayload, etc).

So anyway it kinda depends on what exactly you’re looking to do. Could you describe your use case in a little more detail?

1 Like