@@ -49,7 +49,7 @@ export async function updateChat(chatId: string, response: string, messageId: st
4949 await chatCol . updateOne ( query , update )
5050}
5151
52- export async function insertChatUsage ( userId : string , roomId : number , chatId : ObjectId , messageId : string , usage : UsageResponse ) {
52+ export async function insertChatUsage ( userId : ObjectId , roomId : number , chatId : ObjectId , messageId : string , usage : UsageResponse ) {
5353 const chatUsage = new ChatUsage ( userId , roomId , chatId , messageId , usage )
5454 await usageCol . insertOne ( chatUsage )
5555 return chatUsage
@@ -67,8 +67,7 @@ export async function renameChatRoom(userId: string, title: string, roomId: numb
6767 title,
6868 } ,
6969 }
70- const result = await roomCol . updateOne ( query , update )
71- return result
70+ return await roomCol . updateOne ( query , update )
7271}
7372
7473export async function deleteChatRoom ( userId : string , roomId : number ) {
@@ -156,7 +155,7 @@ export async function deleteChat(roomId: number, uuid: number, inversion: boolea
156155 } ,
157156 }
158157 }
159- chatCol . updateOne ( query , update )
158+ await chatCol . updateOne ( query , update )
160159}
161160
162161export async function createUser ( email : string , password : string ) : Promise < UserInfo > {
@@ -170,15 +169,13 @@ export async function createUser(email: string, password: string): Promise<UserI
170169}
171170
172171export async function updateUserInfo ( userId : string , user : UserInfo ) {
173- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
172+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
174173 , { $set : { name : user . name , description : user . description , avatar : user . avatar } } )
175- return result
176174}
177175
178176export async function updateUserPassword ( userId : string , password : string ) {
179- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
177+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
180178 , { $set : { password, updateTime : new Date ( ) . toLocaleString ( ) } } )
181- return result
182179}
183180
184181export async function getUser ( email : string ) : Promise < UserInfo > {
0 commit comments