Fix index issue
This commit is contained in:
@@ -1,38 +1,62 @@
|
||||
import { Schema } from 'mongoose'
|
||||
import { regExpPattern } from 'regexp-pattern'
|
||||
import { Schema } from "mongoose"
|
||||
import { regExpPattern } from "regexp-pattern"
|
||||
|
||||
export let userSchema = new Schema({
|
||||
_id: { type: Schema.Types.ObjectId, required: true, auto: true },
|
||||
loginToken: { type: String, index: true, unique: true, sparse: true },
|
||||
passwordHash: {
|
||||
type: {
|
||||
hash: String,
|
||||
salt: String,
|
||||
keyLength: Number,
|
||||
hashMethod: String,
|
||||
iterations: Number
|
||||
}
|
||||
export let userSchema = new Schema(
|
||||
{
|
||||
_id: { type: Schema.Types.ObjectId, required: true, auto: true },
|
||||
loginToken: {
|
||||
type: String,
|
||||
index: true,
|
||||
unique: true,
|
||||
partialFilterExpression: { loginToken: { $type: "string" } },
|
||||
},
|
||||
passwordHash: {
|
||||
type: {
|
||||
hash: String,
|
||||
salt: String,
|
||||
keyLength: Number,
|
||||
hashMethod: String,
|
||||
iterations: Number,
|
||||
},
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
match: regExpPattern.email,
|
||||
required: true,
|
||||
index: true,
|
||||
unique: true,
|
||||
},
|
||||
newEmail: { type: String, match: regExpPattern.email },
|
||||
thumbnailImageId: { type: Schema.Types.ObjectId },
|
||||
emailToken: {
|
||||
type: {
|
||||
value: {
|
||||
type: String,
|
||||
index: true,
|
||||
unique: true,
|
||||
partialFilterExpression: { emailToken: { $type: "string" } },
|
||||
},
|
||||
created: Date,
|
||||
},
|
||||
},
|
||||
passwordToken: {
|
||||
type: {
|
||||
value: {
|
||||
type: String,
|
||||
index: true,
|
||||
unique: true,
|
||||
partialFilterExpression: { passwordToken: { $type: "string" } },
|
||||
},
|
||||
created: Date,
|
||||
},
|
||||
},
|
||||
firstName: { type: String, required: true },
|
||||
lastName: { type: String, required: true },
|
||||
administrator: { type: Boolean, required: true },
|
||||
team: Schema.Types.ObjectId,
|
||||
},
|
||||
email: { type: String, match: regExpPattern.email, required: true, index: true, unique: true },
|
||||
newEmail: { type: String, match: regExpPattern.email },
|
||||
thumbnailImageId: { type: Schema.Types.ObjectId },
|
||||
emailToken: {
|
||||
type: {
|
||||
value: { type: String, index: true, unique: true, sparse: true },
|
||||
created: Date
|
||||
}
|
||||
},
|
||||
passwordToken: {
|
||||
type: {
|
||||
value: { type: String, index: true, unique: true, sparse: true },
|
||||
created: Date
|
||||
}
|
||||
},
|
||||
firstName: { type: String, required: true },
|
||||
lastName: { type: String, required: true },
|
||||
administrator: { type: Boolean, required: true },
|
||||
team: Schema.Types.ObjectId,
|
||||
}, { timestamps: true, id: false })
|
||||
{ timestamps: true, id: false }
|
||||
)
|
||||
|
||||
userSchema.methods.toClient = function(authUser) {
|
||||
if (!authUser) {
|
||||
@@ -42,13 +66,13 @@ userSchema.methods.toClient = function(authUser) {
|
||||
let user = {
|
||||
_id: this._id,
|
||||
email: this.email,
|
||||
emailValidated: (!!this.emailToken !== true),
|
||||
emailValidated: !!this.emailToken !== true,
|
||||
imageId: this.imageId,
|
||||
thumbnailImageId: this.thumbnailImageId,
|
||||
firstName: this.firstName,
|
||||
lastName: this.lastName,
|
||||
administrator: this.administrator,
|
||||
team: this.team
|
||||
team: this.team,
|
||||
}
|
||||
|
||||
return user
|
||||
|
||||
Reference in New Issue
Block a user