Basic FunctionalityAssets ManagementDBOn this pageDB Description: A record that represents a database. Column Type: Field. Description: Type definition for a database column. The boolean type is only used for representing the database NULL value with the boolean false value. Signature: type Column = integer | number | string | boolean Row Type: Field. Description: Type definition for a database row. Signature: type Row = {Column} SQL Type: Field. Description: Type definition for an SQL query. Can be SQL string or a pair of SQL string and an array of parameters. Signature: type SQL = string | {string, {Row}} exist Type: Function. Description: Checks whether a table exists in the database. Signature: exist: function(self: DB, tableName: string, schema?: string): boolean Parameters: ParameterTypeDescriptiontableNamestringThe name of the table to check.schemastring[optional] The name of the schema to check in. Returns: Return TypeDescriptionbooleanWhether the table exists or not. transaction Type: Function. Description: Executes a list of SQL statements as a single transaction. Signature: transaction: function(self: DB, sqls: {SQL}): boolean Parameters: ParameterTypeDescriptionsqls{SQL}A list of SQL statements to execute. Returns: Return TypeDescriptionbooleanWhether the transaction was successful or not. transactionAsync Type: Function. Description: Executes a list of SQL statements as a single transaction asynchronously. Signature: transactionAsync: function(self: DB, sqls: {SQL}): boolean Parameters: ParameterTypeDescriptionsqls{SQL}A list of SQL statements to execute. Returns: Return TypeDescriptionbooleanWhether the transaction was successful or not. query Type: Function. Description: Executes an SQL query and returns the results as a list of rows. Signature: query: function( self: DB, sql: string, args: Row, withColumn?: boolean --[[false]] ): {Row} Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to executeargsRow[optional] A list of values to substitute into the SQL statement.withColumnboolean[optional] Whether to include column names in the result (default false). Returns: Return TypeDescription{Row}A list of rows returned by the query. query Type: Function. Description: Executes an SQL query and returns the results as a list of rows. Signature: query: function( self: DB, sql: string, withColumn?: boolean --[[false]] ): {Row} | nil Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to executewithColumnboolean[optional] Whether to include column names in the result (default false). Returns: Return TypeDescription{Row} | nilA list of rows returned by the query, or nil if the query failed. insert Type: Function. Description: Inserts a row of data into a table within a transaction. Signature: insert: function(self: DB, tableName: string, values: {Row}): boolean Parameters: ParameterTypeDescriptiontableNamestringThe name of the table to insert into.valuesRowThe values to insert into the table. Returns: Return TypeDescriptionbooleanWhether the insertion was successful or not. exec Type: Function. Description: Executes an SQL statement and returns the number of rows affected. Signature: exec: function(self: DB, sql: string): integer Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute. Returns: Return TypeDescriptionintegerThe number of rows affected by the statement, returns -1 if the statement failed. exec Type: Function. Description: Executes an SQL statement and returns the number of rows affected. Signature: exec: function(self: DB, sql: string, values: Row): integer Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute.valuesRowA list of values to substitute into the SQL statement. Returns: Return TypeDescriptionintegerThe number of rows affected by the statement, returns -1 if the statement failed. exec Type: Function. Description: Executes an SQL statement with list of values and returns the number of rows affected within a transaction. Signature: exec: function(self: DB, sql: string, values: {Row}): integer Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute.values{Row}A list of lists of values to substitute into the SQL statement. Returns: Return TypeDescriptionintegerthe number of rows affected by the statement, returns -1 if the statement failed. insertAsync Type: Function. Description: Inserts a row of data into a table within a transaction asynchronously. Signature: insertAsync: function(self: DB, tableName: string, values: {Row}): boolean Parameters: ParameterTypeDescriptiontableNamestringThe name of the table to insert into.values{Row}The values to insert into the table. Returns: Return TypeDescriptionbooleanWhether the insert was successful or not. insertAsync Type: Function. Description: Inserts data from an Excel file into a table within a transaction asynchronously. Signature: insertAsync: function(self: DB, tableSheets: {string}, excelFile: string, startRow: integer): boolean Parameters: ParameterTypeDescriptiontableSheets{string}the names of the tables to insert into.excelFilestringThe path to the Excel file containing the data.startRowintegerThe row number to start inserting data from. The row number start with 1. Returns: Return TypeDescriptionbooleanWhether the insert was successful or not. insertAsync Type: Function. Description: Inserts data from an Excel file into a table within a transaction asynchronously. Signature: insertAsync: function(self: DB, tableSheets: {{string, string}}, excelFile: string, startRow: integer): boolean Parameters: ParameterTypeDescriptiontableSheets{{string, string}}A list of table names and corresponding sheet names to insert into.excelFilestringThe path to the Excel file containing the data.startRowintegerThe row number to start inserting data from. The row number start with 1. Returns: Return TypeDescriptionbooleanWhether the insert was successful or not. queryAsync Type: Function. Description: Executes an SQL query asynchronously and returns the results as a list of rows. Signature: queryAsync: function( self: DB, sql: string, args: Row, withColumn?: boolean --[[false]] ): {Row} | nil Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute.argsRow[optional] A list of values to substitute into the SQL statement.withColumnboolean[optional] Whether to include column names in the result (default false). Returns: Return TypeDescription{Row} | nilA list of rows returned by the query, or nil if the query failed. queryAsync Type: Function. Description: Executes an SQL query asynchronously and returns the results as a list of rows. Signature: queryAsync: function( self: DB, sql: string, withColumn?: boolean --[[false]] ): {Row} | nil Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute.withColumnboolean[optional] Whether to include column names in the result (default false). Returns: Return TypeDescription{Row} | nilA list of rows returned by the query, or nil if the query failed. execAsync Type: Function. Description: Executes an SQL statement with a list of values within a transaction asynchronously and returns the number of rows affected. Signature: execAsync: function(self: DB, sql: string, values: {Row}): integer Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute.values{Row}A list of values to substitute into the SQL statement. Returns: Return TypeDescriptionintegerThe number of rows affected by the statement, returns -1 if the statement failed. execAsync Type: Function. Description: Executes an SQL statement asynchronously and returns the number of rows affected. Signature: execAsync: function(self: DB, sql: string): integer Parameters: ParameterTypeDescriptionsqlstringThe SQL statement to execute. Returns: Return TypeDescriptionintegerthe number of rows affected by the statement, returns -1 if the statement failed.