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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Product List
## Product-List

Fork and clone this repository then cd into the product-list folder and run "npm install" in your terminal. Before starting the server, make sure you start your Mongo database. In order for the app to work correctly you need to run "node server.js" in your terminal to start the server. Once the server is started you can go into the "products-front-end" folder and check the readme there for instructions on how to start the front end app.

This project has been created by a student at Parsity, an online software engineering course. The work in this repository is wholly of the student based on a sample starter project that can be accessed by looking at the repository that this project forks.

Expand Down
21 changes: 21 additions & 0 deletions models/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const ReviewSchema = new Schema({
userName: String,
text: String,
product: { type: Schema.Types.ObjectId, ref: "Product" },
});

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);
const Review = mongoose.model("Review", ReviewSchema);

module.exports = { Product, Review };
Loading