# mongoose-create-or-update

> A Promise-based Mongoose plugin for creating and updating documents in a single statement.

Latest version **1.0.3** (published 2017-03-31) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-03-31 |
| First published | 2016-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | neogeek |
| Keywords | mongoose, plugin |

## Links

- npm: https://www.npmjs.com/package/mongoose-create-or-update
- Repository: https://github.com/neogeek/mongoose-create-or-update
- Issues: https://github.com/neogeek/mongoose-create-or-update/issues
- npm.io page: https://npm.io/package/mongoose-create-or-update

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2017-03-31
- 1.0.2 — 2016-12-09
- 1.0.1 — 2016-10-14
- 1.0.0 — 2016-10-05

## README

# mongoose-create-or-update

> A Promise-based Mongoose plugin for creating and updating documents in a single statement.

[![Build Status](https://travis-ci.org/neogeek/mongoose-create-or-update.svg?branch=master)](https://travis-ci.org/neogeek/mongoose-create-or-update)
[![codecov](https://img.shields.io/codecov/c/github/neogeek/mongoose-create-or-update/master.svg)](https://codecov.io/gh/neogeek/mongoose-create-or-update)
[![NPM Version](http://img.shields.io/npm/v/mongoose-create-or-update.svg?style=flat)](https://www.npmjs.org/package/mongoose-create-or-update)
[![Greenkeeper badge](https://badges.greenkeeper.io/neogeek/mongoose-create-or-update.svg)](https://greenkeeper.io/)
[![Latest Documentation](https://doxdox.org/images/badge-flat.svg)](https://doxdox.org/neogeek/mongoose-create-or-update)

## Install

```bash
$ npm install mongoose mongoose-create-or-update --save
```

## Usage

```javascript
const mongoose = require('mongoose');

const dataSchema = new mongoose.Schema({
    'contents': String
});

dataSchema.plugin(require('mongoose-create-or-update'));

const dataModel = mongoose.model('data', dataSchema);
```

```javascript
let dataId = null;

dataModel.createOrUpdate({
    '_id': dataId
}, {
    'contents': 'Lorem ipsum dolor sit amet'
}).then(data => {

    dataId = data._id;

    done();

}).catch(err => {

    console.log(err);

});
```

## Documentation

View full documentation [here](https://doxdox.org/neogeek/mongoose-create-or-update).

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