You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the third argument. Here is the signature of the function: extendSchema(Schema, definition, options). But I can't check now if it possible to get instance options (virtuals) to inherit them.
I have a sample that may help. It leverages the transpiled version of extends from ES6
const mongoose = require("mongoose");
function extendSchema(parent, child, options) {
let updated_schema = Object.assign({}, parent.obj, child);
let updated_child_object = new mongoose.Schema(updated_schema, options);
__extends(updated_child_object, parent);
return updated_child_object;
}
var __extends =
(this && this.__extends) ||
function(d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype =
b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
};
module.exports = extendSchema;
I have some virtuals for populating data. It would be nice if those virtuals would be inherited too.
The text was updated successfully, but these errors were encountered: