Created
April 4, 2020 03:31
-
-
Save LEvinson2504/e3162781c338d62333075e4243954004 to your computer and use it in GitHub Desktop.
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
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