Menu.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import mongoose, {
  2. Document,
  3. Schema
  4. } from "mongoose";
  5. export interface IMenu extends Document {
  6. userID: mongoose.Types.ObjectId;
  7. title: string;
  8. description?: string;
  9. isActive?: boolean;
  10. products: Array<{
  11. productID: mongoose.Types.ObjectId;
  12. isViewPrice: boolean;
  13. }>;
  14. isViewPrice: boolean;
  15. createdAt: Date;
  16. updatedAt: Date;
  17. }
  18. const menuSchema = new Schema<IMenu>(
  19. {
  20. userID: {
  21. type: Schema.Types.ObjectId,
  22. ref: "User", // TODO aggregate fonk kullanılacak ref değil
  23. },
  24. title: {
  25. type: String,
  26. },
  27. description: {
  28. type: String,
  29. },
  30. isActive: {
  31. type: Boolean,
  32. default: true
  33. },
  34. products: [
  35. {
  36. productID: {
  37. type: Schema.Types.ObjectId,
  38. ref: "Product", // TODO ilerde product servis buna göre düzenlenecek aggregate fonskiyonu kullanılacak ref değil
  39. },
  40. isViewPrice: {
  41. type: Boolean,
  42. }
  43. }
  44. ],
  45. isViewPrice: {
  46. type: Boolean,
  47. }
  48. },
  49. {
  50. timestamps: true
  51. }
  52. );
  53. export const Menu = mongoose.model<IMenu>("Menu", menuSchema);