数据存储结构 - TWA-Eurasia/letusgo GitHub Wiki
var Item = new Schema({
name: String,
unit: String,
brand: String,
price: Number,
leftNumber: Number,
saleNumber: {type: Number, default: 0},
imageUrl: String,
description: String,
state: {type: String, default: 'new'},
mainCategory: {type: Schema.ObjectId, ref: 'MainCategory'},
childCategories: [{type: Schema.ObjectId, ref: 'ChildCategory'}],
specification: String
});
var User = new Schema({
name: {type: String, unique: true},
password: String,
phoneNumber: Number,
address: String,
email: String,
cart: {type: Schema.ObjectId, ref: 'Cart'},
indents: [{
indent: {type: Schema.ObjectId, ref: 'Indent'}
}]
});
var Indent = new Schema({
userId: {type: Schema.ObjectId, ref: 'User'},
items: [{
itemId: {type: Schema.ObjectId, ref: 'Item'},
number: Number
}],
date: Date,
isPaid: {type: Boolean, default: false}
});
var Cart = new Schema({
userId: {type: Schema.ObjectId, ref: 'User'},
items: [{
itemId: {type: Schema.ObjectId, ref: 'Item'},
number: Number,
indented: {type: Boolean, default: false}
}]
});
var MainCategory = new Schema({
name: String,
childId: [{
type: Schema.ObjectId,
ref: 'ChildCategory'
}]
});
var ChildCategory = new Schema({
name: String,
superId: {
type: Schema.ObjectId,
ref: 'MainCategory'
}
});