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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Product List

1. how to install.

- after cloning the file npm install in the main folder to install server side dependencies
- cd into product-list-frontend and npm install client side dependencies

2. how to run.
-to run the server, from the main directory npm run start (this will start our server)

- to run our react app to consume data from our server, cd into our product-list-frontend and npm run dev, this will start our client side 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
27 changes: 27 additions & 0 deletions models/product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const mongoose = require("mongoose");
const Review = require("./review");
const Schema = mongoose.Schema;

const ProductSchema = new Schema({
category: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
price: {
type: Number,
required: true,
},
image: {
type: String,
required: true,
},
reviews: [{ type: Schema.Types.ObjectId, ref: "Review" }],
});

const Product = mongoose.model("Product", ProductSchema);

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

const reviewSchema = new Schema({
userName: {
type: String,
required: true,
},
text: {
type: String,
required: true,
},
product: { type: Schema.Types.ObjectId, ref: "Product" },
});
const Review = mongoose.model("Review", reviewSchema);

module.exports = Review;
11 changes: 11 additions & 0 deletions models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const mongoose = require("mongoose");
const { Schema } = mongoose;
const userSchema = new Schema({
googleId: String,
name: String,
email: String,
});

const UserModel = mongoose.model("user", userSchema);

module.exports = UserModel;
Loading