| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import mongoose, {
- Document,
- Schema
- } from "mongoose";
- export interface IMenu extends Document {
- userID: mongoose.Types.ObjectId;
- title: string;
- description?: string;
- isActive?: boolean;
- products: Array<{
- categoryIDs: mongoose.Types.ObjectId[];
- productID: mongoose.Types.ObjectId;
- isViewPrice: boolean;
- }>;
- isViewPrice: boolean;
- createdAt: Date;
- updatedAt: Date;
- }
- const menuSchema = new Schema<IMenu>(
- {
- userID: {
- type: Schema.Types.ObjectId,
- ref: "User", // TODO aggregate fonk kullanılacak ref değil
- },
- title: {
- type: String,
- },
- description: {
- type: String,
- },
- isActive: {
- type: Boolean,
- default: true
- },
- products: [
- {
- categoryIDs: {
- type: [Schema.Types.ObjectId],
- default: []
- },
- productID: {
- type: Schema.Types.ObjectId,
- ref: "Product", // TODO ilerde product servis buna göre düzenlenecek aggregate fonskiyonu kullanılacak ref değil
- },
- isViewPrice: {
- type: Boolean,
- }
- }
- ],
- isViewPrice: {
- type: Boolean,
- }
- },
- {
- timestamps: true
- }
- );
- export const Menu = mongoose.model<IMenu>("Menu", menuSchema);
|