forked from caglalogy/APPoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacilityCreator.js
More file actions
91 lines (76 loc) · 1.79 KB
/
facilityCreator.js
File metadata and controls
91 lines (76 loc) · 1.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const mongoose = require('mongoose');
const Facility = require('./models/facility');
const bcrypt = require('bcrypt');
mongoose.connect('mongodb+srv://admin:admin@cluster0.mwbbr.mongodb.net/user?retryWrites=true&w=majority', {useNewUrlParser: true, useUnifiedTopology: true})
.then(() =>
{
console.log("Database Connected!");
})
.catch((e) =>
{
console.log('Error!');
console.log(e);
})
mongoose.set('useCreateIndex', true); // for deprecation warning
async function create()
{
const newFacility = new Facility(
{
name : "annie's",
password : "admin",
image : "annieskitchen.jpeg",
about : "Annie's Kitchen is THE vegan restaurant of the Lille metropolis!",
number : "555 123 123",
adress : "Lille",
category : "restaurants"
});
newFacility.password = await bcrypt.hash(newFacility.password, 12);
await newFacility.save()
.then(() =>
{
console.log("it is saved!");
})
.catch((e) =>
{
console.log("ERROR OCCURED!");
console.log(e);
})
}
async function saveDb(newFacility)
{
await newFacility.save()
.then(() =>
{
console.log("it is saved!");
})
.catch((e) =>
{
console.log("ERROR OCCURED!");
console.log(e);
})
}
//create()
const update =
{
date : '14.05.2030',
hour : '15.00',
email : 'Dorukb@gmail.com',
isApproved : false
}
async function test()
{
let facility = await Facility.findOne({name : 'vapiano'});
const id = facility._id;
Facility.updateOne(
{ "_id": id},
{
"$push":
{
"appointments": update
}
}
).then(data => {
console.log(data);
})
}
create()