mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-23 10:46:12 +01:00
fix(data-schemas): use partial index for group idOnTheSource uniqueness
Replace sparse index with partial filter expression to allow multiple local groups while maintaining unique constraint for external source IDs. The sparse option on compound indexes doesn't work as expected when one field is always present.
This commit is contained in:
parent
eed43e6662
commit
0143ae5728
1 changed files with 7 additions and 2 deletions
|
|
@ -44,8 +44,13 @@ const groupSchema = new Schema<IGroup>(
|
|||
{ timestamps: true },
|
||||
);
|
||||
|
||||
// Create indexes for efficient lookups
|
||||
groupSchema.index({ idOnTheSource: 1, source: 1 }, { unique: true, sparse: true });
|
||||
groupSchema.index(
|
||||
{ idOnTheSource: 1, source: 1 },
|
||||
{
|
||||
unique: true,
|
||||
partialFilterExpression: { idOnTheSource: { $exists: true } },
|
||||
},
|
||||
);
|
||||
groupSchema.index({ memberIds: 1 });
|
||||
|
||||
export default groupSchema;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue