Schema.prototype.queue()

Parameters
  • name «String» name of the document method to call later

  • args «Array» arguments to pass to the method

Adds a method call to the queue.

Example:

  1. schema.methods.print = function() { console.log(this); };
  2. schema.queue('print', []); // Print the doc every one is instantiated
  3. const Model = mongoose.model('Test', schema);
  4. new Model({ name: 'test' }); // Prints '{"_id": ..., "name": "test" }'