Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMeasure

Hierarchy

Index

Constructors

constructor

  • Parameters

    • Optional doc: any

    Returns IMeasureSchema

Properties

base

base: __module

Base Mongoose instance the model uses.

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.

discriminators

discriminators: {}

Registered discriminators for this model.

Type declaration

  • [name: string]: Model<any>

events

events: EventEmitter

Event emitter that reports any errors that occurred. Useful for global error handling.

modelName

modelName: string

The name of the model

schema

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

Schema the model uses.

Methods

$where

  • Adds a $where clause to this query

    Parameters

    • argument: string | Function

    Returns Query<IMeasureSchema[], IMeasureSchema, {}>

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

aggregate

  • aggregate<R>(pipeline?: any[]): Aggregate<R[]>
  • aggregate<R>(pipeline: any[], cb: Function): Promise<R[]>
  • Type parameters

    • R = any

    Parameters

    • Optional pipeline: any[]

    Returns Aggregate<R[]>

  • Type parameters

    • R = any

    Parameters

    • pipeline: any[]
    • cb: Function

    Returns Promise<R[]>

bulkWrite

  • bulkWrite(writes: any[], options?: CollectionBulkWriteOptions): Promise<BulkWriteOpResultObject>
  • bulkWrite(writes: any[], options?: CollectionBulkWriteOptions, cb?: (err: any, res: BulkWriteOpResultObject) => void): void
  • Sends multiple insertOne, updateOne, updateMany, replaceOne, deleteOne, and/or deleteMany operations to the MongoDB server in one command. This is faster than sending multiple independent operations (e.g. if you use create()) because with bulkWrite() there is only one round trip to MongoDB.

    Parameters

    • writes: any[]
    • Optional options: CollectionBulkWriteOptions

    Returns Promise<BulkWriteOpResultObject>

  • Parameters

    • writes: any[]
    • Optional options: CollectionBulkWriteOptions
    • Optional cb: (err: any, res: BulkWriteOpResultObject) => void
        • (err: any, res: BulkWriteOpResultObject): void
        • Parameters

          • err: any
          • res: BulkWriteOpResultObject

          Returns void

    Returns void

count

  • count(callback?: (err: any, count: number) => void): Query<number, IMeasureSchema, {}>
  • count(filter: FilterQuery<IMeasureSchema>, callback?: (err: any, count: number) => void): Query<number, IMeasureSchema, {}>
  • Creates a count query: counts the number of documents that match filter.

    Parameters

    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<number, IMeasureSchema, {}>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<number, IMeasureSchema, {}>

countDocuments

  • countDocuments(callback?: (err: any, count: number) => void): Query<number, IMeasureSchema, {}>
  • countDocuments(filter: FilterQuery<IMeasureSchema>, callback?: (err: any, count: number) => void): Query<number, IMeasureSchema, {}>
  • Creates a countDocuments query: counts the number of documents that match filter.

    Parameters

    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<number, IMeasureSchema, {}>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<number, IMeasureSchema, {}>

create

  • Creates a new document or documents

    Parameters

    Returns Promise<IMeasureSchema>

  • Parameters

    Returns Promise<IMeasureSchema[]>

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Type parameters

    Parameters

    • docs: DocContents[]
    • Optional options: SaveOptions

    Returns Promise<IMeasureSchema[]>

  • Type parameters

    Parameters

    • doc: DocContents

    Returns Promise<IMeasureSchema>

  • Type parameters

    Parameters

    • Rest ...docs: DocContents[]

    Returns Promise<IMeasureSchema[]>

  • Type parameters

    Parameters

    Returns void

  • Type parameters

    Parameters

    Returns void

createCollection

  • createCollection(options?: CollectionCreateOptions): Promise<Collection<IMeasureSchema>>
  • createCollection(options: CollectionCreateOptions, callback: (err: NativeError, collection: Collection<IMeasureSchema>) => void): void
  • Create the collection for this model. By default, if no indexes are specified, mongoose will not create the collection for the model until any documents are created. Use this method to create the collection explicitly.

    Parameters

    • Optional options: CollectionCreateOptions

    Returns Promise<Collection<IMeasureSchema>>

  • Parameters

    • options: CollectionCreateOptions
    • callback: (err: NativeError, collection: Collection<IMeasureSchema>) => void
        • Parameters

          Returns void

    Returns void

