# sails-hook-update-or-create

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

Latest version **0.1.4** (published 2016-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install sails-hook-update-or-create
pnpm add sails-hook-update-or-create
yarn add sails-hook-update-or-create
bun add sails-hook-update-or-create
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2016-10-17 |
| First published | 2016-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Joshua Marquez |
| Maintainers | joshua.marquez |
| Keywords | sails, hook, waterline, updateorcreate |

## Links

- npm: https://www.npmjs.com/package/sails-hook-update-or-create
- Repository: https://github.com/protocoolmx/sails-hook-update-or-create
- Homepage: https://github.com/protocoolmx/sails-hook-update-or-create#readme
- Issues: https://github.com/protocoolmx/sails-hook-update-or-create/issues
- npm.io page: https://npm.io/package/sails-hook-update-or-create

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ~4.16.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2016-10-17
- 0.1.3 — 2016-10-17
- 0.1.2 — 2016-09-11

## README

# sails-hook-update-or-create

[![npm version](https://badge.fury.io/js/sails-hook-update-or-create.svg)](https://badge.fury.io/js/sails-hook-update-or-create)

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

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

## Test

```
$ npm test
```

---
_Source: https://npm.io/package/sails-hook-update-or-create · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
