Database Actions
os.eraseDatabase(recordName: string, address: string, options: RecordActionOptions): Promise<CrudRecordItemResult>
Deletes a database along with all the data in it.
Returns a promise that resolves with the result of the operation.
The first parameter is a string and is the name of the record to delete the database from.
The second parameter is a string and is the address of the database to delete.
The third parameter is a RecordActionOptions and is the options for the request.
Examples
Erase a databaseconst result = await os.eraseDatabase('recordName', 'myDatabase');os.listDatabases(recordName: string, startingAddress?: string, options: ListDataOptions): Promise<CrudListItemsResult>
Lists the databases in a record.
Returns a promise that resolves with the result of the operation.
The first parameter is a string and is the name of the record to delete the search collection from.
The second parameter is optional and is a string and is the address that the listing should start after.
The third parameter is a ListDataOptions and is the options for the request.
Examples
List databasesconst result = await os.listDatabases('recordName', 'myDatabase');os.getDatabase(recordName: string, address: string, options: RecordActionOptions): Database
Gets basic info about a database from the specified record.
The first parameter is a string and is the name of the record to retrieve the database from.
The second parameter is a string and is the address of the database to retrieve.
The third parameter is a RecordActionOptions and is the options for the request.
Examples
Get a database and query a tableconst db = os.getDatabase('myRecord', 'myDatabase');
const result = await db.query`SELECT * FROM myTable`;Insert a new rowconst value1 = 'abc';
const value2 = 123;
const result = await db.execute`INSERT INTO myTable (column1, column2) VALUES (${value1}, ${value2})`;Run multiple queries in a transactionconst values = [
['apple', 10],
['car', 25000],
['strawberry', 1],
['lego', 5]
];
const result = await db.batch(
values.map(([name, value]) => db.sql`INSERT INTO data (name, value) VALUES (${name}, ${value})`)
);os.listDatabasesByMarker(recordName: string, marker: string, startingAddress?: string, options: ListDataOptions): Promise<CrudListItemsResult>
Lists the databases in a record by a specific marker.
The first parameter is a string and is the name of the record to list the databases from.
The second parameter is a string and is the marker to filter the list by.
The third parameter is optional and is a string and is the address that the listing should start after.
The fourth parameter is a ListDataOptions and is the options for the request.
Examples
List public read databasesconst result = await os.listDatabasesByMarker('recordName', 'publicRead');List private databasesconst result = await os.listDatabasesByMarker('recordName', 'private');os.recordDatabase(request: RecordSearchCollectionRequest, options: RecordActionOptions): Promise<CrudRecordItemResult>
Creates or updates a database in the given record.
Databases are used to store and manage structured data within a record. They use the SQL programming language, which is a powerful programming language designed to manage relational databases.
Returns a promise that resolves with the result of the operation.
The first parameter is a RecordSearchCollectionRequest and is the request to create or update the database.
The second parameter is a RecordActionOptions and is the options for the request.
Examples
Record a database.const result = await os.recordDatabase({
recordName: 'myRecord',
address: 'myDatabase',
});Record a private databaseconst result = await os.recordDatabase({
recordName: 'myRecord',
address: 'myDatabase',
markers: ['private']
});