NetSuite FastTrack Toolkit (NFT) - v8.0.0
    Preparing search index...

    Class LazyQuery

    Makes a NetSuite query an ES2015 style Iterator. That is, it follows the Iterator Protocol for iterating over query results in a forward-only fashion. The result can be passed to any library that accepts Iterators (such as ImmutableJS) to provide easy chainable logic for arbitrary length result sets.

    LazySearch

    import {Seq} from './NFT-X.Y.Z/immutable'
    const oneResult = Seq(LazyQuery.from()).map(nsQueryResult2obj()).take(1)

    Implements

    • IterableIterator<query.Result>
    Index

    Properties

    currentData: Result[]
    currentPage: Page
    index: number
    iterator: PageIterator
    log: Logger
    mappedData: QueryResultMap[]
    pagedData: PagedData
    LOGNAME: "lazyquery" = ...

    the name of the custom logger for this component for independent logging control

    Methods

    • LazyQuery is both an iterable and an iterator for query results.

      Returns IterableIterator<Result>

    • per the iterator protocol, retrieves the next element. Also returns null if done as the specification for the protocol says the value property is optional when 'done'

      You don't typically call this function yourself - libraries like ImmutableJS do.

      Returns IteratorResult<Result>

    • Creates a lazy query from an existing NS .

      Parameters

      • q: { params?: (string | number | boolean)[]; query: string }

        the SQL query and optional query parameters

      • OptionalpageSize: number

        optional pagesize, can be up to 1000. Default is 500

      Returns LazyQuery

      Lazy Seq ready for processing

      import {Seq} from './NFT-X.Y.Z/immutable'
      import * as query from 'N/query
      import {governanceRemains, LazyQuery, nsQueryResult2obj} from './NFT-X.Y.Z/query'

      Seq(LazyQuery.from({
      query: 'SELECT id FROM FOO WHERE name = ?',
      params: ['Farnsworth']
      }))
      .takeWhile(governanceRemains()) // process until we drop below default governance threshold
      .map(nsQueryResult2obj()) // convert query results to plain objects with properties
      .forEach( r => log.debug(r))