Parameters
  • [skipInit] «Boolean|Object» whether to skip initialization (defaults to false). If an object, treated as options.

Returns:
  • «Model» The model associated with . Mongoose will create the model if it doesn’t already exist.

Models defined on the mongoose instance are available to all connection created by the same mongoose instance.

Example:

When no argument is passed, Mongoose uses the model name. If you don’t like this behavior, either pass a collection name, use mongoose.pluralize(), or set your schemas collection name option.

Example:

  1. const schema = new Schema({ name: String }, { collection: 'actor' });
  2. // or
  3. const M = mongoose.model('Actor', schema, collectionName)