helpers/mongooseHelper.js
function assertInstance(instance, model) {
  const modelName = get('modelName')(model)
  try {
    mongoose.model(modelName)
  } catch (err) {
    throw Error(`no such model as ${modelName}`)
  }
  const errMsg = stripIndents`
    Expected an instance of ${modelName} but got this:
    ${JSON.stringify(instance, undefined, 2)}`
  assert(instance instanceof model, errMsg)
}
function assertInstance(instance, model) {
  const modelName = get('modelName')(model)
  try {
    mongoose.model(modelName)
  } catch (err) {
    throw Error(`no such model as ${modelName}`)
  }
  const errMsg = stripIndents`
    Expected an instance of ${modelName} but got this:
    ${JSON.stringify(instance, undefined, 2)}`
  assert(instance instanceof model, errMsg)
}
function assertInstance ( instance , model ) { const modelName = get ( 'modelName' ) ( model ) try { mongoose . model ( modelName ) } catch ( err ) { throw Error ( ` ${ modelName } ` ) } const errMsg = stripIndents ` ${ modelName } ${ JSON . stringify ( instance , undefined , 2 ) } ` assert ( instance instanceof model , errMsg ) }
Throws if a given object is not an instance of given model.
@method assertInstance
@param {Mixed} instance - Could be anything, but most likely a mongoose Model
@param {Model} model - The Model from Mongoose (see mongoose.model('User'))
@return {undefined}
@throws {Error} - Throws if input is not an instance of model, or if model doesn't exist
Throws if a given object is not an instance of given model .