Skip to content

Instantly share code, notes, and snippets.

@JerryC8080
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JerryC8080/d9be03f65fd35d92a582 to your computer and use it in GitHub Desktop.
Save JerryC8080/d9be03f65fd35d92a582 to your computer and use it in GitHub Desktop.
Sails Model.findOrCreate method use way with promise style
var Promise = require("bluebird");
return Promise.map(objects, function (object) {
sails.log.info('An object will be created:');
sails.log.info(object);
return Comment.findOrCreate(object.id , object);
}).then(function (objects) {
sails.log.info('The objects created or found goes here: ');
sails.log.info(objects);
return objects;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment