🔧 refactor: Update Group Schema to use TypeScript and import from data-schemas

This commit is contained in:
Ruben Talstra 2025-03-10 15:19:52 +01:00
parent 2fd04b6d65
commit 4448c13684
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
4 changed files with 47 additions and 43 deletions

View file

@ -1,5 +1,5 @@
const mongoose = require('mongoose');
const groupSchema = require('~/models/schema/groupSchema');
const { groupSchema } = require('@librechat/data-schemas');
const Group = mongoose.model('Group', groupSchema);

View file

@ -1,41 +0,0 @@
const mongoose = require('mongoose');
/**
* @typedef {Object} MongoGroup
* @property {ObjectId} [_id] - MongoDB Document ID
* @property {string} name - The group's name
* @property {string} [description] - A brief description of the group
* @property {string} [externalId] - External identifier for the group (required for non-local groups)
* @property {string} provider - The provider of the group. Defaults to 'local'. For external groups (e.g., 'openid') the externalId is required.
* @property {Date} [createdAt] - Date when the group was created (added by timestamps)
* @property {Date} [updatedAt] - Date when the group was last updated (added by timestamps)
*/
const groupSchema = mongoose.Schema(
{
name: {
type: String,
required: true,
unique: true,
},
description: {
type: String,
},
externalId: {
type: String,
unique: true,
required: function () {
return this.provider !== 'local';
},
},
provider: {
type: String,
required: true,
default: 'local',
enum: ['local', 'openid'],
},
},
{ timestamps: true },
);
module.exports = groupSchema;