Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions models/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const Review = require("./review.js");

const productSchema = new Schema({
category: String,
name: String,
price: Number,
image: String,
reviews: [{ type: Schema.Types.ObjectId, ref: "Review" }],
});
const Product = mongoose.model("Product", productSchema);

module.exports = Product;
13 changes: 13 additions & 0 deletions models/review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const Product = require("./product.js");

const reviewSchema = new Schema({
username: String,
text: String,
product: [{ type: Schema.Types.ObjectId, ref: "Product" }],
});

const Review = mongoose.model("Review", reviewSchema);

module.exports = Review;
Loading