mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-01 07:11:50 +01:00
feat: utitlize lean queries, remove migration script, index createdAt timestamps (#698)
* feat(mongoDb): utitlize lean queries and index createdAt timestamps for cosmosDB support * fix: remove unnecessary lean() method from deleteMany calls * fix: remove unnecessary lean() method from deleteMany calls * fix: remove lean() from queries that need hydration * chore(migrateDb.js): remove unused migration script fix(Preset.js): return lean documents when retrieving presets refactor(index.js): remove migration script from server initialization refactor(convos.js): remove toObject() when sending conversation object refactor(presets.js): remove toObject() when sending presets object
This commit is contained in:
parent
2f7658e39f
commit
19af2b06ce
13 changed files with 34 additions and 160 deletions
|
|
@ -3,7 +3,7 @@ const { encrypt, decrypt } = require('../../utils/');
|
|||
|
||||
const getUserPluginAuthValue = async (user, authField) => {
|
||||
try {
|
||||
const pluginAuth = await PluginAuth.findOne({ user, authField });
|
||||
const pluginAuth = await PluginAuth.findOne({ user, authField }).lean();
|
||||
if (!pluginAuth) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ const getUserPluginAuthValue = async (user, authField) => {
|
|||
const updateUserPluginAuth = async (userId, authField, pluginKey, value) => {
|
||||
try {
|
||||
const encryptedValue = encrypt(value);
|
||||
const pluginAuth = await PluginAuth.findOne({ userId, authField });
|
||||
const pluginAuth = await PluginAuth.findOne({ userId, authField }).lean();
|
||||
if (pluginAuth) {
|
||||
const pluginAuth = await PluginAuth.updateOne(
|
||||
{ userId, authField },
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ const registerUser = async (user) => {
|
|||
const { email, password, name, username } = user;
|
||||
|
||||
try {
|
||||
const existingUser = await User.findOne({ email });
|
||||
const existingUser = await User.findOne({ email }).lean();
|
||||
|
||||
if (existingUser) {
|
||||
console.info(
|
||||
|
|
@ -104,7 +104,7 @@ const registerUser = async (user) => {
|
|||
* @returns
|
||||
*/
|
||||
const requestPasswordReset = async (email) => {
|
||||
const user = await User.findOne({ email });
|
||||
const user = await User.findOne({ email }).lean();
|
||||
if (!user) {
|
||||
return new Error('Email does not exist');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue