Reputation: 877
I'm uploading a CSV file to the sails app. At this point it should do two things:
My first thought was I could do something like
entries = parse(data);
foreach(entry in entries) {
sails.models.entry.create(entry);
}
but this approach silently fails.
Is there a proper way to handle this sort of scenario?
Thanks!
Upvotes: 1
Views: 2599
Reputation: 24958
You can call .create
with an array of objects to create multiple models; this is referred to in the documentation for .create()
. So:
sails.models.entry.create(entries).exec(...);
should work fine.
Upvotes: 6