@@ -54,7 +54,7 @@ export async function updateChat(chatId: string, response: string, messageId: st
5454 await chatCol . updateOne ( query , update )
5555}
5656
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 ) {
5858 const chatUsage = new ChatUsage ( userId , roomId , chatId , messageId , usage )
5959 await usageCol . insertOne ( chatUsage )
6060 return chatUsage
@@ -72,8 +72,7 @@ export async function renameChatRoom(userId: string, title: string, roomId: numb
7272 title,
7373 } ,
7474 }
75- const result = await roomCol . updateOne ( query , update )
76- return result
75+ return await roomCol . updateOne ( query , update )
7776}
7877
7978export async function deleteChatRoom ( userId : string , roomId : number ) {
@@ -161,7 +160,7 @@ export async function deleteChat(roomId: number, uuid: number, inversion: boolea
161160 } ,
162161 }
163162 }
164- chatCol . updateOne ( query , update )
163+ await chatCol . updateOne ( query , update )
165164}
166165
167166export async function createUser ( email : string , password : string ) : Promise < UserInfo > {
@@ -175,15 +174,13 @@ export async function createUser(email: string, password: string): Promise<UserI
175174}
176175
177176export async function updateUserInfo ( userId : string , user : UserInfo ) {
178- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
177+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
179178 , { $set : { name : user . name , description : user . description , avatar : user . avatar } } )
180- return result
181179}
182180
183181export async function updateUserPassword ( userId : string , password : string ) {
184- const result = userCol . updateOne ( { _id : new ObjectId ( userId ) }
182+ return userCol . updateOne ( { _id : new ObjectId ( userId ) }
185183 , { $set : { password, updateTime : new Date ( ) . toLocaleString ( ) } } )
186- return result
187184}
188185
189186export async function getUser ( email : string ) : Promise < UserInfo > {
0 commit comments