user-service
    Preparing search index...
    interface UserDocument {
        _id: string;
        $locals: Record<string, unknown>;
        $op: "save" | "validate" | "remove" | null;
        $where: Record<string, unknown>;
        baseModelName?: string;
        collection: Collection;
        createdAt: Date;
        db: Connection;
        errors?: ValidationError;
        isNew: boolean;
        password: string;
        role: UserRole;
        schema: Schema;
        updatedAt: Date;
        username: string;
        $assertPopulated<Paths = {}>(
            path: string | string[],
            values?: Partial<Paths>,
        ): Omit<UserDocument, keyof Paths> & Paths;
        $clearModifiedPaths(): this;
        $clone(): this;
        $createModifiedPathsSnapshot(): ModifiedPathsSnapshot;
        $getAllSubdocs(): Document<ObjectId, any, any, Record<string, any>, {}>[];
        $getPopulatedDocs(): Document<ObjectId, any, any, Record<string, any>, {}>[];
        $ignore(path: string): void;
        $inc(path: string | string[], val?: number): this;
        $isDefault(path?: string): boolean;
        $isDeleted(val?: boolean): boolean;
        $isEmpty(path: string): boolean;
        $isValid(path: string): boolean;
        $markValid(path: string): void;
        $model<
            ModelType extends
                Model<
                    unknown,
                    {},
                    {},
                    {},
                    Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                        _id: ObjectId;
                    } & { __v: number } & { id: string },
                    any,
                    unknown,
                >,
        >(
            name: string,
        ): ModelType;
        $model<ModelType extends Model<any, {}, {}, {}, any, any, any>>(): ModelType;
        $parent(): | Document<ObjectId, any, any, Record<string, any>, {}>
        | undefined;
        $restoreModifiedPathsSnapshot(snapshot: ModifiedPathsSnapshot): this;
        $session(session?: ClientSession | null): ClientSession | null;
        $set(
            path: string | Record<string, any>,
            val: any,
            type: any,
            options?: DocumentSetOptions,
        ): this;
        $set(
            path: string | Record<string, any>,
            val: any,
            options?: DocumentSetOptions,
        ): this;
        $set(value: string | Record<string, any>): this;
        deleteOne(options?: QueryOptions<unknown>): any;
        depopulate<Paths = {}>(
            path?: string | string[],
        ): MergeType<UserDocument, Paths>;
        directModifiedPaths(): string[];
        equals(doc: Document<string>): boolean;
        get<T extends string | number | symbol>(
            path: T,
            type?: any,
            options?: any,
        ): any;
        get(path: string, type?: any, options?: any): any;
        getChanges(): UpdateQuery<UserDocument>;
        increment(): this;
        init(obj: AnyObject, opts?: AnyObject): this;
        invalidate<T extends string | number | symbol>(
            path: T,
            errorMsg: string | NativeError,
            value?: any,
            kind?: string,
        ): NativeError | null;
        invalidate(
            path: string,
            errorMsg: string | NativeError,
            value?: any,
            kind?: string,
        ): NativeError | null;
        isDirectModified<T extends string | number | symbol>(
            path: T | T[],
        ): boolean;
        isDirectModified(path: string | string[]): boolean;
        isDirectSelected<T extends string | number | symbol>(path: T): boolean;
        isDirectSelected(path: string): boolean;
        isInit<T extends string | number | symbol>(path: T): boolean;
        isInit(path: string): boolean;
        isModified<T extends string | number | symbol>(
            path?: T | T[],
            options?: { ignoreAtomics?: boolean } | null,
        ): boolean;
        isModified(
            path?: string | string[],
            options?: { ignoreAtomics?: boolean } | null,
        ): boolean;
        isSelected<T extends string | number | symbol>(path: T): boolean;
        isSelected(path: string): boolean;
        markModified<T extends string | number | symbol>(
            path: T,
            scope?: any,
        ): void;
        markModified(path: string, scope?: any): void;
        model<
            ModelType extends
                Model<
                    unknown,
                    {},
                    {},
                    {},
                    Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                        _id: ObjectId;
                    } & { __v: number } & { id: string },
                    any,
                    unknown,
                >,
        >(
            name: string,
        ): ModelType;
        model<ModelType extends Model<any, {}, {}, {}, any, any, any>>(): ModelType;
        modifiedPaths(options?: { includeChildren?: boolean }): string[];
        overwrite(obj: AnyObject): this;
        populate<Paths = {}>(
            path: string | PopulateOptions | (string | PopulateOptions)[],
        ): Promise<MergeType<UserDocument, Paths>>;
        populate<Paths = {}>(
            path: string,
            select?: string | AnyObject,
            model?: Model<any, {}, {}, {}, any, any, any>,
            match?: AnyObject,
            options?: PopulateOptions,
        ): Promise<MergeType<UserDocument, Paths>>;
        populated(path: string): any;
        replaceOne(
            replacement?: AnyObject,
            options?: QueryOptions<unknown> | null,
        ): Query<any, UserDocument>;
        save(options?: SaveOptions): Promise<UserDocument>;
        set<T extends string | number | symbol>(
            path: T,
            val: any,
            type: any,
            options?: DocumentSetOptions,
        ): this;
        set(
            path: string | Record<string, any>,
            val: any,
            type: any,
            options?: DocumentSetOptions,
        ): this;
        set(
            path: string | Record<string, any>,
            val: any,
            options?: DocumentSetOptions,
        ): this;
        set(value: string | Record<string, any>): this;
        toBSON(): any;
        toJSON<
            O extends
                ToObjectOptions<
                    unknown,
                    Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                        _id: ObjectId;
                    } & { __v: number } & { id: string },
                >,
        >(
            options: O,
        ): ApplyVersionKey<
            ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> extends {
                __v?: U;
            }
                ? { __v?: U } & ApplyFlattenTransforms<
                    ApplyVirtuals<any, Record<string, any>, O>,
                    O,
                >
                : ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> & {
                    __v: number;
                },
            O,
            {},
        >;
        toJSON(
            options?: ToObjectOptions<
                unknown,
                Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                    _id: ObjectId;
                } & { __v: number } & { id: string },
            >,
        ): any;
        toJSON<T>(
            options?: ToObjectOptions<
                unknown,
                Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                    _id: ObjectId;
                } & { __v: number } & { id: string },
            >,
        ): Require_id<T> & { __v: number };
        toObject<
            O extends
                ToObjectOptions<
                    unknown,
                    Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                        _id: ObjectId;
                    } & { __v: number } & { id: string },
                >,
        >(
            options: O,
        ): ApplyVersionKey<
            ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> extends {
                __v?: U;
            }
                ? { __v?: U } & ApplyFlattenTransforms<
                    ApplyVirtuals<any, Record<string, any>, O>,
                    O,
                >
                : ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> & {
                    __v: number;
                },
            O,
            {},
        >;
        toObject(
            options?: ToObjectOptions<
                unknown,
                Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                    _id: ObjectId;
                } & { __v: number } & { id: string },
            >,
        ): any;
        toObject<T>(
            options?: ToObjectOptions<
                unknown,
                Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                    _id: ObjectId;
                } & { __v: number } & { id: string },
            >,
        ): Require_id<T> & { __v: number };
        unmarkModified<T extends string | number | symbol>(path: T): void;
        unmarkModified(path: string): void;
        updateOne(
            update?: UpdateWithAggregationPipeline | UpdateQuery<UserDocument>,
            options?: QueryOptions<unknown> | null,
        ): Query<any, UserDocument>;
        validate<T extends string | number | symbol>(
            pathsToValidate?: T | T[],
            options?: Omit<ValidateOptions, "pathsToSkip"> & AnyObject,
        ): Promise<void>;
        validate(
            pathsToValidate?: PathsToValidate,
            options?: Omit<ValidateOptions, "pathsToSkip"> & AnyObject,
        ): Promise<void>;
        validate(options: ValidateOptions): Promise<void>;
        validateSync(
            options: ValidateOptions & { [k: string]: any },
        ): ValidationError | null;
        validateSync<T extends string | number | symbol>(
            pathsToValidate?: T | T[],
            options?: Omit<ValidateOptions, "pathsToSkip"> & AnyObject,
        ): ValidationError | null;
        validateSync(
            pathsToValidate?: PathsToValidate,
            options?: Omit<ValidateOptions, "pathsToSkip"> & AnyObject,
        ): ValidationError | null;
    }

    Hierarchy

    • Document<string>
      • UserDocument
    Index

    Properties

    _id: string

    This documents _id.

    $locals: Record<string, unknown>

    Empty object that you can use for storing properties on the document. This is handy for passing data to middleware without conflicting with Mongoose internals.

    $op: "save" | "validate" | "remove" | null

    A string containing the current operation that Mongoose is executing on this document. Can be null, 'save', 'validate', or 'remove'.

    $where: Record<string, unknown>

    Set this property to add additional query filters when Mongoose saves this document and isNew is false.

    baseModelName?: string

    If this is a discriminator model, baseModelName is the name of the base model.

    collection: Collection

    Collection the model uses.

    createdAt: Date
    db: Connection

    Connection the model uses.

    errors?: ValidationError

    Returns the current validation errors.

    isNew: boolean

    Boolean flag specifying if the document is new.

    password: string
    role: UserRole
    schema: Schema

    The document's schema.

    updatedAt: Date
    username: string

    Methods

    • Assert that a given path or paths is populated. Throws an error if not populated.

      Type Parameters

      • Paths = {}

      Parameters

      • path: string | string[]
      • Optionalvalues: Partial<Paths>

      Returns Omit<UserDocument, keyof Paths> & Paths

    • Clear the document's modified paths.

      Returns this

    • Returns a deep clone of this document

      Returns this

    • Creates a snapshot of this document's internal change tracking state. You can later reset this document's change tracking state using $restoreModifiedPathsSnapshot().

      Returns ModifiedPathsSnapshot

    • Returns Document<ObjectId, any, any, Record<string, any>, {}>[]

    • Returns an array of all populated documents associated with the query

      Returns Document<ObjectId, any, any, Record<string, any>, {}>[]

    • Don't run validation on this path or persist changes to this path.

      Parameters

      • path: string

      Returns void

    • Increments the numeric value at path by the given val. When you call save() on this document, Mongoose will send a $inc as opposed to a $set.

      Parameters

      • path: string | string[]
      • Optionalval: number

      Returns this

    • Checks if a path is set to its default. If no path set, checks if any path is set to its default.

      Parameters

      • Optionalpath: string

      Returns boolean

    • Getter/setter, determines whether the document was removed or not.

      Parameters

      • Optionalval: boolean

      Returns boolean

    • Returns true if the given path is nullish or only contains empty objects. Useful for determining whether this subdoc will get stripped out by the minimize option.

      Parameters

      • path: string

      Returns boolean

    • Checks if a path is invalid

      Parameters

      • path: string

      Returns boolean

    • Marks a path as valid, removing existing validation errors.

      Parameters

      • path: string

      Returns void

    • Returns the model with the given name on this document's associated connection.

      Type Parameters

      • ModelType extends Model<
            unknown,
            {},
            {},
            {},
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
            any,
            unknown,
        >

      Parameters

      • name: string

      Returns ModelType

    • Returns the model with the given name on this document's associated connection.

      Type Parameters

      • ModelType extends Model<any, {}, {}, {}, any, any, any>

      Returns ModelType

    • If this document is a subdocument or populated document, returns the document's parent. Returns undefined otherwise.

      Returns Document<ObjectId, any, any, Record<string, any>, {}> | undefined

    • Restore this document's change tracking state to the given snapshot. Note that $restoreModifiedPathsSnapshot() does not modify the document's properties, just resets the change tracking state.

      Parameters

      • snapshot: ModifiedPathsSnapshot

      Returns this

    • Getter/setter around the session associated with this document. Used to automatically set session if you save() a doc that you got from a query with an associated session.

      Parameters

      • Optionalsession: ClientSession | null

      Returns ClientSession | null

    • Alias for set(), used internally to avoid conflicts

      Parameters

      • path: string | Record<string, any>
      • val: any
      • type: any
      • Optionaloptions: DocumentSetOptions

      Returns this

    • Alias for set(), used internally to avoid conflicts

      Parameters

      • path: string | Record<string, any>
      • val: any
      • Optionaloptions: DocumentSetOptions

      Returns this

    • Alias for set(), used internally to avoid conflicts

      Parameters

      • value: string | Record<string, any>

      Returns this

    • Removes this document from the db.

      Parameters

      • Optionaloptions: QueryOptions<unknown>

      Returns any

    • Takes a populated field and returns it to its unpopulated state. If called with no arguments, then all populated fields are returned to their unpopulated state.

      Type Parameters

      • Paths = {}

      Parameters

      • Optionalpath: string | string[]

      Returns MergeType<UserDocument, Paths>

    • Returns the list of paths that have been directly modified. A direct modified path is a path that you explicitly set, whether via doc.foo = 'bar', Object.assign(doc, { foo: 'bar' }), or doc.set('foo', 'bar').

      Returns string[]

    • Returns true if this document is equal to another document.

      Documents are considered equal when they have matching _ids, unless neither document has an _id, in which case this function falls back to using deepEqual().

      Parameters

      • doc: Document<string>

      Returns boolean

    • Returns the value of a path.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T
      • Optionaltype: any
      • Optionaloptions: any

      Returns any

    • Returns the value of a path.

      Parameters

      • path: string
      • Optionaltype: any
      • Optionaloptions: any

      Returns any

    • Returns the changes that happened to the document in the format that will be sent to MongoDB.

      Returns UpdateQuery<UserDocument>

    • Signal that we desire an increment of this documents version.

      Returns this

    • Initializes the document without setters or marking anything modified. Called internally after a document is returned from mongodb. Normally, you do not need to call this function on your own.

      Parameters

      • obj: AnyObject
      • Optionalopts: AnyObject

      Returns this

    • Marks a path as invalid, causing validation to fail.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T
      • errorMsg: string | NativeError
      • Optionalvalue: any
      • Optionalkind: string

      Returns NativeError | null

    • Marks a path as invalid, causing validation to fail.

      Parameters

      • path: string
      • errorMsg: string | NativeError
      • Optionalvalue: any
      • Optionalkind: string

      Returns NativeError | null

    • Returns true if path was directly set and modified, else false.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T | T[]

      Returns boolean

    • Returns true if path was directly set and modified, else false.

      Parameters

      • path: string | string[]

      Returns boolean

    • Checks if path was explicitly selected. If no projection, always returns true.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T

      Returns boolean

    • Checks if path was explicitly selected. If no projection, always returns true.

      Parameters

      • path: string

      Returns boolean

    • Checks if path is in the init state, that is, it was set by Document#init() and not modified since.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T

      Returns boolean

    • Checks if path is in the init state, that is, it was set by Document#init() and not modified since.

      Parameters

      • path: string

      Returns boolean

    • Returns true if any of the given paths are modified, else false. If no arguments, returns true if any path in this document is modified.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • Optionalpath: T | T[]
      • Optionaloptions: { ignoreAtomics?: boolean } | null

      Returns boolean

    • Returns true if any of the given paths are modified, else false. If no arguments, returns true if any path in this document is modified.

      Parameters

      • Optionalpath: string | string[]
      • Optionaloptions: { ignoreAtomics?: boolean } | null

      Returns boolean

    • Checks if path was selected in the source query which initialized this document.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T

      Returns boolean

    • Checks if path was selected in the source query which initialized this document.

      Parameters

      • path: string

      Returns boolean

    • Marks the path as having pending changes to write to the db.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T
      • Optionalscope: any

      Returns void

    • Marks the path as having pending changes to write to the db.

      Parameters

      • path: string
      • Optionalscope: any

      Returns void

    • Returns the model with the given name on this document's associated connection.

      Type Parameters

      • ModelType extends Model<
            unknown,
            {},
            {},
            {},
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
            any,
            unknown,
        >

      Parameters

      • name: string

      Returns ModelType

    • Returns the model with the given name on this document's associated connection.

      Type Parameters

      • ModelType extends Model<any, {}, {}, {}, any, any, any>

      Returns ModelType

    • Returns the list of paths that have been modified.

      Parameters

      • Optionaloptions: { includeChildren?: boolean }

      Returns string[]

    • Overwrite all values in this document with the values of obj, except for immutable properties. Behaves similarly to set(), except for it unsets all properties that aren't in obj.

      Parameters

      • obj: AnyObject

      Returns this

    • Populates document references.

      Type Parameters

      • Paths = {}

      Parameters

      • path: string | PopulateOptions | (string | PopulateOptions)[]

      Returns Promise<MergeType<UserDocument, Paths>>

    • Populates document references.

      Type Parameters

      • Paths = {}

      Parameters

      • path: string
      • Optionalselect: string | AnyObject
      • Optionalmodel: Model<any, {}, {}, {}, any, any, any>
      • Optionalmatch: AnyObject
      • Optionaloptions: PopulateOptions

      Returns Promise<MergeType<UserDocument, Paths>>

    • Gets _id(s) used during population of the given path. If the path was not populated, returns undefined.

      Parameters

      • path: string

      Returns any

    • Sends a replaceOne command with this document _id as the query selector.

      Parameters

      • Optionalreplacement: AnyObject
      • Optionaloptions: QueryOptions<unknown> | null

      Returns Query<any, UserDocument>

    • Saves this document by inserting a new document into the database if document.isNew is true, or sends an updateOne operation with just the modified paths if isNew is false.

      Parameters

      • Optionaloptions: SaveOptions

      Returns Promise<UserDocument>

    • Sets the value of a path, or many paths.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T
      • val: any
      • type: any
      • Optionaloptions: DocumentSetOptions

      Returns this

    • Sets the value of a path, or many paths.

      Parameters

      • path: string | Record<string, any>
      • val: any
      • type: any
      • Optionaloptions: DocumentSetOptions

      Returns this

    • Sets the value of a path, or many paths.

      Parameters

      • path: string | Record<string, any>
      • val: any
      • Optionaloptions: DocumentSetOptions

      Returns this

    • Sets the value of a path, or many paths.

      Parameters

      • value: string | Record<string, any>

      Returns this

    • Returns any

    • The return value of this method is used in calls to JSON.stringify(doc).

      Type Parameters

      • O extends ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Parameters

      • options: O

      Returns ApplyVersionKey<
          ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> extends {
              __v?: U;
          }
              ? { __v?: U } & ApplyFlattenTransforms<
                  ApplyVirtuals<any, Record<string, any>, O>,
                  O,
              >
              : ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> & {
                  __v: number;
              },
          O,
          {},
      >

    • The return value of this method is used in calls to JSON.stringify(doc).

      Parameters

      • Optionaloptions: ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Returns any

    • The return value of this method is used in calls to JSON.stringify(doc).

      Type Parameters

      • T

      Parameters

      • Optionaloptions: ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Returns Require_id<T> & { __v: number }

    • Converts this document into a plain-old JavaScript object (POJO).

      Type Parameters

      • O extends ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Parameters

      • options: O

      Returns ApplyVersionKey<
          ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> extends {
              __v?: U;
          }
              ? { __v?: U } & ApplyFlattenTransforms<
                  ApplyVirtuals<any, Record<string, any>, O>,
                  O,
              >
              : ApplyFlattenTransforms<ApplyVirtuals<any, Record<string, any>, O>, O> & {
                  __v: number;
              },
          O,
          {},
      >

    • Converts this document into a plain-old JavaScript object (POJO).

      Parameters

      • Optionaloptions: ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Returns any

    • Converts this document into a plain-old JavaScript object (POJO).

      Type Parameters

      • T

      Parameters

      • Optionaloptions: ToObjectOptions<
            unknown,
            Document<unknown, {}, unknown, {}, DefaultSchemaOptions> & {
                _id: ObjectId;
            } & { __v: number } & { id: string },
        >

      Returns Require_id<T> & { __v: number }

    • Clears the modified state on the specified path.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • path: T

      Returns void

    • Clears the modified state on the specified path.

      Parameters

      • path: string

      Returns void

    • Sends an updateOne command with this document _id as the query selector.

      Parameters

      • Optionalupdate: UpdateWithAggregationPipeline | UpdateQuery<UserDocument>
      • Optionaloptions: QueryOptions<unknown> | null

      Returns Query<any, UserDocument>

    • Executes registered validation rules for this document.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • OptionalpathsToValidate: T | T[]
      • Optionaloptions: Omit<ValidateOptions, "pathsToSkip"> & AnyObject

      Returns Promise<void>

    • Executes registered validation rules for this document.

      Parameters

      • OptionalpathsToValidate: PathsToValidate
      • Optionaloptions: Omit<ValidateOptions, "pathsToSkip"> & AnyObject

      Returns Promise<void>

    • Executes registered validation rules for this document.

      Parameters

      • options: ValidateOptions

      Returns Promise<void>

    • Executes registered validation rules (skipping asynchronous validators) for this document.

      Parameters

      • options: ValidateOptions & { [k: string]: any }

      Returns ValidationError | null

    • Executes registered validation rules (skipping asynchronous validators) for this document.

      Type Parameters

      • T extends string | number | symbol

      Parameters

      • OptionalpathsToValidate: T | T[]
      • Optionaloptions: Omit<ValidateOptions, "pathsToSkip"> & AnyObject

      Returns ValidationError | null

    • Executes registered validation rules (skipping asynchronous validators) for this document.

      Parameters

      • OptionalpathsToValidate: PathsToValidate
      • Optionaloptions: Omit<ValidateOptions, "pathsToSkip"> & AnyObject

      Returns ValidationError | null