Missingschemaerror: Schema Hasn't Been Registered For Model
Solution 1:
Your schema is not defined in case. Your model.js and app.js is simply going through each of the models that you have defined. That's different from having visibility of CategorySubSchema in your CategoryProduct's model file.
In NodeJS, the schema and model you defined won't be globally scoped. The problem you are having is the scoping issue as you are assuming the Schemas are globally visible. You will have to export them for the other functions to see them.
Please reference the nodejs module_export link here: http://nodejs.org/api/modules.html#modules_module_exports
In your case, you probably need to change your code to the follow in your model file:
exports.CategoryMainSchema = CategoryMainSchema;
and so on in each model file. Then in the model files you want to use these as subschemas, you can require that model like:
varCategoryMainSchema = require('CategoryMain').CategoryMainSchema//assuming CategoryMain is the name of your model file
The syntax might be a bit off but please give it a try. Thanks.
Post a Comment for "Missingschemaerror: Schema Hasn't Been Registered For Model"