-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
83 lines (76 loc) · 1.6 KB
/
notes.txt
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
mongo "mongodb://todo-cluster-shard-00-00-uo9wx.mongodb.net:27017,todo-cluster-shard-00-01-uo9wx.mongodb.net:27017,todo-cluster-shard-00-02-uo9wx.mongodb.net:27017/test?replicaSet=todo-cluster-shard-0" --authenticationDatabase admin --ssl --username aayush123 --password todoapppass
When logging in, validate creds and send clientToken as response.
clientToken is salted hash of mongodb _id.
With every subsequent api request, client sends the clientToken and username.
validate salted hash of mongodb _id against received clientToken.
If authentication succeeds, process request. else, refuse request.
usecases:
- add tasks to project
- mark task as completed
- delete task
- add project
- delete project
- delete all completed tasks
- fetch all data
- sync all data
add project query:
db.todoList.update(
{
username:"testID"
},
{
$push: {
projects: {projectName: "TestProj2"}
}
}
);
add task query:
db.todoList.update(
{
username:"testID"
},
{
$push: {
tasks: {projectName: "TestProj2", taskName: "TestTask", completed: false}
}
}
);
delete project query:
db.todoList.update(
{
username:"testID"
},
{
$pull: {
projects: {projectName: "TestProj2"},
tasks: {
projectName: "TestProj2"
}
}
}
);
delete task query:
db.todoList.update(
{
username:"testID"
},
{
$pull: {
tasks: {
taskName: "TestTask"
}
}
}
);
update task completion status of task:
db.todoList.update(
{
username:"testID",
"tasks.taskName": "TestTask"
},
{
$set: {
"tasks.$.completed": true
}
}
);