0.1.4 • Published 8 years ago

sails-hook-update-or-create v0.1.4

Weekly downloads
306
License
MIT
Repository
github
Last release
8 years ago

sails-hook-update-or-create

npm version

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)

ParameterTypeDetails
criteria{}, string, intThe 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
0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago