1.0.1 • Published 9 years ago

meanie-mongoose-only-id v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

@meanie/mongoose-only-id

npm version node dependencies github issues codacy

Simple Mongoose helper to safely strip objects to just an ID

Meanie

Installation

You can install this package using yarn or npm.

#yarn
yarn add @meanie/mongoose-only-id

#npm
npm install @meanie/mongoose-only-id --save

Usage

const onlyId = require('meanie-mongoose-only-id');

//Objects are stripped to only ID
onlyId({id: '123', name: 'Name'}); //'123'
onlyId({_id: new ObjectId('123'), name: 'Name'}); //'123'

//Also works on arrays
onlyId([
  {id: '123', name: 'Item 1'},
  {_id: new ObjectId('123'), name: 'Name'},
]); //['123', '123']

//Simple values are retained
onlyId('123'); //'123'
onlyId(123); //123

Issues & feature requests

Please report any bugs, issues, suggestions and feature requests in the @meanie/mongoose-only-id issue tracker.

Contributing

Pull requests are welcome! If you would like to contribute to Meanie, please check out the Meanie contributing guidelines.

Credits

License

(MIT License)

Copyright 2016-2017, Adam Reis

2.0.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago