mongo-projection-from-keys

1.0.0 • Public • Published

mongo-projection-from-keys Build Status

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

Package Sidebar

Install

npm i mongo-projection-from-keys

Weekly Downloads

57

Version

1.0.0

License

MIT

Last publish

Collaborators

  • vladgolubev