aboutsummaryrefslogtreecommitdiff
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/Product.js26
-rw-r--r--server/models/User.js4
2 files changed, 30 insertions, 0 deletions
diff --git a/server/models/Product.js b/server/models/Product.js
new file mode 100644
index 0000000..f825a8b
--- /dev/null
+++ b/server/models/Product.js
@@ -0,0 +1,26 @@
+const mongoose = require('mongoose');
+
+const ProductSchema = new mongoose.Schema({
+ name: {
+ type: String,
+ required: [true, "Product must have a name."],
+ maxLength: [100, "Product name can't have more then 100 characters."]
+ },
+ description: {
+ type: String,
+ required: false
+ },
+ imagePath: {
+ type: String,
+ required: false,
+ maxLength: [256, "Product's image path can't have more then 256 characters."]
+ },
+ price: {
+ type: Number,
+ required: [true, "Product must have a price."]
+ }
+});
+
+const ProductModel = new mongoose.model('Product', ProductSchema);
+
+module.exports = ProductModel;
diff --git a/server/models/User.js b/server/models/User.js
index 294c016..e508f4c 100644
--- a/server/models/User.js
+++ b/server/models/User.js
@@ -34,6 +34,10 @@ const UserSchema = new mongoose.Schema({
type: String,
required: [true, "You need to provide a password."],
},
+ admin: {
+ type: Boolean,
+ default: false
+ }
});
const UserModel = new mongoose.model('User', UserSchema);