Mongoose Validation
This commit is contained in:
@@ -2,11 +2,25 @@ const mongoose = require("mongoose");
|
||||
|
||||
const dishSchema = mongoose.Schema({
|
||||
_id: mongoose.Types.ObjectId,
|
||||
name: String,
|
||||
category: String,
|
||||
price: Number,
|
||||
name: {
|
||||
type: String,
|
||||
maxlength: 128,
|
||||
required: true,
|
||||
},
|
||||
category: {
|
||||
type: String,
|
||||
maxlength: 64,
|
||||
required: true,
|
||||
},
|
||||
price: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
notes: String,
|
||||
imgUrl: String,
|
||||
imgUrl: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
hidden: Boolean,
|
||||
weight: Number,
|
||||
allergens: {
|
||||
|
||||
@@ -2,10 +2,22 @@ const mongoose = require("mongoose");
|
||||
|
||||
const restaurantSchema = mongoose.Schema({
|
||||
_id: mongoose.Types.ObjectId,
|
||||
name: String,
|
||||
city: String,
|
||||
imgUrl: String,
|
||||
workingHours: String,
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
city: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
imgUrl: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
workingHours: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
hidden: Boolean,
|
||||
dishes: [mongoose.Types.ObjectId],
|
||||
});
|
||||
|
||||
@@ -2,10 +2,19 @@ const mongoose = require("mongoose");
|
||||
|
||||
const userSchema = mongoose.Schema({
|
||||
_id: mongoose.Types.ObjectId,
|
||||
email: String,
|
||||
password: String,
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
restaurantId: mongoose.Types.ObjectId,
|
||||
subscriptionActive: Boolean,
|
||||
subscriptionActive: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
subscriptionDue: Date,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user