# Class: SqlQuery

## SqlQuery(type, sql)

Class representing an SQL query which returns the whole cache entries (key-value pairs).

## Constructor

#### new SqlQuery(type, sql)

Public constructor.

Requires name of a type (or SQL table) and SQL query string to be specified. Other SQL query settings have the following defaults:

        SQL Query setting         :    Default value
        Local query flag          :    false
        Cursor page size          :    1024
        Query arguments           :    not specified
        Distributed joins flag    :    false
        Replicated only flag      :    false
        Timeout                   :    0 (disabled)

Every setting may be changed using set methods.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | name of a type or SQL table.
`sql` | string | SQL query string.

Source:
  - Query.js, line 77

### Extends

- Query

### Methods

#### setArgs(…args) → {SqlQuery}

Set query arguments.

Type of any argument may be specified using setArgTypes() method. If type of an argument is not specified then during operations the Ignite client will try to make automatic mapping between JavaScript types and Ignite object types - according to the mapping table defined in the description of the ObjectType class.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`args` | * | <repeatable> | Query arguments.

Source:
  - Query.js, line 154

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setArgTypes(…argTypes) → {SqlQuery}

Specifies types of query arguments.

Query arguments itself are set using setArgs() method. By default, a type of every argument is not specified that means during operations the Ignite client will try to make automatic mapping between JavaScript types and Ignite object types - according to the mapping table defined in the description of the ObjectType class.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`argTypes` | ObjectType.PRIMITIVE_TYPE | CompositeType | <repeatable> | types of Query arguments. The order of types must follow the order of arguments in the setArgs() method. A type of every argument can be: either a type code of primitive (simple) type or an instance of class representing non-primitive (composite) type or null (means the type is not specified)

Source:
  - Query.js, line 176

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setDistributedJoins(distributedJoins) → {SqlQuery}

Set distributed joins flag.

##### Parameters:

Name | Type | Description
--- | --- | ---
`distributedJoins` | boolean | distributed joins flag: true or false.

Source:
  - Query.js, line 188

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setLocal(local) → {Query}

Set local query flag.

##### Parameters:

Name | Type | Description
--- | --- | ---
`local` | boolean | local query flag: true or false.

Inherited From:
  - Query#setLocal
Source:
  - Query.js, line 44

##### Returns:

- the same instance of the Query.

Type
  Query

#### setPageSize(pageSize) → {Query}

Set Cursor page size.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pageSize` | number | cursor page size.

Inherited From:
  - Query#setPageSize
Source:
  - Query.js, line 56

##### Returns:

- the same instance of the Query.

Type
  Query

#### setReplicatedOnly(replicatedOnly) → {SqlQuery}

Set replicated only flag.

##### Parameters:

Name | Type | Description
--- | --- | ---
`replicatedOnly` | boolean | replicated only flag: true or false.

Source:
  - Query.js, line 200

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setSql(sql) → {SqlQuery}

Set SQL query string.

##### Parameters:

Name | Type | Description
--- | --- | ---
`sql` | string | SQL query string.

Source:
  - Query.js, line 136

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setTimeout(timeout) → {SqlQuery}

Set timeout.

##### Parameters:

Name | Type | Description
--- | --- | ---
`timeout` | number | timeout value in milliseconds. Must be non-negative. Zero value disables timeout.

Source:
  - Query.js, line 213

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery

#### setType(type) → {SqlQuery}

Set name of a type or SQL table.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | name of a type or SQL table.

Source:
  - Query.js, line 118

##### Returns:

- the same instance of the SqlQuery.

Type
  SqlQuery