Have ideas to improve npm?Join in the discussion! »

This package has been deprecated

Author message:

This package has moved to @meanie/mongoose-only-id

meanie-mongoose-only-id

1.0.1 • Public • Published

meanie-mongoose-only-id

npm version node dependencies github issues codacy

Simple Mongoose helper to strip an object to just an ID, for use with Meanie Express Seed projects

Meanie

Installation

You can install this package using npm.

npm install meanie-mongoose-only-id --save

Usage

let onlyId = require('meanie-mongoose-only-id');
 
//Simple values are retained
onlyId('123'); //'123'
onlyId(123); //123
 
//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']

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

Install

npm i meanie-mongoose-only-id

DownloadsWeekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar