mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🛠️ fix: Update Conversation and Message Models to Return Objects Instead of Using Lean() (#3230)
This commit is contained in:
parent
a2fd975cd5
commit
a87d4e0b75
2 changed files with 8 additions and 4 deletions
|
|
@ -27,10 +27,12 @@ module.exports = {
|
||||||
update.conversationId = newConversationId;
|
update.conversationId = newConversationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Conversation.findOneAndUpdate({ conversationId: conversationId, user }, update, {
|
const conversation = await Conversation.findOneAndUpdate({ conversationId, user }, update, {
|
||||||
new: true,
|
new: true,
|
||||||
upsert: true,
|
upsert: true,
|
||||||
}).lean();
|
});
|
||||||
|
|
||||||
|
return conversation.toObject();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[saveConvo] Error saving conversation', error);
|
logger.error('[saveConvo] Error saving conversation', error);
|
||||||
return { message: 'Error saving conversation' };
|
return { message: 'Error saving conversation' };
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,12 @@ module.exports = {
|
||||||
update.files = files;
|
update.files = files;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Message.findOneAndUpdate({ messageId }, update, {
|
const message = await Message.findOneAndUpdate({ messageId }, update, {
|
||||||
upsert: true,
|
upsert: true,
|
||||||
new: true,
|
new: true,
|
||||||
}).lean();
|
});
|
||||||
|
|
||||||
|
return message.toObject();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Error saving message:', err);
|
logger.error('Error saving message:', err);
|
||||||
throw new Error('Failed to save message.');
|
throw new Error('Failed to save message.');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue