Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Cursor

Cursor

module

Cursor

since

0.0.1

author

Eduardo Astolfi eduardo.astolfi91@gmail.com

copyright

2016 Eduardo Astolfi eduardo.astolfi91@gmail.com

license

MIT Licensed

classdesc

Cursor class that maps a MongoDB-like cursor

Hierarchy

  • Cursor

Index

Constructors

constructor

  • new Cursor(documents: any, selection: any, fields?: any, options?: Object): Cursor
  • Parameters

    • documents: any

      The list of documents

    • selection: any
    • Optional fields: any
    • Default value options: Object = {}

    Returns Cursor

Properties

cursor_pos

cursor_pos: any

db_objects

db_objects: any

documents

documents: any

fetch_mode

fetch_mode: any

fields

fields: any

indexes

indexes: any = null

limitValue

limitValue: any

Protected logger

logger: JSWLogger

selector

selector: any

selector_compiled

selector_compiled: any

selector_id

selector_id: any

skipValue

skipValue: any

sortValue

sortValue: any

sort_compiled

sort_compiled: any

sorted

sorted: boolean = false

Static COLSCAN

COLSCAN: string = "colscan"

Static IDXSCAN

IDXSCAN: string = "idxscan"

Methods

batchSize

  • batchSize(): void

close

  • close(): void

comment

  • comment(): void

count

  • count(): any
  • Obtains the total of documents of the cursor

    method

    Cursor#count

    Returns any

    The total of documents in the cursor

explain

  • explain(): void

fetch

  • fetch(): any

fetchAll

  • fetchAll(): any
  • Fetch all documents in the cursor

    method

    Cursor#fetchAll

    Returns any

    All the documents contained in the cursor

fetchOne

  • fetchOne(): any
  • Retrieves the next document in the cursor

    method

    Cursor#fetchOne

    Returns any

    The next document in the cursor

forEach

  • forEach(callback: any): void
  • Iterates over the cursor, calling a callback function

    method

    Cursor#forEach

    Parameters

    • callback: any

    Returns void

hasNext

  • hasNext(): boolean
  • Checks if the cursor has one document to be fetched

    method

    Cursor#hasNext

    Returns boolean

    True if we can fetch one more document

hint

  • hint(): void

itcount

  • itcount(): void

limit

  • limit(limit: any): this
  • Set the max number of document to fetch

    method

    Cursor#limit

    Parameters

    • limit: any

      The max number of documents

    Returns this

    This instance so it can be chained with other methods

map

  • map(callback: any): Array<any>
  • Iterates over the cursor, returning a new array with the documents affected by the callback function

    method

    Cursor#map

    Parameters

    • callback: any

    Returns Array<any>

    The documents after being affected with the callback function

max

  • max(): void

maxScan

  • maxScan(): void

maxTimeMS

  • maxTimeMS(): void

min

  • min(): void

next

  • next(): any

noCursorTimeout

  • noCursorTimeout(): void

objsLeftInBatch

  • objsLeftInBatch(): void

pretty

  • pretty(): void

readConcern

  • readConcern(): void

readPref

  • readPref(): void

returnKey

  • returnKey(): void

rewind

  • rewind(): void

setSorting

  • setSorting(spec: any): this
  • Set the sorting of the cursor

    method

    Cursor#sort

    Parameters

    • spec: any

      The sorting specification

    Returns this

    This instance so it can be chained with other methods

showRecordId

  • showRecordId(): void

size

  • size(): void

skip

  • skip(skip: any): this
  • Set the number of document to skip when fetching the cursor

    method

    Cursor#skip

    Parameters

    • skip: any

      The number of documents to skip

    Returns this

    This instance so it can be chained with other methods

snapshot

  • snapshot(): void

sort

  • sort(spec: any): this
  • Applies a sorting on the cursor

    method

    Cursor#sort

    Parameters

    • spec: any

      The sorting specification

    Returns this

    This instance so it can be chained with other methods

tailable

  • tailable(): void

toArray

  • toArray(): void

Static project

  • project(doc: any, spec: any, aggregation?: boolean): any
  • Projects the fields of one or several documents, changing the output

    method

    Cursor.project

    Parameters

    • doc: any

      The document/s that will be projected

    • spec: any

      Fields projection specification. Can be an space/comma separated list, an array, or an object

    • Default value aggregation: boolean = false

    Returns any

    The document/s after the projection

Static sort

  • sort(doc: any, fields: any): void

Generated using TypeDoc