Skip to content

breeze-client / QueryOptions

Class: QueryOptions ​

Defined in: src/query/query-options.ts:75

A QueryOptions instance is used to specify the 'options' under which a query will occur.

Constructors ​

Constructor ​

new QueryOptions(config?): QueryOptions

Defined in: src/query/query-options.ts:108

QueryOptions constructor

ts
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
// assume em1 is a preexisting EntityManager
em1.setProperties( { queryOptions: newQo });

Any QueryOptions property that is not defined will be defaulted from any QueryOptions defined at a higher level in the breeze hierarchy, i.e.

  • from query.queryOptions
  • to entityManager.queryOptions
  • to QueryOptions.defaultInstance;

Parameters ​

config? ​

QueryOptionsConfig

A configuration object.

Returns ​

QueryOptions

Properties ​

fetchStrategy ​

fetchStrategy: FetchStrategy

Defined in: src/query/query-options.ts:79

The FetchStrategy to use with any queries. Read Only


includeDeleted ​

includeDeleted: boolean

Defined in: src/query/query-options.ts:83

Whether to include cached deleted entities in a query result (false by default). Read Only


mergeStrategy ​

mergeStrategy: MergeStrategy

Defined in: src/query/query-options.ts:81

The MergeStrategy to use with any queries. Read Only


defaultInstance ​

static defaultInstance: QueryOptions

Defined in: src/query/query-options.ts:88

The default instance for use whenever QueryOptions are not specified.

Methods ​

setAsDefault() ​

setAsDefault(): any

Defined in: src/query/query-options.ts:170

Sets the 'defaultInstance' by creating a copy of the current 'defaultInstance' and then applying all of the properties of the current instance. The current instance is returned unchanged.

ts
var newQo = new QueryOptions( { mergeStrategy: MergeStrategy.OverwriteChanges });
newQo.setAsDefault();

Returns ​

any


toJSON() ​

toJSON(): Object

Defined in: src/query/query-options.ts:180

Returns the serializable form of these options: the names of the fetchStrategy and mergeStrategy, and includeDeleted when it is true. JSON.stringify calls it when EntityManager.exportEntities exports the manager's options and when a query is serialized; QueryOptions.fromJSON reads it back.

Returns ​

Object


using() ​

using(qoConfig): QueryOptions

Defined in: src/query/query-options.ts:151

Returns a copy of this QueryOptions with the specified MergeStrategy, FetchStrategy, or 'includeDeleted' option applied.

ts
// Given an EntityManager instance, em
var queryOptions = em.queryOptions.using(MergeStrategy.PreserveChanges);

or

ts
var queryOptions = em.queryOptions.using(FetchStrategy.FromLocalCache);

or

ts
var queryOptions = em.queryOptions.using({ mergeStrategy: MergeStrategy.OverwriteChanges });

or

ts
var queryOptions = em.queryOptions.using({
   includeDeleted: true,
   fetchStrategy:  FetchStrategy.FromLocalCache 
});

Parameters ​

qoConfig ​

MergeStrategy | FetchStrategy | QueryOptionsConfig

A configuration object or a standalone MergeStrategy or FetchStrategy

Returns ​

QueryOptions

A new QueryOptions instance.


fromJSON() ​

static fromJSON(json): QueryOptions

Defined in: src/query/query-options.ts:193

Creates a QueryOptions from the output of QueryOptions.toJSON. Used by EntityManager.importEntities and when a serialized query is read back.

Parameters ​

json ​

any

A serialized QueryOptions.

Returns ​

QueryOptions


resolve() ​

static resolve(queryOptionsArray): QueryOptions

Defined in: src/query/query-options.ts:119

Combines several QueryOptions into one, taking each property from the first of them that has it set. Breeze uses it to combine a query's own options with its EntityManager's and QueryOptions.defaultInstance; applications do not normally need it.

Parameters ​

queryOptionsArray ​

any[]

The QueryOptions to combine, most specific first. Entries may be null or undefined.

Returns ​

QueryOptions

Released under the MIT License.