1
我試圖在我的purchaseSchema中調用我的productSchema,但是我得到了這個錯誤:OverwriteModelError:編譯後無法覆蓋Product
模型。 我可以嘗試什麼?OverwriteModelError:一旦編譯就無法覆蓋`Product`模型
這是我的產品架構:
mongoose = require('mongoose');
var Schema = mongoose.Schema;
var productSchema = new Schema({
cd: {
type: Number,
require: true
},
nm_iten: {
type: String,
require: true
},
type_iten: {
type: String,
require: true
},
unity: {
type: String,
require: true
},
});
var product = mongoose.model('Product',productSchema);
module.exports = {product:product}
而且,這是我的購買模式:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var productSchema = require('./products');
var product = productSchema.product;
var purchaseSchema = new Schema({
code: {
type: Number,
require: true
},
product:[product],
quant: {
type: Number,
require: true
},
vl_uni: {
type: Number,
require: true
},
vl_total: {
type: Number,
require: true
}
});
mongoose.model('Purchase',purchaseSchema);