Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IORUnitSchema

Hierarchy

  • Document
    • IORUnitSchema

Index

Properties

$locals

$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

$op: string

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

$where

$where: Record<string, unknown>

Additional properties to attach to the query when calling save() and isNew is false.

Optional __v

__v: any

This documents __v.

Optional _id

_id: any

This documents _id.

Optional baseModelName

baseModelName: string

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

collection

collection: Collection

Collection the model uses.

db

db: Connection

Connection the model uses.

elements

elements: IORElementSchema[]

Elements of the unit

Optional errors

errors: ValidationError

Hash containing current validation errors.

Optional id

id: any

The string version of this documents _id.

isNew

isNew: boolean

Boolean flag specifying if the document is new.

modelName

modelName: string

The name of the model

name

name: string

Name of the unit (eg: "cultivation cart")

rates

rates: IORRateSchema[]

History of occupation rate value

schema

schema: Schema<Document<any, {}>, Model<any, any>, undefined>

The document's schema.

slots

slots: number

Number of slots available in the unit

Methods

$getAllSubdocs

  • $getAllSubdocs(): Document<any, {}>[]
  • Returns Document<any, {}>[]

$getPopulatedDocs

  • $getPopulatedDocs(): Document<any, {}>[]
  • Returns an array of all populated documents associated with the query

    Returns Document<any, {}>[]

$ignore

  • $ignore(path: string): void
  • Don't run validation on this path or persist changes to this path.

    Parameters

    • path: string

    Returns void

$isDefault

  • $isDefault(path: string): boolean
  • Checks if a path is set to its default.

    Parameters

    • path: string

    Returns boolean

$isDeleted

  • $isDeleted(val?: boolean): boolean
  • Getter/setter, determines whether the document was removed or not.

    Parameters

    • Optional val: boolean

    Returns boolean

$isEmpty

  • $isEmpty(path: string): 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

$isValid

  • $isValid(path: string): boolean
  • Checks if a path is invalid

    Parameters

    • path: string

    Returns boolean

$markValid

  • $markValid(path: string): void
  • Marks a path as valid, removing existing validation errors.

    Parameters

    • path: string

    Returns void

$session

  • $session(session?: ClientSession): ClientSession
  • 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

    • Optional session: ClientSession

    Returns ClientSession

$set

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

    Parameters

    • path: string
    • val: any
    • Optional options: any

    Returns IORUnitSchema

  • Parameters

    • path: string
    • val: any
    • type: any
    • Optional options: any

    Returns IORUnitSchema

  • Parameters

    • value: any

    Returns IORUnitSchema

computeRate

  • Compute the current occupancy rate of the unit

    Returns IORRateSchema

    The occupancy rate entry

    const module = new ORModule({ ... })
    const unit = module.units[0][0]
    
    const rate = unit.computeRate()
    

delete

  • delete(options?: QueryOptions): Query<any, IORUnitSchema, {}>
  • delete(options: QueryOptions, cb?: (err: NativeError, res: any) => void): void
  • delete(cb: (err: NativeError, res: any) => void): void
  • Removes this document from the db.

    Parameters

    • Optional options: QueryOptions

    Returns Query<any, IORUnitSchema, {}>

  • Parameters

    • options: QueryOptions
    • Optional cb: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns void

  • Parameters

    • cb: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns void

deleteOne

  • deleteOne(options?: QueryOptions): Query<any, IORUnitSchema, {}>
  • deleteOne(options: QueryOptions, cb?: (err: NativeError, res: any) => void): void
  • deleteOne(cb: (err: NativeError, res: any) => void): void
  • Removes this document from the db.

    Parameters

    • Optional options: QueryOptions

    Returns Query<any, IORUnitSchema, {}>

  • Parameters

    • options: QueryOptions
    • Optional cb: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns void

  • Parameters

    • cb: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns void

depopulate

  • Takes a populated field and returns it to its unpopulated state.

    Parameters

    • path: string

    Returns IORUnitSchema

directModifiedPaths

  • directModifiedPaths(): string[]
  • 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[]

