Movatterモバイル変換


[0]ホーム

URL:


Redux-ORM

Redux-ORM

QuerySet

This class is used to build and make queries to the database
and operating the resulting set (such as updating attributes
or deleting the records).

The queries are built lazily. For example:

const qs = Book.all()    .filter(book => book.releaseYear > 1999)    .orderBy('name');

Doesn't execute a query. The query is executed only when
you need information from the query result, such as [count](#QuerySet+count),
[toRefArray](#QuerySet+toRefArray). After the query is executed, the resulting
set is cached in the QuerySet instance.

QuerySet instances also return copies, so chaining filters doesn't
mutate the previous instances.

Kind: global class

  • QuerySet
    • new QuerySet(modelClass, clauses, [opts])
    • withModels
    • withRefs
    • toRefArray() ⇒ Array.
    • toModelArray() ⇒ Array.
    • count() ⇒ number
    • exists() ⇒ Boolean
    • at(index) ⇒ Model ⎮ undefined
    • first() ⇒ Model
    • last() ⇒ Model
    • all() ⇒ QuerySet
    • filter(lookupObj) ⇒ QuerySet
    • exclude(lookupObj) ⇒ QuerySet
    • orderBy(iteratees, [orders]) ⇒ QuerySet
    • update(mergeObj) ⇒ undefined
    • delete() ⇒ undefined
    • map()
    • forEach()
    • new QuerySet(modelClass, clauses, [opts])

      Creates a QuerySet. The constructor is mainly for internal use;
      You should access QuerySet instances from [Model](Model).

      ParamTypeDescription
      modelClassModel

      the model class of objects in this QuerySet.

      clausesArray.

      query clauses needed to evaluate the set.

      [opts]Object

      additional options

      withModels

      Deprecated

      Kind: instance property ofQuerySet

      withRefs

      Deprecated

      Kind: instance property ofQuerySet

      toRefArray()⇒ Array.<Object>

      Returns an array of the plain objects represented by the QuerySet.
      The plain objects are direct references to the store.

      Kind: instance method ofQuerySet
      Returns: Array. -

      references to the plain JS objects represented by
      the QuerySet

      toModelArray()⇒ Array.<Model>

      Returns an array of [Model](Model) instances represented by the QuerySet.

      Kind: instance method ofQuerySet
      Returns: Array. -

      model instances represented by the QuerySet

      count()⇒ number

      Returns the number of [Model](Model) instances represented by the QuerySet.

      Kind: instance method ofQuerySet
      Returns: number -

      length of the QuerySet

      exists()⇒ Boolean

      Checks if the [QuerySet](#QuerySet) instance has any records matching the query
      in the database.

      Kind: instance method ofQuerySet
      Returns: Boolean -

      true if theQuerySet instance contains entities, elsefalse.

      at(index)⇒ Model,undefined

      Returns the [Model](Model) instance at indexindex in the [QuerySet](#QuerySet) instance if
      withRefs flag is set tofalse, or a reference to the plain JavaScript
      object in the model state iftrue.

      Kind: instance method ofQuerySet
      Returns:Model ⎮ undefined -

      aModel instance at index
      index in theQuerySet instance,
      or undefined if the index is out of bounds.

      ParamTypeDescription
      indexnumber

      index of the model instance to get

      first()⇒ Model

      Returns the [Model](Model) instance at index 0 in the [QuerySet](#QuerySet) instance.

      Kind: instance method ofQuerySet

      last()⇒ Model

      Returns the [Model](Model) instance at indexQuerySet.count() - 1

      Kind: instance method ofQuerySet

      all()⇒ QuerySet

      Returns a new [QuerySet](#QuerySet) instance with the same entities.

      Kind: instance method ofQuerySet
      Returns:QuerySet -

      a new QuerySet with the same entities.

      filter(lookupObj)⇒ QuerySet

      Returns a new [QuerySet](#QuerySet) instance with entities that match properties inlookupObj.

      Kind: instance method ofQuerySet
      Returns:QuerySet -

      a newQuerySet instance with objects that passed the filter.

      ParamTypeDescription
      lookupObjObject

      the properties to match objects with. Can also be a function.
      It works the same asLodash filter.

      exclude(lookupObj)⇒ QuerySet

      Returns a new [QuerySet](#QuerySet) instance with entities that do not match
      properties inlookupObj.

      Kind: instance method ofQuerySet
      Returns:QuerySet -

      a newQuerySet instance with objects that did not pass the filter.

      ParamTypeDescription
      lookupObjObject

      the properties to unmatch objects with. Can also be a function.
      It works the same asLodash reject.

      orderBy(iteratees, [orders])⇒ QuerySet

      Returns a new [QuerySet](#QuerySet) instance with entities ordered byiteratees in ascending
      order, unless otherwise specified. Delegates toLodash orderBy.

      Kind: instance method ofQuerySet
      Returns:QuerySet -

      a newQuerySet with objects ordered byiteratees.

      ParamTypeDescription
      iterateesArray. ⎮ Array.<function()>

      an array where each item can be a string or a
      function. If a string is supplied, it should
      correspond to property on the entity that will
      determine the order. If a function is supplied,
      it should return the value to order by.

      [orders]Array.<(Boolean'asc''desc')>

      the sort orders ofiteratees. If unspecified, all iteratees
      will be sorted in ascending order.true and'asc'
      correspond to ascending order, andfalse and'desc'
      to descending order.

      update(mergeObj)⇒ undefined

      Records an update specified withmergeObj to all the objects
      in the [QuerySet](#QuerySet) instance.

      Kind: instance method ofQuerySet

      ParamTypeDescription
      mergeObjObject

      an object to merge with all the objects in this
      queryset.

      delete()⇒ undefined

      Records a deletion of all the objects in this [QuerySet](#QuerySet) instance.

      Kind: instance method ofQuerySet

      map()

      Deprecated

      Kind: instance method ofQuerySet

      forEach()

      Deprecated

      Kind: instance method ofQuerySet

      Last updated on 10.1.2020

      [8]ページ先頭

      ©2009-2025 Movatter.jp