Type Alias: StartOptions\

typescript
1
StartOptions\
<`T`\>
: object
Represents a RIDB (Rust IndexedDB) instance. This is the main class exposed by the RIDB Storage sdk and is used to create a database instance.
### Usage:
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const db = new RIDB(
{
schemas: {
demo: {
version: 0,
primaryKey: 'id',
type: SchemaFieldType.object,
properties: {
id: {
type: SchemaFieldType.string,
maxLength: 60
}
}
}
} as const
}
)

Starting the database

typescript
1
await db.start({dbName: "demo"})

Using with encryption plugin

You can also optionally specify storageType with a compatible storage of your choice and an optional password to enable encryption plugin
typescript
1
2
3
4
await db.start({
password: "my-password"
db
})
A compatible storage should be a class implementing [StorageInternal
](/ridb/docs/type-aliases/../_media/StorageInternal.md) and its methods.

Using with migration plugin

The migration plugin will automatically migrate your documents for you as you upgrade and change your schemas over the time.
typescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const db = new RIDB(
{
schemas: {
demo: {
version: 1,
primaryKey: 'id',
type: SchemaFieldType.object,
required:['id', 'age'],
properties: {
id: {
type: SchemaFieldType.string,
maxLength: 60
},
age: {
type: SchemaFieldType.number,
}
}
}
} as const,
migrations: {
demo: {
1: function (doc) {
return doc
}
}
}
}
)
await db.start({dbName: "demo"})

Type Parameters

T extends RIDBTypes.SchemaTypeRecord
The type of the schema record.

Type declaration

Index Signature

[name: string]: any

password?

typescript
1
optional password: string

storageType?

typescript
1
optional storageType: typeof RIDBTypes.BaseStorage | StorageType

Defined in