-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
105 lines (93 loc) · 2.27 KB
/
db.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const mongo = require('./mongo')
// 查询用户信息
const findUserInfo = userId => {
return mongo.findOneById('user', userId)
}
// 更新用户
const updateUser = (userId, updateObj) => {
return mongo.updateOne('user', { _id: userId }, updateObj)
}
// 查询用户标签组
const findUserTags = userId => {
return mongo.findAll('url_tag', { userId })
}
// 查询用户信息-mail
const findUserByMail = mail => {
return mongo.findOne('user', { mail })
}
// 插入一条用户信息
const insertUser = data => {
return mongo.insertOne('user', data)
}
// 插入一条用户用户标签
const inserUserTag = data => {
return mongo.insertOne('url_tag', data)
}
// 发送注册验证码
const sendRegisterEmail = (mail, captchaCode) => {
const data = {
mail,
captchaCode,
sendTime: new Date(),
}
return mongo.insertOne('send_mail', data)
}
// 校验登录验证码
const verifyRegisterCode = (mail, code) => {
return mongo.findOne('send_mail', { mail: mail })
}
// 查询用户稍后再看
const findUserLater = userId => {
return mongo.findAll('see_later', { userId: userId })
}
// 插入一条稍后再看
const insertLater = data => {
return mongo.insertOne('see_later', data)
}
// 插入多条稍后再看
const insertLaterMany = data => {
return mongo.insertMany('see_later', data)
}
// 更新稍后状态
const updateLater = (id, updateObj) => {
return mongo.updateOneById('see_later', id, updateObj)
}
const deleteLater = id => {
return mongo.deleteOneById('see_later', id)
}
// 关键词记事本
const insertTodoKeys = data => {
return mongo.insertOne('todo_keys', data)
}
const findUserTodoKeys = userId => {
return mongo.findAll('todo_keys', { userId: userId })
}
const insertTodoMany = data => {
return mongo.insertMany('todo_keys', data)
}
const updateTodoKeys = (id, updateObj) => {
return mongo.updateOneById('todo_keys', id, updateObj)
}
const deleteTodoKeys = id => {
return mongo.deleteOneById('todo_keys', id)
}
module.exports = {
insertTodoKeys,
updateTodoKeys,
findUserTodoKeys,
deleteTodoKeys,
sendRegisterEmail,
verifyRegisterCode,
findUserLater,
findUserByMail,
findUserTags,
inserUserTag,
updateUser,
insertLater,
findUserInfo,
insertUser,
insertTodoMany,
deleteLater,
insertLaterMany,
updateLater,
}