1.0.0 • Published 6 years ago

mongo-projection-from-keys v1.0.0

Weekly downloads
29
License
MIT
Repository
github
Last release
6 years ago

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