【发布时间】:2017-10-22 03:03:47
【问题描述】:
我正在使用 MongoDb 和 Mongoose 为实践电子商务网站创建模型。到目前为止,我的 Product 模型如下所示:
var mongoose = require('mongoose');
module.exports = mongoose.model('Product',{
imagePath: {type: String, required: true},
title: {type: String, required: true},
description: {type: String, required: true},
price: {type: Number, required: true}
});
我的问题是说我有一件衬衫,它有不同的尺寸可供选择,例如 S、M 和 L。添加它的最佳方法是什么?此外,如果我包括库存跟踪,我将如何跟踪所有尺寸?在此先感谢您的任何帮助。
【问题讨论】:
标签: node.js mongodb mongoose mongoose-schema