mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
feat(data-schemas): add new Mongoose models for conversationTag, key, pluginAuth, preset, project, prompt, promptGroup, sharedLink, toolCall, and transaction
- Introduced new model files for conversationTag, key, pluginAuth, preset, project, prompt, promptGroup, sharedLink, toolCall, and transaction. - Each model includes a function to create or return the respective Mongoose model using the provided instance and schema. - Updated the centralized models index to include these new models for better organization and accessibility.
This commit is contained in:
parent
20ad7d52f3
commit
90ac2b51cd
11 changed files with 108 additions and 0 deletions
11
packages/data-schemas/src/models/conversationTag.ts
Normal file
11
packages/data-schemas/src/models/conversationTag.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import conversationTagSchema, { IConversationTag } from '~/schema/conversationTag';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the ConversationTag model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createConversationTagModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return (
|
||||||
|
mongoose.models.ConversationTag ||
|
||||||
|
mongoose.model<IConversationTag>('ConversationTag', conversationTagSchema)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,16 @@ import { createActionModel } from './action';
|
||||||
import { createAssistantModel } from './assistant';
|
import { createAssistantModel } from './assistant';
|
||||||
import { createFileModel } from './file';
|
import { createFileModel } from './file';
|
||||||
import { createBannerModel } from './banner';
|
import { createBannerModel } from './banner';
|
||||||
|
import { createProjectModel } from './project';
|
||||||
|
import { createKeyModel } from './key';
|
||||||
|
import { createPluginAuthModel } from './pluginAuth';
|
||||||
|
import { createTransactionModel } from './transaction';
|
||||||
|
import { createPresetModel } from './preset';
|
||||||
|
import { createPromptModel } from './prompt';
|
||||||
|
import { createPromptGroupModel } from './promptGroup';
|
||||||
|
import { createConversationTagModel } from './conversationTag';
|
||||||
|
import { createSharedLinkModel } from './sharedLink';
|
||||||
|
import { createToolCallModel } from './toolCall';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates all database models for all collections
|
* Creates all database models for all collections
|
||||||
|
|
@ -28,5 +38,15 @@ export function createModels(mongoose: typeof import('mongoose')) {
|
||||||
Assistant: createAssistantModel(mongoose),
|
Assistant: createAssistantModel(mongoose),
|
||||||
File: createFileModel(mongoose),
|
File: createFileModel(mongoose),
|
||||||
Banner: createBannerModel(mongoose),
|
Banner: createBannerModel(mongoose),
|
||||||
|
Project: createProjectModel(mongoose),
|
||||||
|
Key: createKeyModel(mongoose),
|
||||||
|
PluginAuth: createPluginAuthModel(mongoose),
|
||||||
|
Transaction: createTransactionModel(mongoose),
|
||||||
|
Preset: createPresetModel(mongoose),
|
||||||
|
Prompt: createPromptModel(mongoose),
|
||||||
|
PromptGroup: createPromptGroupModel(mongoose),
|
||||||
|
ConversationTag: createConversationTagModel(mongoose),
|
||||||
|
SharedLink: createSharedLinkModel(mongoose),
|
||||||
|
ToolCall: createToolCallModel(mongoose),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
packages/data-schemas/src/models/key.ts
Normal file
8
packages/data-schemas/src/models/key.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import keySchema, { IKey } from '~/schema/key';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the Key model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createKeyModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.Key || mongoose.model<IKey>('Key', keySchema);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/pluginAuth.ts
Normal file
8
packages/data-schemas/src/models/pluginAuth.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import pluginAuthSchema, { IPluginAuth } from '~/schema/pluginAuth';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the PluginAuth model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createPluginAuthModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.PluginAuth || mongoose.model<IPluginAuth>('PluginAuth', pluginAuthSchema);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/preset.ts
Normal file
8
packages/data-schemas/src/models/preset.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import presetSchema, { IPreset } from '~/schema/preset';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the Preset model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createPresetModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.Preset || mongoose.model<IPreset>('Preset', presetSchema);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/project.ts
Normal file
8
packages/data-schemas/src/models/project.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import projectSchema, { IMongoProject } from '~/schema/project';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the Project model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createProjectModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.Project || mongoose.model<IMongoProject>('Project', projectSchema);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/prompt.ts
Normal file
8
packages/data-schemas/src/models/prompt.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import promptSchema, { IPrompt } from '~/schema/prompt';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the Prompt model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createPromptModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.Prompt || mongoose.model<IPrompt>('Prompt', promptSchema);
|
||||||
|
}
|
||||||
11
packages/data-schemas/src/models/promptGroup.ts
Normal file
11
packages/data-schemas/src/models/promptGroup.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import promptGroupSchema, { IPromptGroupDocument } from '~/schema/promptGroup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the PromptGroup model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createPromptGroupModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return (
|
||||||
|
mongoose.models.PromptGroup ||
|
||||||
|
mongoose.model<IPromptGroupDocument>('PromptGroup', promptGroupSchema)
|
||||||
|
);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/sharedLink.ts
Normal file
8
packages/data-schemas/src/models/sharedLink.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import shareSchema, { ISharedLink } from '~/schema/share';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the SharedLink model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createSharedLinkModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.SharedLink || mongoose.model<ISharedLink>('SharedLink', shareSchema);
|
||||||
|
}
|
||||||
8
packages/data-schemas/src/models/toolCall.ts
Normal file
8
packages/data-schemas/src/models/toolCall.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import toolCallSchema, { IToolCallData } from '~/schema/toolCall';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the ToolCall model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createToolCallModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return mongoose.models.ToolCall || mongoose.model<IToolCallData>('ToolCall', toolCallSchema);
|
||||||
|
}
|
||||||
10
packages/data-schemas/src/models/transaction.ts
Normal file
10
packages/data-schemas/src/models/transaction.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import transactionSchema, { ITransaction } from '~/schema/transaction';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or returns the Transaction model using the provided mongoose instance and schema
|
||||||
|
*/
|
||||||
|
export function createTransactionModel(mongoose: typeof import('mongoose')) {
|
||||||
|
return (
|
||||||
|
mongoose.models.Transaction || mongoose.model<ITransaction>('Transaction', transactionSchema)
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue