mongoose-schema-jsonschema
mongoose-schema-jsonschema copied to clipboard
Feature Request: Add interface to be more static JsonSchema(mongooseModel)
i think it would be less error prone to have an option for passing the model to a function, without having the need for extending all the mongoose types. e.g. i have my models in a different package than the schema-creation script. now i need to include mongoose, for schema creation and it seems, there is something off with peerDependencies or so, because the .jsonSchema function does not exist.
so instead of
mongooseModel.jsonSchema();
i would like to do:
const JsonSChema =require("mongoose-schema-jsonschema");
JsonSchema(mongooseModel);
yes, this... I use shared mongoose libraries, so the Models are instantiated through a provided mongoose connection... Can't seem to find the right way to ensure the JsonSchema function is added to the model...
I tried
module.exports = function connectionFactory(connection) {
logger.trace(`transactionLog model connection ${connection.id}`);
extendMongooose(connection);
return connection.model('TransactionLog', transactionLogSchema);
};
But that results in
TypeError: Cannot destructure property 'Types' of 'mongoose.Schema' as it is undefined.