mongo-projection-from-keys
v1.0.0
Published
Generate MongoDB projection from list of keys to include / exclude
Downloads
194
Maintainers
Readme
mongo-projection-from-keys
Generate MongoDB projection from list of keys to include / exclude
Install
$ yarn add mongo-projection-from-keys
Usage
const mongoProjectionFromKeys = require('mongo-projection-from-keys');
mongoProjectionFromKeys({
include: ['email', 'username'],
exclude: ['_id']
});
// => '{email: 1, username: 1, _id: 0}'
API
mongoProjectionFromKeys({include, exclude})
{include, exclude}
Type: object
Options object with include
and exclude
arrays.
exclude
has higher priority.
License
MIT © Vlad Holubiev