src/mongoose.js
function getModel (app, name, Model) {
  const mongooseClient = app.get('mongoose');
  assert(mongooseClient, 'mongoose client not set by app');
  const modelNames = mongooseClient.modelNames();
  if (modelNames.includes(name)) {
    return mongooseClient.model(name);
  } else {
    assert(Model && typeof Model === 'function', 'Model function not privided.');
    return Model(app, name);
  }
}
function getModel (app, name, Model) {
  const mongooseClient = app.get('mongoose');
  assert(mongooseClient, 'mongoose client not set by app');
  const modelNames = mongooseClient.modelNames();
  if (modelNames.includes(name)) {
    return mongooseClient.model(name);
  } else {
    assert(Model && typeof Model === 'function', 'Model function not privided.');
    return Model(app, name);
  }
}
function getModel ( app , name , Model ) { const mongooseClient = app . get ( 'mongoose' ) ; assert ( mongooseClient , 'mongoose client not set by app' ) ; const modelNames = mongooseClient . modelNames ( ) ; if ( modelNames . includes ( name ) ) { return mongooseClient . model ( name ) ; } else { assert ( Model && typeof Model === 'function' , 'Model function not privided.' ) ; return Model ( app , name ) ; } }
Get or create the mongoose model if not exists
Get or create the mongoose model if not exists