Aggregate.prototype.model()

Parameters
  • [model] «Model» the model to which the aggregate is to be bound
Returns:
  • «Aggregate,Model» if model is passed, will return this, otherwise will return the model

Get/set the model that this aggregation will execute on.

Example:

  1. const aggregate = MyModel.aggregate([{ $match: { answer: 42 } }]);
  2. aggregate.model() === MyModel; // true
  3. // Change the model. There's rarely any reason to do this.
  4. aggregate.model(SomeOtherModel);
  5. aggregate.model() === SomeOtherModel; // true