SpriteServer.openDatabase
Interface
(databaseName: string)
When you āopenā a database in ArcadeDB, it means youāre creating an instance of the database in memory, allocating resources, and making the database available for operations. Hereās what happens when you open a database:
- Create a new database instance: A new database instance is created in memory, which includes the databaseās metadata, schema, and cached data. This instance is used to manage the databaseās resources and provide access to the data.
- Allocate resources: The database instance allocates the necessary resources, such as memory, threads, and file handles, to support the databaseās operations. This ensures that the database has the necessary resources to handle incoming requests.
- Load database metadata and schema: The databaseās metadata and schema are loaded into memory, which includes information about the databaseās structure, indexes, and relationships.
- Connect to the underlying storage: The database instance establishes a connection to the underlying storage, such as disk storage, to access the database files.
- Make the database available for operations: The database is now available for users to perform operations, such as executing queries, creating new records, or modifying existing data.
Example
const server = new SpriteServer({
username: 'aUser',
password: 'aPassword',
address: 'http://localhost:2480',
});
async function openDatabaseExample(databaseName: string) {
try {
const open = await server.openDatabase(databaseName);
console.log(open);
// true
} catch (error) {
// handle errors
console.error(error);
}
};
openDatabaseExample('aDatabase');