@trust0/ridb
v0.4.5
Published
Dependency free wasm db encrypted and secure database wrapper for web and node.
Downloads
1,655
Readme
Install
In order to install simply run the following command npm:
npm i @elribonazo/ridb --save
yarn:
yarn add @elribonazo/ridb
Usage
Creating your own database is pretty straight forward.
import {
RIDB,
SchemaFieldType
} from '@elribonazo/ridb';
(async () => {
const db = new RIDB({
demo: {
version: 0,
primaryKey: 'id',
type: SchemaFieldType.object,
properties: {
id: {
type: SchemaFieldType.string,
maxLength: 60
}
}
}
});
console.log("Starting the database");
await db.start();
console.log("Ok :)");
})()
Specification
Storage
A valid storage must extend BaseStorage class here's some example:
export class InMemory<T extends SchemaType> extends BaseStorage<T> {
async write(operation:Operation<T>): Promise<Doc<T>> {
if (operation.opType === OpType.CREATE) {
return operation.data;
}
throw new Error("Method not implemented.");
}
query(): Promise<void> {
throw new Error("Method not implemented.");
}
findDocumentById(id: string): Promise<null> {
throw new Error("Method not implemented.");
}
count(): Promise<number> {
throw new Error("Method not implemented.");
}
close(): Promise<void> {
throw new Error("Method not implemented.");
}
}