-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from adnan-mujagic/adnan-mujagic/TECH-1-project…
…-structure Adding database models
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const categorySchema = mongoose.Schema({ | ||
name: String, | ||
}); | ||
|
||
const Category = mongoose.model("Category", categorySchema); | ||
|
||
module.exports = Category; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const orderSchema = mongoose.Schema({ | ||
products: [ | ||
{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "Product", | ||
}, | ||
], | ||
total: Number, | ||
buyer: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "User", | ||
}, | ||
status: String, | ||
}); | ||
|
||
const Order = mongoose.model("Order", orderSchema); | ||
|
||
module.exports = Order; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const productSchema = mongoose.Schema({ | ||
name: String, | ||
description: String, | ||
images: [ | ||
{ | ||
type: String, | ||
}, | ||
], | ||
price: Number, | ||
categories: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "Category", | ||
}, | ||
quantity: Number, | ||
date_added: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
last_restocked: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
properties: [ | ||
{ | ||
type: Object, | ||
}, | ||
], | ||
}); | ||
|
||
const Product = mongoose.model("Product", productSchema); | ||
|
||
module.exports = Product; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const reviewSchema = mongoose.Schema({ | ||
product: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "Product", | ||
}, | ||
user: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "User", | ||
}, | ||
rating: Number, | ||
text: String, | ||
likes: [ | ||
{ | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: "User", | ||
}, | ||
], | ||
}); | ||
|
||
const Review = mongoose.model("Review", reviewSchema); | ||
|
||
module.exports = Review; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const mongoose = require("mongoose"); | ||
|
||
const userSchema = mongoose.Schema({ | ||
first_name: String, | ||
last_name: String, | ||
bio: { | ||
type: String, | ||
default: "", | ||
}, | ||
username: String, | ||
password: String, | ||
email: String, | ||
age: Number, | ||
phone_number: String, | ||
created_at: { | ||
type: Date, | ||
default: Date.now, | ||
}, | ||
profile_picture: { | ||
type: String, | ||
default: | ||
"https://cdn-icons.flaticon.com/png/512/1144/premium/1144709.png?token=exp=1648896007~hmac=8fec9c21f3c232dd89ccca64cf0dcc51", | ||
}, | ||
role: { | ||
type: String, | ||
default: "NORMAL", | ||
}, | ||
}); | ||
|
||
const User = mongoose.model("User", userSchema); | ||
|
||
module.exports = User; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters