@@ -54,7 +54,7 @@ export async function updateChat(chatId: string, response: string, messageId: st
54
54
await chatCol . updateOne ( query , update )
55
55
}
56
56
57
- export async function insertChatUsage ( userId : string , roomId : number , chatId : ObjectId , messageId : string , usage : UsageResponse ) {
57
+ export async function insertChatUsage ( userId : ObjectId , roomId : number , chatId : ObjectId , messageId : string , usage : UsageResponse ) {
58
58
const chatUsage = new ChatUsage ( userId , roomId , chatId , messageId , usage )
59
59
await usageCol . insertOne ( chatUsage )
60
60
return chatUsage
@@ -72,8 +72,7 @@ export async function renameChatRoom(userId: string, title: string, roomId: numb
72
72
title,
73
73
} ,
74
74
}
75
- const result = await roomCol . updateOne ( query , update )
76
- return result
75
+ return await roomCol . updateOne ( query , update )
77
76
}
78
77
79
78
export async function deleteChatRoom ( userId : string , roomId : number ) {
@@ -161,7 +160,7 @@ export async function deleteChat(roomId: number, uuid: number, inversion: boolea
161
160
} ,
162
161
}
163
162
}
164
- chatCol . updateOne ( query , update )
163
+ await chatCol . updateOne ( query , update )
165
164
}
166
165
167
166
export async function createUser ( email : string , password : string ) : Promise < UserInfo > {
@@ -175,15 +174,13 @@ export async function createUser(email: string, password: string): Promise<UserI
175
174
}
176
175
177
176
export async function updateUserInfo ( userId : string , user : UserInfo ) {
178
- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
177
+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
179
178
, { $set : { name : user . name , description : user . description , avatar : user . avatar } } )
180
- return result
181
179
}
182
180
183
181
export async function updateUserPassword ( userId : string , password : string ) {
184
- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
182
+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
185
183
, { $set : { password, updateTime : new Date ( ) . toLocaleString ( ) } } )
186
- return result
187
184
}
188
185
189
186
export async function getUser ( email : string ) : Promise < UserInfo > {
0 commit comments