-
Notifications
You must be signed in to change notification settings - Fork 0
/
radstaskBdbstudentstouserslink.mongo.js
57 lines (49 loc) · 1.33 KB
/
radstaskBdbstudentstouserslink.mongo.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
/* PART OF rads-TASK.B
*
* students collection has a list of student objects
* with the following format
* Student {
* name: String,
* gender: Enum(String),
* enrolmentNumber: Long,
* programme: Programme,
* school: School,
* semesters: [Semester],
* currentSemester: Semester,
* phoneNumber: Long,
* emailId: String,
* user: User
* }
*
* instead of user field it has username, and password fields
* which are reqd. to be removed at the end of this processing task
*/
var somId = db.schools.findOne({name: "Management"})._id
var bbaID = db.programmes.findOne({name: "BBA"})._id
var students = db.students.find({
"programme": "BBA"
})
while(students.hasNext()) {
var student = students.next()
var newUser = {
username: student.user,
password: '49a2ebcf41084163270424e74002551d40dde836',
type: 'student',
student: student._id
}
db.users.insert(newUser)
student.programme = bbaID
student.school = somId
var hisHerUserId = db.users.findOne({username: student.user})._id
student.user = hisHerUserId
db.students.update({_id: student._id}, student)
}
var hiteshaMaam = {
name: "Hitesha Yadav",
gender: "female",
employeeId: 1000,
currentSession: null,
emailId: "hitesha.yadav@gdgoenka.ac.in",
user: "hitesha.yadav",
school: somId
}