mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
feat: syncs across document deletions
This commit is contained in:
parent
1dbfb0dab7
commit
97634865eb
4 changed files with 31 additions and 18 deletions
|
|
@ -1,3 +1,4 @@
|
|||
const mongoose = require('mongoose');
|
||||
const { MeiliSearch } = require('meilisearch');
|
||||
const { cleanUpPrimaryKeyValue } = require('../../lib/utils/misc');
|
||||
const _ = require('lodash');
|
||||
|
|
@ -192,6 +193,18 @@ module.exports = function mongoMeili(schema, options) {
|
|||
schema.post('remove', function (doc) {
|
||||
doc.postRemoveHook();
|
||||
});
|
||||
schema.post('deleteMany', function (doc) {
|
||||
// console.log('deleteMany hook', doc);
|
||||
if (Object.prototype.hasOwnProperty.call(schema.obj, 'messages')) {
|
||||
console.log('Syncing convos...');
|
||||
mongoose.model('Conversation').syncWithMeili();
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(schema.obj, 'messageId')) {
|
||||
console.log('Syncing messages...');
|
||||
mongoose.model('Message').syncWithMeili();
|
||||
}
|
||||
});
|
||||
schema.post('findOneAndUpdate', function (doc) {
|
||||
doc.postSaveHook();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue