123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import mongoose from "mongoose";
- const ExchangeHistorySchema = new mongoose.Schema(
- {
- userId: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "User",
- required: true,
- },
- username: {
- type: String,
- required: true,
- },
- item: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "ExchangeItem",
- required: true,
- },
- status: {
- type: String,
- enum: ["待兑换未审核", "待兑换已审核", "已兑换", "拒绝"],
- default: "待兑换未审核",
- },
- points: { type: Number, default: 0 },
- exchangeInfo: {
- account: { type: String },
- name: { type: String },
- phone: { type: String },
- address: { type: String },
- },
- exchangeTime: { type: Date },
- exchangeCount: { type: Number, default: 0 },
- },
- { timestamps: true }
- );
- ExchangeHistorySchema.index({ "userId": 1 }); // userId 索引
- ExchangeHistorySchema.index({ "username": 1 }); // username 索引
- ExchangeHistorySchema.index({ "createdAt": 1 }); // createdAt 索引
- export default mongoose.models.ExchangeHistory ||
- mongoose.model("ExchangeHistory", ExchangeHistorySchema);
|