mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +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
|
|
@ -55,7 +55,7 @@ configSchema.methods.incrementCount = function () {
|
|||
|
||||
// Static methods
|
||||
configSchema.statics.findByTag = async function (tag) {
|
||||
return await this.findOne({ tag });
|
||||
return await this.findOne({ tag }).lean();
|
||||
};
|
||||
|
||||
configSchema.statics.updateByTag = async function (tag, update) {
|
||||
|
|
@ -67,7 +67,7 @@ const Config = mongoose.models.Config || mongoose.model('Config', configSchema);
|
|||
module.exports = {
|
||||
getConfigs: async (filter) => {
|
||||
try {
|
||||
return await Config.find(filter).exec();
|
||||
return await Config.find(filter).lean();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return { config: 'Error getting configs' };
|
||||
|
|
@ -75,7 +75,7 @@ module.exports = {
|
|||
},
|
||||
deleteConfigs: async (filter) => {
|
||||
try {
|
||||
return await Config.deleteMany(filter).exec();
|
||||
return await Config.deleteMany(filter);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return { config: 'Error deleting configs' };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue