This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert.js
72 lines (66 loc) · 2.16 KB
/
insert.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
const MongoClient = require("mongodb").MongoClient;
const uri = "mongodb+srv://theg:[email protected]/UManage?retryWrites=true&w=majority";
var client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true
});
const hicheel = require("../hicheel.json");
const dun2018fall = require("../dun2018fall.json");
const dun2018spr = require("../dun2018spr.json");
const classChoice2018fall = require("../CC2018fall.json");
const classChoice2018spr = require("../CC2018spr.json");
const classes = require("../classes.json");
client.connect((err, client) => {
if (err) {
console.log(err);
}
const db = client.db("UManage");
const Classes = db.collection("Classes");
const ClassDet = db.collection("ClassDet");
const Marks2018fall = db.collection("Marks2018fall");
const Marks2018spr = db.collection("Marks2018spr");
const CC2018spr = db.collection("classChoice2018spr");
const CC2018fall = db.collection("ClassChoice2018fall");
Classes.insertMany(
classes.map(obj => {
obj.Name = obj.Name.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
ClassDet.insertMany(
hicheel.map(obj => {
obj.Name = obj.Name.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
Marks2018fall.insertMany(
dun2018fall.map(obj => {
obj.Хичээлийн_нэр = obj.Хичээлийн_нэр.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
Marks2018spr.insertMany(
dun2018spr.map(obj => {
obj.Хичээлийн_нэр = obj.Хичээлийн_нэр.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
CC2018fall.insertMany(
classChoice2018fall.map(obj => {
obj.Хичээлийн_нэр = obj.Хичээлийн_нэр.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
CC2018spr.insertMany(
classChoice2018spr.map(obj => {
obj.Хичээлийн_нэр = obj.Хичээлийн_нэр.toUpperCase();
return obj;
}),
(err, res) => console.log(err ? err : res)
);
});