-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.js
32 lines (28 loc) · 809 Bytes
/
models.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var mongoose = require("mongoose");
mongoose.connect(`mongodb+srv://hackreactortest:${process.env.PASSWORD}@cluster0-k0vmg.mongodb.net/test?retryWrites=true`, {useNewUrlParser: true});
// mongodb://localhost/menu if you want to seed locally
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
console.log('connected to database!!!!')
});
var menuSchema = new mongoose.Schema({
item_name: String,
description: String,
price: Number,
popular: Boolean,
special_instruction: Boolean,
extras: {
type: [
{
name: String,
price: Number
}
],
default: undefined
},
restaurant_id: Number,
photo_URL: String
});
var menu = mongoose.model("menu", menuSchema);
module.exports = menu;