mongoose-detective
Version:
Find the referenced model name at a specified path.
35 lines (23 loc) • 1.03 kB
Markdown
# mongoose-detective [](https://travis-ci.org/Zertz/mongoose-detective) [](http://badge.fury.io/js/mongoose-detective) [](https://github.com/feross/standard)
Find the referenced model name at a specified path
```js
npm i mongoose-detective --save
```
## Usage
```js
const detective = require('mongoose-detective')
const mongoose = require('mongoose')
const InvoiceSchema = new Schema({
customer: { type: mongoose.Schema.Types.ObjectId, ref: 'Customer' }
})
mongoose.model('Invoice', InvoiceSchema)
const modelName = detective(mongoose.models.Invoice, 'customer')
// modelName = 'Customer'
```
## Contributing
I'd love for you to contribute and make mongoose-detective even better than it is today!
```
git clone https://github.com/Zertz/mongoose-detective.git
npm install
npm test
```