equals

  • equals(doc: Document<any, {}>): boolean
  • 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<any, {}>

    Returns boolean

execPopulate

  • Explicitly executes population and returns a promise. Useful for promises integration.

    Returns Promise<IORUnitSchema>

  • Parameters

    Returns void

fill

  • fill(): void
  • Fill the unit with empty elements

    const module = new ORModule({ ... })
    const unit = module.units[0][0]
    
    await unit.fill()
    

    Returns void

get

  • get(path: string, type?: any, options?: any): any
  • Returns the value of a path.

    Parameters

    • path: string
    • Optional type: any
    • Optional options: any

    Returns any

getChanges

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

    Returns UpdateQuery<IORUnitSchema>

increment

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

    Returns IORUnitSchema

init

  • 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

    Returns IORUnitSchema

invalidate

  • invalidate(path: string, errorMsg: string | NativeError, value?: any, kind?: string): NativeError
  • Marks a path as invalid, causing validation to fail.

    Parameters

    • path: string
    • errorMsg: string | NativeError
    • Optional value: any
    • Optional kind: string

    Returns NativeError

isDirectModified

  • isDirectModified(path: string): boolean
  • Returns true if path was directly set and modified, else false.

    Parameters

    • path: string

    Returns boolean

isDirectSelected

  • isDirectSelected(path: string): boolean
  • Checks if path was explicitly selected. If no projection, always returns true.

    Parameters

    • path: string

    Returns boolean

isInit

  • isInit(path: string): 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

isModified

  • isModified(path?: string | string[]): boolean
  • Returns true if any of the given paths is modified, else false. If no arguments, returns true if any path in this document is modified.

    Parameters

    • Optional path: string | string[]

    Returns boolean

isSelected

  • isSelected(path: string): boolean
  • Checks if path was selected in the source query which initialized this document.

    Parameters

    • path: string

    Returns boolean

markModified

  • markModified(path: string, scope?: any): void
  • Marks the path as having pending changes to write to the db.

    Parameters

    • path: string
    • Optional scope: any

    Returns void

model

  • model<T>(name: string): T
  • Returns another Model instance.

    Type parameters

    • T: Model<any, {}, T>

    Parameters

    • name: string

    Returns T

modifiedPaths

  • modifiedPaths(options?: { includeChildren?: boolean }): string[]
  • Returns the list of paths that have been modified.

    Parameters

    • Optional options: { includeChildren?: boolean }
      • Optional includeChildren?: boolean

    Returns string[]

overwrite

  • 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

    Returns IORUnitSchema

populate

  • Populates document references, executing the callback when complete. If you want to use promises instead, use this function with execPopulate().

    Parameters

    Returns IORUnitSchema

  • Parameters

    Returns IORUnitSchema

  • Parameters

    • opts: PopulateOptions | PopulateOptions[]
    • Optional callback: (err: NativeError, res: IORUnitSchema) => void

    Returns IORUnitSchema

populated

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

    Parameters

    • path: string

    Returns any

remove

  • remove(options?: QueryOptions): Promise<IORUnitSchema>
  • remove(options?: QueryOptions, cb?: (err: NativeError, res: any) => void): void
  • Removes this document from the db.

    Parameters

    • Optional options: QueryOptions

    Returns Promise<IORUnitSchema>

  • Parameters

    • Optional options: QueryOptions
    • Optional cb: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns void

replaceOne

  • replaceOne(replacement?: _AllowStringsForIds<LeanDocument<IORUnitSchema>>, options?: QueryOptions, callback?: (err: any, res: any) => void): Query<any, IORUnitSchema, {}>
  • Sends a replaceOne command with this document _id as the query selector.

    Parameters

    • Optional replacement: _AllowStringsForIds<LeanDocument<IORUnitSchema>>
    • Optional options: QueryOptions
    • Optional callback: (err: any, res: any) => void
        • (err: any, res: any): void
        • Parameters

          • err: any
          • res: any

          Returns void

    Returns Query<any, IORUnitSchema, {}>

