Class: Database<T>
Defined in: ridb_core.d.ts:637
Represents a database containing collections of documents. RIDB extends from this class and is used to expose collections.
So if you specify:
typescript1234567891011121314151617const db = new RIDB({schemas: {demo: {version: 0,primaryKey: 'id',type: SchemaFieldType.object,properties: {id: {type: SchemaFieldType.string,maxLength: 60}}}} as const})
The collection will be available as db.collections.demo
and all the methods for the collection (find, count, findById, update, create, delete) will be available.
Type Parameters
T
T
extends SchemaTypeRecord
A record of schema types.
Constructors
Constructor
new Database<T>(): Database<T>
Returns
Database
<T
>
Properties
collections
readonly collections: { [name in string | number | symbol]: Collection<Schema<T[name]>> }
Defined in: ridb_core.d.ts:667
The collections in the database.
This is a read-only property where the key is the name of the collection and the value is a Collection
instance.
started
readonly started: boolean
Defined in: ridb_core.d.ts:671
Methods
authenticate()
authenticate(password): Promise<boolean>
Defined in: ridb_core.d.ts:660
Parameters
password
string
Returns
Promise
<boolean
>
close()
close(): Promise<void>
Defined in: ridb_core.d.ts:685
Closes the database.
Returns
Promise
<void
>
A promise that resolves when the database is closed.
start()
start(): Promise<void>
Defined in: ridb_core.d.ts:678
Starts the database.
Returns
Promise
<void
>
A promise that resolves when the database is started.
create()
static create<TS>(db_name, schemas, migrations, plugins, options, password?, storage?): Promise<Database<TS>>
Defined in: ridb_core.d.ts:650
Creates a new Database
instance with the provided schemas and storage module.
Type Parameters
TS
TS
extends SchemaTypeRecord
A record of schema types.
Parameters
db_name
string
schemas
TS
The schemas to use for the collections.
migrations
MigrationPathsForSchemas
<TS
> | MigrationPathsForSchema
<TS
[string
]>
plugins
typeof BasePlugin
[]
options
password?
string
storage?
BaseStorage
<TS
>
Returns
Promise
<Database
<TS
>>
A promise that resolves to the created Database
instance.