Category.ts 663 B

123456789101112131415161718192021222324252627282930313233
  1. import mongoose, {
  2. Document,
  3. Schema
  4. } from "mongoose";
  5. export interface ICategory extends Document {
  6. userID: mongoose.Types.ObjectId;
  7. isActive: boolean;
  8. createdAt: Date;
  9. updatedAt: Date;
  10. title: string;
  11. index: number;
  12. }
  13. const CategorySchema = new Schema<ICategory>(
  14. {
  15. userID: mongoose.Schema.Types.ObjectId,
  16. title: {
  17. type: String,
  18. trim: true
  19. },
  20. index: Number,
  21. isActive: {
  22. type: Boolean,
  23. default: true
  24. }
  25. },
  26. {
  27. timestamps: true
  28. }
  29. );
  30. export const Category = mongoose.model<ICategory>("Category", CategorySchema);