npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

@meanie/mongoose-update-denormalized

2.1.0 • Public • Published

@meanie/mongoose-update-denormalized

npm version node dependencies github issues codacy

A plugin for Mongoose to normalize JSON output

Meanie

Installation

You can install this package using yarn or npm.

#yarn 
yarn add @meanie/mongoose-update-denormalized
 
#npm 
npm install @meanie/mongoose-update-denormalized --save

Usage

Setup as a global plugin for all Mongoose schema's:

const mongoose = require('mongoose');
const updateDenormalized = require('@meanie/mongoose-update-denormalized');
 
mongoose.plugin(updateDenormalized);

Or for a specific (sub) schema:

const mongoose = require('mongoose');
const updateDenormalized = require('@meanie/mongoose-update-denormalized');
const {Schema} = mongoose;
 
const MySchema = new Schema({});
MySchema.plugin(updateDenormalized);

This plugin exposes a static method to update denormalized data:

const User = mongoose.model('User');
const {_id, name, region} = location;
await User.updateDenormalized('location', _id, {name, region});

This would update the name and region properties on the denormalized location property on users, for the given matching location ID.

Issues & feature requests

Please report any bugs, issues, suggestions and feature requests in the @meanie/mongoose-update-denormalized issue tracker.

Contributing

Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.

Credits

License

(MIT License)

Copyright 2016-2018, Adam Reis

install

npm i @meanie/mongoose-update-denormalized

Downloadsweekly downloads

4

version

2.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability