-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
80 lines (70 loc) · 1.91 KB
/
app.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
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
const mongoose = require('mongoose')
const Student = require('./Student.js')
const db = mongoose.connection;
const mongoURI = 'mongodb://localhost:27017/students';
mongoose.connect(mongoURI, { useNewUrlParser: true }, () => {
console.log('the connection with mongod is established')
})
const studentsNames = [
'Abdullah Altwaim',
'Abdulrahman Alrifae',
'Aesha Alshuraim',
'Ahlam Almusallam',
'Ahmed Al-Bahrani',
'Ahmed AlMeshaal',
'Ashwag Alrougui',
'Azzam Alkhaldi',
'Bedour Alrashed',
'Eman Yahya',
'Faisal Alsharari',
'Hanan Alharbi',
'Hazim Alblowi',
'Khalid alarifi',
'Mo Asslahi',
'Mansour Almohsen',
'Munira AlShuhail',
'Munirah almadhi',
'Nada Alotaibi',
'nawaf almansour',
'Norah Alessa',
'Reem AlHarbi',
'sara daghustani',
'Sulaiman Alhabib',
'Turki Almalki',
'Waleed Mastour']
const studentsObjects = studentsNames.map(student => { return { name: student } })
// Student.insertMany(studentsObjects, (error, student) => {
// if (error) {
// console.log(error)
// } else {
// console.log(student);
// } db.close()
// });
// Student.find((err, student) => {
// console.log(student);
// db.close()
// })
// Student.findOneAndUpdate({ name: 'Waleed Mastour ' }, { Attendance: false }, (err, student) => {
// if (err) {
// console.log(err);
// } else {
// console.log(student);
// }
// db.close()
// })
// Student.findOneAndUpdate({ name: 'Turki Almalki' }, { Attendance: false }, (err, student) => {
// if (err) {
// console.log(err);
// } else {
// console.log(student);
// }
// db.close()
// })
// Student.findOneAndRemove({ name: 'Mo Asslahi' }, (err, student) => {
// if (err) {
// console.log(err);
// } else {
// console.log('This is the deleted student:', student);
// }
// db.close()
// })