Class: Statement<S>
Statement defines a single SQL statement.
Both static and prepared statements are supported. In the current
implementation, the prepared statements are prepared locally, and
executed remotely (on-chain).
Mutating transactions such as INSERTs, DELETEs, and UPDATEs produce
a two-phase transaction. Firstly, the transaction is sent to the
registry contract, and awaited. The returned txn
information also
contains a wait
method than can be used to await finalization on
the Tableland network. This method will also throw an exception if
any runtime errors occur.
Type parameters
• S = unknown
Constructors
new Statement()
new Statement<
S
>(config
,sql
,parameters
?):Statement
<S
>
Parameters
• config: Partial
<ReadConfig
& SignerConfig
> & Partial
<AutoWaitConfig
>
• sql: string
• parameters?: Parameters
Returns
Statement
<S
>
Source
@tableland/sdk/src/statement.ts:62
Properties
config
private
readonly
config:Partial
<ReadConfig
&SignerConfig
> &Partial
<AutoWaitConfig
>
Source
@tableland/sdk/src/statement.ts:58
parameters?
private
optional
readonly
parameters:Parameters
Source
@tableland/sdk/src/statement.ts:60
sql
private
readonly
sql:string
Source
@tableland/sdk/src/statement.ts:59
Methods
#checkIsValidOpts()
private
#checkIsValidOpts(opts
):opts is Options
Parameters
• opts: any
Returns
opts is Options
Source
@tableland/sdk/src/statement.ts:185
#parseAndExtract()
private
#parseAndExtract():Promise
<ExtractedStatement
>
Returns
Promise
<ExtractedStatement
>
Source
@tableland/sdk/src/statement.ts:112
#waitExec()
private
#waitExec(params
,controller
?):Promise
<WaitableTransactionReceipt
>
Parameters
• params: ExtractedStatement
• controller?: PollingController
Returns
Promise
<WaitableTransactionReceipt
>
Source
@tableland/sdk/src/statement.ts:143
all()
all<
T
>(opts
):Promise
<Result
<T
>>
Executes a query and returns all rows and metadata.
Type parameters
• T = Record
<string
, S
>
Parameters
• opts: Options
= {}
An optional object used to control behavior, see Options
Returns
Promise
<Result
<T
>>
Source
@tableland/sdk/src/statement.ts:158
bind()
bind<
T
>(...values
):Statement
<T
>
Bind a set of values to the parameters of the prepared statement. We follow the SQLite convention for prepared statements parameter binding. We support Ordered (?NNNN), Anonymous (?), and Named (@name, :name, $name) parameters.
Type parameters
• T = S
Parameters
• ...values: ValuesType
[]
A variadic list of values to bind. May include base types, and objects.
Returns
Statement
<T
>
A new bound Statement.
Source
@tableland/sdk/src/statement.ts:83
first()
first(opts)
first<
T
>(opts
?):Promise
<null
|T
>
Executes a query and returns the first row of the results. This does not return metadata like the other methods. Instead it returns the object directly. If the query returns no rows, then first() will return null.
Type parameters
• T = Record
<string
, S
>
Parameters
• opts?: Options
An optional object used to control behavior, see Options
Returns
Promise
<null
| T
>
Source
@tableland/sdk/src/statement.ts:197
first(colName, opts)
first<
T
,K
>(colName
,opts
?):Promise
<T
>