Mongoose Validation

This commit is contained in:
2020-07-13 20:15:03 +02:00
parent dfcb78f979
commit 59cc6c54cd
5 changed files with 153 additions and 132 deletions

View File

@@ -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: {

View File

@@ -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],
});

View File

@@ -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,
});