2.0.0 • Published 3 years ago

mongoose-detective v2.0.0

Weekly downloads
1,332
License
MIT
Repository
github
Last release
3 years ago

mongoose-detective Build Status NPM version js-standard-style

Find the referenced model name at a specified path

npm i mongoose-detective --save

Usage

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