|
@@ -0,0 +1,29 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
|
+
|
|
|
|
+// 收货地址
|
|
|
|
+const address = {
|
|
|
|
+ customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
|
|
|
|
+ name: { type: String, required: false, zh: '收货人' }, //
|
|
|
|
+ phone: { type: String, required: false, zh: '收货人联系电话' }, //
|
|
|
|
+ province: { type: String, required: false, zh: '省份' }, //
|
|
|
|
+ city: { type: String, required: false, zh: '市' }, //
|
|
|
|
+ area: { type: String, required: false, zh: '区' }, //
|
|
|
|
+ address: { type: String, required: false, zh: '详细地址' }, //
|
|
|
|
+ is_default: { type: String, required: false, default: '0', zh: '是否默认' }, // 字典:is_default
|
|
|
|
+};
|
|
|
|
+const schema = new Schema(address, { toJSON: { getters: true, virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
|
+schema.index({ customer: 1 });
|
|
|
|
+schema.index({ name: 1 });
|
|
|
|
+schema.index({ phone: 1 });
|
|
|
|
+schema.index({ is_default: 1 });
|
|
|
|
+
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('Address', schema, 'address');
|
|
|
|
+};
|