-
Notifications
You must be signed in to change notification settings - Fork 1
/
databaseConfig.js
53 lines (38 loc) · 1.18 KB
/
databaseConfig.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const express = require("express");
const mongoose = require("mongoose");
const hotFlavours=require("./hotFlavours");
const array=require("./cake");
const app = express();
mongoose.connect("mongodb://localhost:27017/BakeryDb", {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
});
mongoose.set("useCreateIndex", true);
const flavoursSchema = new mongoose.Schema({
flavor: String,
image: String,
description: String,
variants: Array,
});
const hotFlavoursSchema = new mongoose.Schema({
flavor: String,
image: String,
description: String,
variants: Array,
});
const HotFlavours = new mongoose.model("HotFlavour", hotFlavoursSchema);
//code to add dummy hot flavours
HotFlavours.insertMany(hotFlavours,(err)=>{
console.log("Hot flavours configured successfully!");
});
const Flavours = new mongoose.model("flavour", flavoursSchema);
//code to add dummy flavors
Flavours.insertMany(array,(err)=>{
console.log("Flavors successfuly configured!");
console.log("Now stop this server and you can start server.js file using node server.js command!");
});
//server startup
app.listen(3000, () => {
console.log("server started on port 3000");
});