save

  • save(options?: SaveOptions): Promise<IORUnitSchema>
  • save(options?: SaveOptions, fn?: (err: NativeError, doc: IORUnitSchema) => void): void
  • save(fn?: (err: NativeError, doc: IORUnitSchema) => void): void
  • 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

    • Optional options: SaveOptions

    Returns Promise<IORUnitSchema>

  • Parameters

    • Optional options: SaveOptions
    • Optional fn: (err: NativeError, doc: IORUnitSchema) => void

    Returns void

  • Parameters

    Returns void

set

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

    Parameters

    • path: string
    • val: any
    • Optional options: any

    Returns IORUnitSchema

  • Parameters

    • path: string
    • val: any
    • type: any
    • Optional options: any

    Returns IORUnitSchema

  • Parameters

    • value: any

    Returns IORUnitSchema

toJSON

  • toJSON(options?: ToObjectOptions): LeanDocument<IORUnitSchema>
  • toJSON<T>(options?: ToObjectOptions): T
  • The return value of this method is used in calls to JSON.stringify(doc).

    Parameters

    • Optional options: ToObjectOptions

    Returns LeanDocument<IORUnitSchema>

  • Type parameters

    • T

    Parameters

    • Optional options: ToObjectOptions

    Returns T

toObject

  • toObject(options?: ToObjectOptions): LeanDocument<IORUnitSchema>
  • toObject<T>(options?: ToObjectOptions): T
  • Converts this document into a plain-old JavaScript object (POJO).

    Parameters

    • Optional options: ToObjectOptions

    Returns LeanDocument<IORUnitSchema>

  • Type parameters

    • T

    Parameters

    • Optional options: ToObjectOptions

    Returns T

unmarkModified

  • unmarkModified(path: string): void
  • Clears the modified state on the specified path.

    Parameters

    • path: string

    Returns void

update

  • update(update?: UpdateQuery<IORUnitSchema>, options?: QueryOptions, callback?: (err: NativeError, res: any) => void): Query<any, IORUnitSchema, {}>
  • Sends an update command with this document _id as the query selector.

    Parameters

    • Optional update: UpdateQuery<IORUnitSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns Query<any, IORUnitSchema, {}>

updateOne

  • updateOne(update?: UpdateQuery<IORUnitSchema>, options?: QueryOptions, callback?: (err: NativeError, res: any) => void): Query<any, IORUnitSchema, {}>
  • Sends an updateOne command with this document _id as the query selector.

    Parameters

    • Optional update: UpdateQuery<IORUnitSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: NativeError, res: any) => void
        • (err: NativeError, res: any): void
        • Parameters

          • err: NativeError
          • res: any

          Returns void

    Returns Query<any, IORUnitSchema, {}>

validate

  • validate(pathsToValidate?: string[], options?: any): Promise<void>
  • validate(callback: (err: NativeError) => void): void
  • validate(pathsToValidate: string[], callback: (err: NativeError) => void): void
  • validate(pathsToValidate: string[], options: any, callback: (err: NativeError) => void): void
  • Executes registered validation rules for this document.

    Parameters

    • Optional pathsToValidate: string[]
    • Optional options: any

    Returns Promise<void>

  • Parameters

    • callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns void

  • Parameters

    • pathsToValidate: string[]
    • callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns void

  • Parameters

    • pathsToValidate: string[]
    • options: any
    • callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns void

validateSlots

  • validateSlots(): boolean
  • Check if the units elements doesn't exceed the slot count

    Returns boolean

    false if the count exceeds, false otherwise

    const module = new ORModule({ ... })
    
    // Do changes on units
    ...
    
    // Make sur all units are valid
    for(groups in module.units) {
            for(unit in groups) {
                await group.validateSlots()
            }
    }
    

validateSync

  • validateSync(pathsToValidate?: string[], options?: any): NativeError
  • Executes registered validation rules (skipping asynchronous validators) for this document.

    Parameters

    • Optional pathsToValidate: string[]
    • Optional options: any

    Returns NativeError

Generated using TypeDoc