We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c332531 commit 7a25850Copy full SHA for 7a25850
backend/models/Item.js
@@ -0,0 +1,14 @@
1
+const mongoose = require("mongoose");
2
+
3
+const itemSchema = new mongoose.Schema(
4
+ {
5
+ title: { type: String, required: true },
6
+ description: { type: String },
7
+ owner: { type: mongoose.Schema.Types.ObjectId, ref: "User" }
8
+ },
9
+ { timestamps: true }
10
+);
11
12
+itemSchema.index({ title: 1 }); // optimize queries by title
13
14
+module.exports = mongoose.model("Item", itemSchema);
0 commit comments