mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-24 03:14:08 +01:00
🔧 fix: Apply Mongoose Plugin at Model Creation (#7749)
* fix: apply mongoMeili when models are created to use main runtime mongoose * chore: update @librechat/data-schemas version to 0.0.8 * refactor: remove unused useDebounceCodeBlock * fix: ensure setter function is stable and handle numeric conversion in useDebouncedInput * refactor: replace useCallback with useMemo for stable debounced function in useDebouncedInput
This commit is contained in:
parent
be4cf5846c
commit
dff4fcac00
9 changed files with 40 additions and 73 deletions
|
|
@ -1,10 +1,21 @@
|
|||
import type * as t from '~/types';
|
||||
import mongoMeili from '~/models/plugins/mongoMeili';
|
||||
import convoSchema from '~/schema/convo';
|
||||
|
||||
/**
|
||||
* Creates or returns the Conversation model using the provided mongoose instance and schema
|
||||
*/
|
||||
export function createConversationModel(mongoose: typeof import('mongoose')) {
|
||||
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
||||
convoSchema.plugin(mongoMeili, {
|
||||
mongoose,
|
||||
host: process.env.MEILI_HOST,
|
||||
apiKey: process.env.MEILI_MASTER_KEY,
|
||||
/** Note: Will get created automatically if it doesn't exist already */
|
||||
indexName: 'convos',
|
||||
primaryKey: 'conversationId',
|
||||
});
|
||||
}
|
||||
return (
|
||||
mongoose.models.Conversation || mongoose.model<t.IConversation>('Conversation', convoSchema)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue