Skip to content

Commit 7a25850

Browse files
authored
Create Item.js
1 parent c332531 commit 7a25850

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

backend/models/Item.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)