30 lines
760 B
TypeScript
30 lines
760 B
TypeScript
import mongoose, { Schema, Document } from 'mongoose';
|
|
|
|
export interface IShopItem extends Document {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
price: number;
|
|
imageUrl?: string;
|
|
available: boolean;
|
|
type: 'badge' | 'frame' | 'effect' | 'other';
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
const ShopItemSchema: Schema = new Schema({
|
|
name: { type: String, required: true },
|
|
description: { type: String, required: true },
|
|
price: { type: Number, required: true },
|
|
imageUrl: { type: String },
|
|
available: { type: Boolean, default: true },
|
|
type: {
|
|
type: String,
|
|
required: true,
|
|
enum: ['badge', 'frame', 'effect', 'other']
|
|
}
|
|
}, {
|
|
timestamps: true
|
|
});
|
|
|
|
export default mongoose.model<IShopItem>('ShopItem', ShopItemSchema);
|