🛠️ fix: Update Conversation and Message Models to Return Objects Instead of Using Lean() (#3230)
This commit is contained in:
@@ -27,10 +27,12 @@ module.exports = {
|
||||
update.conversationId = newConversationId;
|
||||
}
|
||||
|
||||
return await Conversation.findOneAndUpdate({ conversationId: conversationId, user }, update, {
|
||||
const conversation = await Conversation.findOneAndUpdate({ conversationId, user }, update, {
|
||||
new: true,
|
||||
upsert: true,
|
||||
}).lean();
|
||||
});
|
||||
|
||||
return conversation.toObject();
|
||||
} catch (error) {
|
||||
logger.error('[saveConvo] Error saving conversation', error);
|
||||
return { message: 'Error saving conversation' };
|
||||
|
||||
@@ -58,10 +58,12 @@ module.exports = {
|
||||
update.files = files;
|
||||
}
|
||||
|
||||
return await Message.findOneAndUpdate({ messageId }, update, {
|
||||
const message = await Message.findOneAndUpdate({ messageId }, update, {
|
||||
upsert: true,
|
||||
new: true,
|
||||
}).lean();
|
||||
});
|
||||
|
||||
return message.toObject();
|
||||
} catch (err) {
|
||||
logger.error('Error saving message:', err);
|
||||
throw new Error('Failed to save message.');
|
||||
|
||||
Reference in New Issue
Block a user