deno.land / x / casualdb@v0.1.4 / mod.ts

View Documentation
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
31
32
33
34
35
36
37
38
39
import get from "https://deno.land/x/lodash@4.17.15-es/get.js";import set from "https://deno.land/x/lodash@4.17.15-es/set.js";
import { Connector, ConnectOptions } from "./connector.ts";import { createNewOperator } from "./operator/utils.ts";
class CasualDB<Schema> { private _connector: Connector<Schema>;
constructor() { this._connector = new Connector(); }
connect(fsPath: string, options?: ConnectOptions): Promise<unknown> { return this._connector.connect(fsPath, options); }
async get<T>(path: string) { const data = await this._connector.read(); const value: T = get(data, path, null);
return createNewOperator<T>(value); }
seed(data: Schema): Promise<unknown> { return this._connector.write(data); }
async write<T>(path: string, value: T) { const data = await this._connector.read(); const updatedData = set(data, path, value); return this._connector.write(updatedData as Schema); }}
export default CasualDB;export { CasualDB };export { PrimitiveOperator, CollectionOperator } from "./operator/operators.ts";
casualdb
Simple JSON "database" for Deno with type-safety! ⚡️
DocumentationDocumentation
GitHub Repositorycampvanilla/casualdb
GitHub Stars
29

Version Info

Tagged at
a year ago