Skip to content

Sails.js hook model method that updates or creates a record based on criteria and values argument.

License

Notifications You must be signed in to change notification settings

protocoolmx/sails-hook-update-or-create

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sails-hook-update-or-create

npm version Build Status

Sails.js hook model method that updates or creates a record based on criteria and values argument.

Install

$ npm install sails-hook-update-or-create --save

Overview

Model.updateOrCreate(criteria, values)

Parameter Type Details
criteria {}, string, int The criteria used to find the record. If not found and values is not provided, it is also the record that will be created.
values {} The object that you would like to update or create.

Usage

User.updateOrCreate(123, {
  status: 'ACTIVE'
})
.then((user) => {
  sails.log.info(`User with id ${user.id} is active!`);
})
.catch(sails.log.error);

Test

$ npm test

About

Sails.js hook model method that updates or creates a record based on criteria and values argument.

Resources

License

Stars

Watchers

Forks

Packages

No packages published