Download packages/data-schemas/src/models/message.ts from helloya20/chat: direct link, hf CLI and curl.
- Browser
- Download file 670 Bytes
-
https://huggingface.co/spaces/helloya20/chat/resolve/main/packages/data-schemas/src/models/message.ts
- Command line
-
hf download hf://spaces/helloya20/chat/packages/data-schemas/src/models/message.ts
-
curl -L -o message.ts https://huggingface.co/spaces/helloya20/chat/resolve/main/packages/data-schemas/src/models/message.ts
670 Bytes
| import type * as t from '~/types'; | |
| import mongoMeili from '~/models/plugins/mongoMeili'; | |
| import messageSchema from '~/schema/message'; | |
| /** | |
| * Creates or returns the Message model using the provided mongoose instance and schema | |
| */ | |
| export function createMessageModel(mongoose: typeof import('mongoose')) { | |
| if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) { | |
| messageSchema.plugin(mongoMeili, { | |
| mongoose, | |
| host: process.env.MEILI_HOST, | |
| apiKey: process.env.MEILI_MASTER_KEY, | |
| indexName: 'messages', | |
| primaryKey: 'messageId', | |
| }); | |
| } | |
| return mongoose.models.Message || mongoose.model<t.IMessage>('Message', messageSchema); | |
| } | |