MCPcopy
hub / github.com/lfb/nodejs-koa-blog / update

Method update

app/dao/user.js:117–135  ·  view source on GitHub ↗
(id, v)

Source from the content-addressed store, hash-verified

115
116 // 更新用户
117 static async update(id, v) {
118 // 查询用户
119 const user = await User.findByPk(id);
120 if (!user) {
121 throw new global.errs.NotFound('没有找到相关用户');
122 }
123
124 // 更新用户
125 user.email = v.get('body.email')
126 user.username = v.get('body.username')
127 user.status = v.get('body.status')
128
129 try {
130 const res = await user.save();
131 return [null, res]
132 } catch (err) {
133 return [err, null]
134 }
135 }
136
137 static async list(query = {}) {
138 const {id, email, status, username, page = 1, page_size = 10} = query

Callers 5

reply.jsFile · 0.45
category.jsFile · 0.45
user.jsFile · 0.45
comment.jsFile · 0.45
article.jsFile · 0.45

Calls 1

getMethod · 0.80

Tested by

no test coverage detected