Home Manual Reference Source Test
import DatabaseTransaction from 'electron-coresqlite/lib/database-transaction.js'
public class | source

DatabaseTransaction

DatabaseTransaction exposes a convenient API for querying and modifying an RxDB within a SQLite transaction.

You shouldn't need to instantiate this class directly. Instead, use RxDatabase#inTransaction.

Constructor Summary

Public Constructor
public

constructor(database: *)

Member Summary

Public Members
public

Method Summary

Public Methods
public

count(args: ...*): *

public

execute(fn: *): *

public

find(args: ...*): *

public

findAll(args: ...*): *

public

findBy(args: ...*): *

public

findJSONBlob(args: ...*): *

public

modelify(args: ...*): *

public

persistJSONBlob(id: *, json: *): *

public

Asynchronously writes model to the cache and triggers a change event.

public

Asynchronously writes models to the cache and triggers a single change event.

public

Asynchronously removes model from the cache and triggers a change event.

Public Constructors

public constructor(database: *) source

Params:

NameTypeAttributeDescription
database *

Public Members

public database: * source

Public Methods

public count(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public execute(fn: *): * source

Params:

NameTypeAttributeDescription
fn *

Return:

*

public find(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public findAll(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public findBy(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public findJSONBlob(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public modelify(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public persistJSONBlob(id: *, json: *): * source

Params:

NameTypeAttributeDescription
id *
json *

Return:

*

public persistModel(model: Model): Promise source

Asynchronously writes model to the cache and triggers a change event.

Params:

NameTypeAttributeDescription
model Model

A {Model} to write to the database.

Return:

Promise

A promise that:

  • resolves after the database queries are complete and any listening database callbacks have finished
  • rejects if any databse query fails or one of the triggering callbacks failed

public persistModels(models: Array): Promise source

Asynchronously writes models to the cache and triggers a single change event. Note: Models must be of the same class to be persisted in a batch operation.

Params:

NameTypeAttributeDescription
models Array

An {Array} of {Model} objects to write to the database.

Return:

Promise

A promise that:

  • resolves after the database queries are complete and any listening database callbacks have finished
  • rejects if any databse query fails or one of the triggering callbacks failed

public unpersistModel(model: Model): Promise source

Asynchronously removes model from the cache and triggers a change event.

Params:

NameTypeAttributeDescription
model Model

A {Model} to write to the database.

Return:

Promise

A promise that

  • resolves after the database queries are complete and any listening database callbacks have finished
  • rejects if any databse query fails or one of the triggering callbacks failed