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