mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
refactor(userSchema): unique index definitions using partialFilterExpression instead of sparse
This commit is contained in:
parent
18edd2660b
commit
a1c7110a94
1 changed files with 21 additions and 10 deletions
|
|
@ -51,28 +51,18 @@ const userSchema = mongoose.Schema(
|
||||||
},
|
},
|
||||||
googleId: {
|
googleId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
|
||||||
sparse: true,
|
|
||||||
},
|
},
|
||||||
facebookId: {
|
facebookId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
|
||||||
sparse: true,
|
|
||||||
},
|
},
|
||||||
openidId: {
|
openidId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
|
||||||
sparse: true,
|
|
||||||
},
|
},
|
||||||
githubId: {
|
githubId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
|
||||||
sparse: true,
|
|
||||||
},
|
},
|
||||||
discordId: {
|
discordId: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
|
||||||
sparse: true,
|
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
@ -85,4 +75,25 @@ const userSchema = mongoose.Schema(
|
||||||
{ timestamps: true },
|
{ timestamps: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
userSchema.index(
|
||||||
|
{ googleId: 1 },
|
||||||
|
{ unique: true, partialFilterExpression: { googleId: { $type: 'string' } } },
|
||||||
|
);
|
||||||
|
userSchema.index(
|
||||||
|
{ facebookId: 1 },
|
||||||
|
{ unique: true, partialFilterExpression: { facebookId: { $type: 'string' } } },
|
||||||
|
);
|
||||||
|
userSchema.index(
|
||||||
|
{ openidId: 1 },
|
||||||
|
{ unique: true, partialFilterExpression: { openidId: { $type: 'string' } } },
|
||||||
|
);
|
||||||
|
userSchema.index(
|
||||||
|
{ githubId: 1 },
|
||||||
|
{ unique: true, partialFilterExpression: { githubId: { $type: 'string' } } },
|
||||||
|
);
|
||||||
|
userSchema.index(
|
||||||
|
{ discordId: 1 },
|
||||||
|
{ unique: true, partialFilterExpression: { discordId: { $type: 'string' } } },
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = userSchema;
|
module.exports = userSchema;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue