Last active
August 29, 2015 14:19
-
-
Save JerryC8080/d9be03f65fd35d92a582 to your computer and use it in GitHub Desktop.
Sails Model.findOrCreate method use way with promise style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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