Skip to content

Instantly share code, notes, and snippets.

@LEvinson2504
Created April 4, 2020 03:31
Show Gist options
  • Save LEvinson2504/e3162781c338d62333075e4243954004 to your computer and use it in GitHub Desktop.
Save LEvinson2504/e3162781c338d62333075e4243954004 to your computer and use it in GitHub Desktop.
const mongoose = require("mongoose");
// const MenuSchema = new mongoose.Schema({
// });
const MenuSchema = new mongoose.Schema({
itemName: {
type: String,
required: true,
default: "ItemName",
},
itemPrice: {
type: Number,
required: true,
default: 0,
},
itemImage: {
type: String,
required: false, //can add a default image here
},
itemDescription: {
type: String,
// required: true,
},
itemType: {
type: String,
// required: true,
},
orders: [OrderSchema]
});
var OrderSchema = new Schema({
table: {
type: String,
required: true
},
date: {
Type: Date,
default: Date.now
}
});
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
},
date: {
type: Date,
default: Date.now
},
menu: {
type: [MenuSchema],
default: [{ itemName: "nothing here",
itemPrice: 0,
itemDescription: "add description here"
, itemType: "not selected"
}]
},
});
const User = mongoose.model("User", UserSchema);
module.exports = User;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment