Skip to content

Instantly share code, notes, and snippets.

@Hanspagh
Last active August 27, 2015 17:27
Show Gist options
  • Save Hanspagh/3b5dccce63d936827605 to your computer and use it in GitHub Desktop.
Save Hanspagh/3b5dccce63d936827605 to your computer and use it in GitHub Desktop.
function test(req, res) {
//get the userId and...
//
req.models.addedRealEstate.exists({userId: userId, realEstateId: realEstateId})
.then(function(recordExists) {
//If record its exists, stop here else create record in db
if(personIsActive) { return res.json('Error'); }
}).then(function() {
return req.models.addedRealEstate.create({userId: userId, realEstateId: realEstateId, source: source});
}).then(function(realEstate) {
return res.json('Success');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment