Home Manual Reference Source Test
import QueryResultSet from 'electron-coresqlite/lib/query-result-set.js'
public class | source

QueryResultSet

Direct Subclass:

MutableQueryResultSet

Instances of QueryResultSet hold a set of models retrieved from the database for a given query and offset.

Complete vs Incomplete:

QueryResultSet keeps an array of item ids and a lookup table of models. The lookup table may be incomplete if the QuerySubscription isn't finished preparing results. You can use isComplete to determine whether the set has every model.

Offset vs Index:

To avoid confusion, "index" (used within the implementation) refers to an item's position in an array, and "offset" refers to it's position in the query result set. For example, an item might be at index 20 in the _ids array, but at offset 120 in the result.

Static Method Summary

Static Public Methods
public static

setByApplyingModels(set: *, models: *): *

Constructor Summary

Public Constructor
public

constructor(other: {})

Method Summary

Public Methods
public

clone(): *

public
public
public

idAtOffset(offset: Number): Array

public

ids(): Array

public
public
public
public
public
public

query(): Query

public
Protected Methods
protected

Static Public Methods

public static setByApplyingModels(set: *, models: *): * source

Params:

NameTypeAttributeDescription
set *
models *

Return:

*

Public Constructors

public constructor(other: {}) source

Params:

NameTypeAttributeDescription
other {}
  • optional
  • default: {}

Public Methods

public clone(): * source

Return:

*

public count(): QueryRange source

Return:

QueryRange

The number of items in the represented range. Note that a range (LIMIT 10 OFFSET 0) may return fewer than the maximum number of items if none match the query.

public empty(): Boolean source

Return:

Boolean

True if the result set is empty, false otherwise.

public idAtOffset(offset: Number): Array source

Params:

NameTypeAttributeDescription
offset Number

The desired offset.

Return:

Array

the model ID available at the requested offset, or undefined.

public ids(): Array source

Return:

Array

the model IDs in the represented result.

public isComplete(): Boolean source

Return:

Boolean

True if every model in the result set is available, false if part of the set is still being loaded. (Usually following range changes.)

public modelAtOffset(offset: Number): Model source

Params:

NameTypeAttributeDescription
offset Number

The desired offset.

Return:

Model

the model at the requested offset.

public modelWithId(id: String): Model source

Params:

NameTypeAttributeDescription
id String

The desired ID.

Return:

Model

the model with the requested ID, or undefined.

public models(): Array source

Return:

Array

An array of model objects. If the result is not yet complete, this array may contain undefined values.

public offsetOfId(id: String): Number source

Params:

NameTypeAttributeDescription
id String

The desired ID.

Return:

Number

the offset of ID, relative to all of the query results.

public query(): Query source

Return:

Query

The represented query.

public range(): QueryRange source

Return:

QueryRange

The represented range.

Protected Methods

protected modelCacheCount(): * source

Return:

*