createIndexes

  • createIndexes(callback?: (err: any) => void): Promise<void>
  • createIndexes(options?: any, callback?: (err: any) => void): Promise<void>
  • Similar to ensureIndexes(), except for it uses the createIndex function.

    Parameters

    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

  • Parameters

    • Optional options: any
    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

deleteMany

  • deleteMany(filter?: FilterQuery<IMeasureSchema>, options?: QueryOptions, callback?: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • deleteMany(filter: FilterQuery<IMeasureSchema>, callback: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • deleteMany(callback: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • Deletes all of the documents that match conditions from the collection. Behaves like remove(), but deletes all documents that match conditions regardless of the single option.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

  • Parameters

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

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

deleteOne

  • deleteOne(filter?: FilterQuery<IMeasureSchema>, options?: QueryOptions, callback?: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • deleteOne(filter: FilterQuery<IMeasureSchema>, callback: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • deleteOne(callback: (err: NativeError) => void): Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>
  • Deletes the first document that matches conditions from the collection. Behaves like remove(), but deletes at most one document regardless of the single option.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

  • Parameters

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

          • err: NativeError

          Returns void

    Returns Query<{ n?: number; ok?: number } & { deletedCount?: number }, IMeasureSchema, {}>

discriminator

  • discriminator<D>(name: string | number, schema: Schema<D, Model<any, any>, undefined>, value?: string): Model<D, {}>
  • discriminator<T, U>(name: string | number, schema: Schema<T, U, undefined>, value?: string): U
  • Adds a discriminator type.

    Type parameters

    • D: Document<any, {}, D>

    Parameters

    • name: string | number
    • schema: Schema<D, Model<any, any>, undefined>
    • Optional value: string

    Returns Model<D, {}>

  • Type parameters

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

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

    Parameters

    • name: string | number
    • schema: Schema<T, U, undefined>
    • Optional value: string

    Returns U

distinct

  • distinct(field: string, filter?: FilterQuery<IMeasureSchema>, callback?: (err: any, count: number) => void): Query<any[], IMeasureSchema, {}>
  • Creates a distinct query: returns the distinct values of the given field that match filter.

    Parameters

    • field: string
    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<any[], IMeasureSchema, {}>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

ensureIndexes

  • ensureIndexes(callback?: (err: any) => void): Promise<void>
  • ensureIndexes(options?: any, callback?: (err: any) => void): Promise<void>
  • Sends createIndex commands to mongo for each index declared in the schema. The createIndex commands are sent in series.

    Parameters

    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

  • Parameters

    • Optional options: any
    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

estimatedDocumentCount

  • estimatedDocumentCount(options?: QueryOptions, callback?: (err: any, count: number) => void): Query<number, IMeasureSchema, {}>
  • Creates a estimatedDocumentCount query: counts the number of documents in the collection.

    Parameters

    • Optional options: QueryOptions
    • Optional callback: (err: any, count: number) => void
        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns Query<number, IMeasureSchema, {}>

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

exists

  • exists(filter: FilterQuery<IMeasureSchema>): Promise<boolean>
  • exists(filter: FilterQuery<IMeasureSchema>, callback: (err: any, res: boolean) => void): void
  • Returns true if at least one document exists in the database that matches the given filter, and false otherwise.

    Parameters

    Returns Promise<boolean>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • callback: (err: any, res: boolean) => void
        • (err: any, res: boolean): void
        • Parameters

          • err: any
          • res: boolean

          Returns void

    Returns void

fetchMyFoodRecords

  • fetchMyFoodRecords(greenhouseId: number, maxRecords?: number): Promise<IMeasureSchema[]>
  • Fetch the records from MyFood API

    Parameters

    • greenhouseId: number

      The id of the greenhouse from the MyFood API

    • Optional maxRecords: number

      The maximum amount of records to keep (most recent first), -1 for all (default: -1)

    Returns Promise<IMeasureSchema[]>

    The Measures from the fetched records

    const greenhouseId = 91
    const records = await Measure.fetchMyFoodRecords(greenhouseId)
    

fetchUnregisteredRecords

  • fetchUnregisteredRecords(greenhouseId: number, maxRecords?: number): Promise<IMeasureSchema[]>
  • Fetch the records from MyFood API, but only returns the measures that are not registered in the database

    Parameters

    • greenhouseId: number

      The id of the greenhouse from the MyFood API

    • Optional maxRecords: number

      The maximum amount of records to keep (most recent first), -1 for all (default: -1)

    Returns Promise<IMeasureSchema[]>

    The filtered records

    const greenhouseId = 91
    const newRecords = await Measure.fetchUnregisteredRecords(greenhouseId)
    // to get only the last entry for each sensor
    const newRecords = await Measure.fetchUnregisteredRecords(greenhouseId, 6)
    

filterUnregisteredRecords

  • Filter all the given measures to keep only the ones the are not registered in the database

    Parameters

    Returns Promise<IMeasureSchema[]>

    The filtered measures

    const records = await Measure.fetchMyFoodRecords(greenhouseId)
    const newRecords = await Measure.filterUnregisteredRecords(records)
    

find

findById

  • Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().

    Parameters

    • id: any
    • Optional projection: any
    • Optional options: QueryOptions
    • Optional callback: (err: NativeError, doc: IMeasureSchema) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findByIdAndDelete

  • Creates a findByIdAndDelete query, filtering by the given _id.

    Parameters

    • Optional id: any
    • Optional options: QueryOptions
    • Optional callback: (err: any, doc: IMeasureSchema, res: any) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findByIdAndRemove

  • Creates a findByIdAndRemove query, filtering by the given _id.

    Parameters

    • Optional id: any
    • Optional options: QueryOptions
    • Optional callback: (err: any, doc: IMeasureSchema, res: any) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findByIdAndUpdate

  • Creates a findOneAndUpdate query, filtering by the given _id.

    Parameters

    • id: any
    • update: UpdateQuery<IMeasureSchema>
    • options: QueryOptions & { rawResult: true }
    • Optional callback: (err: any, doc: FindAndModifyWriteOpResultObject<IMeasureSchema>, res: any) => void
        • (err: any, doc: FindAndModifyWriteOpResultObject<IMeasureSchema>, res: any): void
        • Parameters

          • err: any
          • doc: FindAndModifyWriteOpResultObject<IMeasureSchema>
          • res: any

          Returns void

    Returns Query<FindAndModifyWriteOpResultObject<IMeasureSchema>, IMeasureSchema, {}>

  • Parameters

    • id: any
    • update: UpdateQuery<IMeasureSchema>
    • options: QueryOptions & { upsert: true } & { new: true } & QueryOptions & { upsert: true } & { returnOriginal: false }
    • Optional callback: (err: any, doc: IMeasureSchema, res: any) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

  • Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

  • Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findOne

  • Finds one document.

    Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findOneAndDelete

  • Creates a findOneAndDelete query: atomically finds the given document, deletes it, and returns the document as it was before deletion.

    Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findOneAndRemove

  • Creates a findOneAndRemove query: atomically finds the given document and deletes it.

    Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findOneAndReplace

  • Creates a findOneAndReplace query: atomically finds the given document and replaces it with replacement.

    Parameters

    • filter: FilterQuery<IMeasureSchema>
    • replacement: _AllowStringsForIds<LeanDocument<IMeasureSchema>>
    • options: QueryOptions & { upsert: true } & { new: true } & QueryOptions & { upsert: true } & { returnOriginal: false }
    • Optional callback: (err: any, doc: IMeasureSchema, res: any) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

  • Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

findOneAndUpdate

  • Creates a findOneAndUpdate query: atomically find the first document that matches filter and apply update.

    Parameters

    • filter: FilterQuery<IMeasureSchema>
    • update: UpdateQuery<IMeasureSchema>
    • options: QueryOptions & { rawResult: true }
    • Optional callback: (err: any, doc: FindAndModifyWriteOpResultObject<IMeasureSchema>, res: any) => void
        • (err: any, doc: FindAndModifyWriteOpResultObject<IMeasureSchema>, res: any): void
        • Parameters

          • err: any
          • doc: FindAndModifyWriteOpResultObject<IMeasureSchema>
          • res: any

          Returns void

    Returns Query<FindAndModifyWriteOpResultObject<IMeasureSchema>, IMeasureSchema, {}>

  • Parameters

    • filter: FilterQuery<IMeasureSchema>
    • update: UpdateQuery<IMeasureSchema>
    • options: QueryOptions & { upsert: true } & { new: true } & QueryOptions & { upsert: true } & { returnOriginal: false }
    • Optional callback: (err: any, doc: IMeasureSchema, res: any) => void

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

  • Parameters

    Returns Query<IMeasureSchema, IMeasureSchema, {}>

geoSearch

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getSensorByName

  • getSensorByName(sensorName: string): Sensor
  • Get a sensor type by it's name

    Parameters

    • sensorName: string

      Sensor name

    Returns Sensor

    Sensor type

    const sensorName = record.sensor
    const sensor = Measure.getSensorByName(sensorName)
    

hydrate

  • Shortcut for creating a new Document from existing raw data, pre-saved in the DB. The document returned has no paths marked as modified initially.

    Parameters

    • obj: any

    Returns IMeasureSchema

init

  • This function is responsible for building indexes, unless autoIndex is turned off. Mongoose calls this function automatically when a model is created using mongoose.model() or connection.model(), so you don't need to call it.

    Parameters

    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<IMeasureSchema>

insertMany

  • Inserts one or more new documents as a single insertMany call to the MongoDB server.

    Parameters

    Returns Promise<InsertManyResult>

  • Parameters

    Returns Promise<IMeasureSchema>

  • Parameters

    Returns Promise<InsertManyResult>

  • Parameters

    Returns Promise<IMeasureSchema[]>

  • Parameters

    Returns void

  • Parameters

    • docs: (IMeasureSchema | _AllowStringsForIds<LeanDocument<IMeasureSchema>>)[]
    • Optional options: InsertManyOptions
    • Optional callback: (err: NativeError, res: InsertManyResult | IMeasureSchema[]) => void
        • Parameters

          Returns void

    Returns void

listIndexes

  • listIndexes(callback: (err: NativeError, res: any[]) => void): void
  • listIndexes(): Promise<any[]>
  • Lists the indexes currently defined in MongoDB. This may or may not be the same as the indexes defined in your schema depending on whether you use the autoIndex option and if you build indexes manually.

    Parameters

    • callback: (err: NativeError, res: any[]) => void
        • (err: NativeError, res: any[]): void
        • Parameters

          • err: NativeError
          • res: any[]

          Returns void

    Returns void

  • Returns Promise<any[]>

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

mapReduce

  • mapReduce<Key, Value>(o: MapReduceOptions<IMeasureSchema, Key, Value>, callback?: (err: any, res: any) => void): Promise<any>
  • Executes a mapReduce command.

    Type parameters

    • Key

    • Value

    Parameters

    • o: MapReduceOptions<IMeasureSchema, Key, Value>
    • Optional callback: (err: any, res: any) => void
        • (err: any, res: any): void
        • Parameters

          • err: any
          • res: any

          Returns void

    Returns Promise<any>

off

  • off(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

on

  • on(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

once

  • once(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

populate

  • populate(docs: any[], options: string | PopulateOptions | PopulateOptions[], callback?: (err: any, res: IMeasureSchema[]) => void): Promise<IMeasureSchema[]>
  • populate(doc: any, options: string | PopulateOptions | PopulateOptions[], callback?: (err: any, res: IMeasureSchema) => void): Promise<IMeasureSchema>
  • Populates document references.

    Parameters

    • docs: any[]
    • options: string | PopulateOptions | PopulateOptions[]
    • Optional callback: (err: any, res: IMeasureSchema[]) => void

    Returns Promise<IMeasureSchema[]>

  • Parameters

    • doc: any
    • options: string | PopulateOptions | PopulateOptions[]
    • Optional callback: (err: any, res: IMeasureSchema) => void

    Returns Promise<IMeasureSchema>

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

remove

  • remove(filter?: any, callback?: (err: NativeError) => void): Query<any, IMeasureSchema, {}>
  • Parameters

    • Optional filter: any
    • Optional callback: (err: NativeError) => void
        • (err: NativeError): void
        • Parameters

          • err: NativeError

          Returns void

    Returns Query<any, IMeasureSchema, {}>

removeAllListeners

  • removeAllListeners(event?: string | symbol): IMeasure
  • Parameters

    • Optional event: string | symbol

    Returns IMeasure

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): IMeasure
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns IMeasure

replaceOne

  • replaceOne(filter?: FilterQuery<IMeasureSchema>, replacement?: _AllowStringsForIds<LeanDocument<IMeasureSchema>>, options?: QueryOptions, callback?: (err: any, res: any) => void): Query<any, IMeasureSchema, {}>
  • Creates a replaceOne query: finds the first document that matches filter and replaces it with replacement.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional replacement: _AllowStringsForIds<LeanDocument<IMeasureSchema>>
    • 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, IMeasureSchema, {}>

setMaxListeners

  • Parameters

    • n: number

    Returns IMeasure

startSession

  • startSession(options?: SessionOptions, cb?: (err: any, session: ClientSession) => void): Promise<ClientSession>
  • Starts a MongoDB session for benefits like causal consistency, retryable writes, and transactions.

    Parameters

    • Optional options: SessionOptions
    • Optional cb: (err: any, session: ClientSession) => void
        • (err: any, session: ClientSession): void
        • Parameters

          • err: any
          • session: ClientSession

          Returns void

    Returns Promise<ClientSession>

syncIndexes

  • syncIndexes(options?: Record<string, unknown>): Promise<string[]>
  • syncIndexes(options: Record<string, unknown>, callback: (err: NativeError, dropped: string[]) => void): void
  • Makes the indexes in MongoDB match the indexes defined in this model's schema. This function will drop any indexes that are not defined in the model's schema except the _id index, and build any indexes that are in your schema but not in MongoDB.

    Parameters

    • Optional options: Record<string, unknown>

    Returns Promise<string[]>

  • Parameters

    • options: Record<string, unknown>
    • callback: (err: NativeError, dropped: string[]) => void
        • (err: NativeError, dropped: string[]): void
        • Parameters

          • err: NativeError
          • dropped: string[]

          Returns void

    Returns void

translateAliases

  • translateAliases(raw: any): any
  • Translate any aliases fields/conditions so the final query or document object is pure

    Parameters

    • raw: any

    Returns any

update

  • deprecated

    use updateOne or updateMany instead. Creates a update query: updates one or many documents that match filter with update, based on the multi option.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional update: UpdateQuery<IMeasureSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: any, res: any) => void
        • (err: any, res: any): void
        • Parameters

          • err: any
          • res: any

          Returns void

    Returns Query<UpdateWriteOpResult, IMeasureSchema, {}>

updateMany

  • Creates a updateMany query: updates all documents that match filter with update.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional update: UpdateQuery<IMeasureSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: any, res: any) => void
        • (err: any, res: any): void
        • Parameters

          • err: any
          • res: any

          Returns void

    Returns Query<UpdateWriteOpResult, IMeasureSchema, {}>

updateOne

  • Creates a updateOne query: updates the first document that matches filter with update.

    Parameters

    • Optional filter: FilterQuery<IMeasureSchema>
    • Optional update: UpdateQuery<IMeasureSchema>
    • Optional options: QueryOptions
    • Optional callback: (err: any, res: any) => void
        • (err: any, res: any): void
        • Parameters

          • err: any
          • res: any

          Returns void

    Returns Query<UpdateWriteOpResult, IMeasureSchema, {}>

validate

  • validate(callback?: (err: any) => void): Promise<void>
  • validate(optional: any, callback?: (err: any) => void): Promise<void>
  • validate(optional: any, pathsToValidate: string[], callback?: (err: any) => void): Promise<void>
  • Casts and validates the given object against this model's schema, passing the given context to custom validators.

    Parameters

    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

  • Parameters

    • optional: any
    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

  • Parameters

    • optional: any
    • pathsToValidate: string[]
    • Optional callback: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns Promise<void>

watch

  • watch(pipeline?: Record<string, unknown>[], options?: ChangeStreamOptions): ChangeStream<any>
  • Watches the underlying collection for changes using MongoDB change streams.

    Parameters

    • Optional pipeline: Record<string, unknown>[]
    • Optional options: ChangeStreamOptions

    Returns ChangeStream<any>

where

  • Creates a Query, applies the passed conditions, and returns the Query.

    Parameters

    • path: string
    • Optional val: any

    Returns Query<IMeasureSchema[], IMeasureSchema, {}>

  • Parameters

    • obj: object

    Returns Query<IMeasureSchema[], IMeasureSchema, {}>

  • Returns Query<IMeasureSchema[], IMeasureSchema, {}>

Generated using TypeDoc