Object built-in object

Object SQLite

sqlite database connection object

Use db.open or db.openSQLite create, create method:

1
var slite = db.openSQLite("sqlite:/path/to/db");

Inheritance

Member attribute

fileName

String, the current database file name

1
readonly String SQLite.fileName;

timeout

Integer, query and set the database timeout time in milliseconds

1
Integer SQLite.timeout;

type

String, query current connection database type

1
readonly String SQLite.type;

Member function

backup

Backup the current database to a new file

1
SQLite.backup(String fileName) async;

Call parameters:

  • fileName : String, specifies the name of the backup database file

close

Close the current database connection

1
SQLite.close() async;

begin

Start a transaction on the current database connection

1
SQLite.begin() async;

commit

Commit the transaction on the current database connection

1
SQLite.commit() async;

rollback

Roll back the transaction on the current database connection

1
SQLite.rollback() async;

trans

Enter a transaction to execute a function, and submit or rollback according to the function execution

1
Boolean SQLite.trans(Function func);

Call parameters:

  • func : Function, a function executed in a transactional manner

Return result:

  • Boolean , returns whether the transaction is committed, returns true during normal commit, returns false during rollback, and throws an error if the transaction fails

There are three results of func execution:

  • The function returns normally, including the end of the run and active return, at which point the transaction will be automatically committed
  • The function returns false, at this time the transaction will be rolled back
  • Function run error, transaction is automatically rolled back

execute

Execute a sql command and return the execution result, you can format the string according to the parameters

1 2
NArray SQLite.execute(String sql, ...args) async;

Call parameters:

  • sql : String, format string, optional parameters are specified with ?. For example:'SELECT FROM TEST WHERE [id]=?'
  • args : ..., optional parameter list

Return result:

  • NArray , returns an array containing the result records. If the request is UPDATE or INSERT, the returned result will also include affected and insertId. mssql does not support insertId.

insert

Insert new record

1
Number SQLite.insert(Object opts) async;

Call parameters:

  • opts : Object, parameter list

Return result:

  • Number , returns the inserted id, or 0 if the engine does not support it

find

Query data according to specified conditions

1
NArray SQLite.find(Object opts) async;

Call parameters:

  • opts : Object, parameter list

Return result:

  • NArray , returns the record containing the result

count

Statistics data records according to specified conditions

1
Integer SQLite.count(Object opts) async;

Call parameters:

  • opts : Object, parameter list

Return result:

  • Integer , returns the number of records containing the result

update

Update data according to specified conditions

1
Integer SQLite.update(Object opts) async;

Call parameters:

  • opts : Object, parameter list

Return result:

  • Integer , returns the number of records containing updates

remove

Delete data according to specified conditions

1
Integer SQLite.remove(Object opts) async;

Call parameters:

  • opts : Object, optional parameter list

Return result:

  • Integer , returns the number of records containing updates

format

Format a sql command and return the formatted result

1 2
String SQLite.format(String method, Object opts);

Call parameters:

  • method : String, specifies the method of the request
  • opts : Object, optional parameter list

Return result:

  • String , returns the sql command after formatting

Format a sql command and return the formatted result

1 2
String SQLite.format(String sql, ...args);

Call parameters:

  • sql : String, format string, optional parameters are specified with ?. For example:'SELECT FROM TEST WHERE [id]=?'
  • args : ..., optional parameter list

Return result:

  • String , returns the sql command after formatting

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be reimplemented according to its own characteristics

1
String SQLite.toString();

Return result:

  • String , returns a string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object

1
Value SQLite.toJSON(String key = "");

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable