meanie-mongoose-to-json
A simple plugin for Mongoose to normalize JSON output, for use with Meanie Express Seed projects
Installation
You can install this package using npm
.
npm install meanie-mongoose-to-json --save
Usage
As a global plugin for all Mongoose schema's:
const mongoose = ;mongoose;
NOTE: as of Mongoose 4.5.4 this does not work for sub schema's yet, see #4271.
For a specific (sub) schema:
const mongoose = ;const Schema = mongooseSchema;const MySchema = {};MySchema;
This plugin will normalize JSON output for client side applications from:
To a simpler:
From version 1.1.0 onwards, this plugin now also removes private paths from the JSON, e.g.:
const mongoose = ;const toJson = ; const schema = email: type: String password: type: String private: true; schema; const User = mongoose;const user = email: 'test@test.com' password: 'test'; console;
This will output:
Issues & feature requests
Please report any bugs, issues, suggestions and feature requests in the meanie-mongoose-to-json issue tracker.
Contributing
Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.
Credits
- Meanie logo designed by Quan-Lin Sim
License
(MIT License)
Copyright 2016-2017, Adam Reis