Skip to content

Instantly share code, notes, and snippets.

@jfernandez
Last active January 2, 2016 13:49
Show Gist options
  • Save jfernandez/8312460 to your computer and use it in GitHub Desktop.
Save jfernandez/8312460 to your computer and use it in GitHub Desktop.
function saveObject(request) {
// Return 200 and close the connection right away.
// The client doesn't need to wait for the DB.
request.reply({}).code(200);
db.ModelFoo.create(request.params).success(function(record) {
// This event gets fired some milliseconds later.
// You can chain other business logic here or log success.
});
// At this point this node app is already processing other API requests
// without having to wait for the database
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment