@types/lowdb
- Version 1.0.15
- Published
- 13.1 kB
- 1 dependency
- MIT license
Install
npm i @types/lowdb
yarn add @types/lowdb
pnpm add @types/lowdb
Overview
TypeScript definitions for lowdb
Index
Variables
Interfaces
Variables
variable Lowdb
let Lowdb: Lowdb.lowdb;
Interfaces
interface AdapterAsync
interface AdapterAsync<SchemaT = any> extends BaseAdapter<SchemaT> {}
method write
write: (state: object) => Promise<void>;
construct signature
new <SchemaT = any>( source: string, options?: AdapterOptions<SchemaT>): AdapterAsync<SchemaT>;
interface AdapterOptions
interface AdapterOptions<SchemaT = any> {}
property defaultValue
defaultValue?: SchemaT | undefined;
property deserialize
deserialize?: ((serializedData: string) => SchemaT) | undefined;
property serialize
serialize?: ((data: SchemaT) => string) | undefined;
interface AdapterSync
interface AdapterSync<SchemaT = any> extends BaseAdapter<SchemaT> {}
method write
write: (state: object) => void;
construct signature
new <SchemaT = any>( source: string, options?: AdapterOptions<SchemaT>): AdapterSync<SchemaT>;
interface BaseAdapter
interface BaseAdapter<SchemaT = any> extends AdapterOptions<SchemaT> {}
property "@@reference"
readonly '@@reference': SchemaT;
property source
source: string;
construct signature
new <SchemaT = any>( source: string, options?: AdapterOptions<SchemaT>): BaseAdapter<SchemaT>;
interface FpReturnAsync
interface FpReturnAsync<PathT> extends FpReturnBase<PathT> {}
method write
write: <R1 extends PathT>(f1: (a1: PathT) => R1) => Promise<R1>;
Writes the change to the database, based on the callback's return value.
Example 1
posts.write((allPosts) => [...allPosts, {title: 'Yup!'}])
interface FpReturnBase
interface FpReturnBase<PathT> {}
call signature
<R1>(f1: (a1: PathT) => R1): R1;
Execute a series of functions on the data at a given path. Result of previous function is the input of the next one. Returns the result of the last function.
call signature
<R1, R2>(f1: [(a1: PathT) => R1, (a: R1) => R2]): R2;
call signature
<R1, R2, R3>(f1: [(a1: PathT) => R1, (a: R1) => R2, (a: R2) => R3]): R3;
call signature
<R1, R2, R3, R4>( f1: [(a1: PathT) => R1, (a: R1) => R2, (a: R2) => R3, (a: R3) => R4]): R4;
call signature
<R1, R2, R3, R4, R5>( f1: [ (a1: PathT) => R1, (a: R1) => R2, (a: R2) => R3, (a: R3) => R4, (a: R4) => R5 ]): R5;
call signature
<R1, R2, R3, R4, R5, R6>( f1: [ (a1: PathT) => R1, (a: R1) => R2, (a: R2) => R3, (a: R3) => R4, (a: R4) => R5, (a: R5) => R6 ]): R6;
call signature
<R1, R2, R3, R4, R5, R6, R7>( f1: [ (a1: PathT) => R1, (a: R1) => R2, (a: R2) => R3, (a: R3) => R4, (a: R4) => R5, (a: R5) => R6, (a: R6) => R7 ]): R7;
call signature
(funcs: Array<(a: any) => any>): any;
interface FpReturnSync
interface FpReturnSync<PathT> extends FpReturnBase<PathT> {}
method write
write: <R1 extends PathT>(f1: (a1: PathT) => R1) => R1;
Writes the change to the database, based on the callback's return value.
Example 1
posts.write((allPosts) => [...allPosts, {title: 'Yup!'}])
interface lowdb
interface lowdb {}
call signature
<AdapterT extends AdapterAsync>(adapter: AdapterT): Promise< LowdbAsync<AdapterT[ReferenceProperty]>>;
call signature
<AdapterT extends AdapterSync>(adapter: AdapterT): LowdbSync< AdapterT[ReferenceProperty]>;
interface LowdbAsync
interface LowdbAsync<SchemaT> extends LowdbBase<SchemaT>, ObjectChain<SchemaT> {}
interface LowdbBase
interface LowdbBase<SchemaT> {}
interface lowdbFp
interface lowdbFp {}
call signature
<AdapterT extends AdapterAsync>(adapter: AdapterT): Promise< LowdbFpAsync<AdapterT[ReferenceProperty]>>;
call signature
<AdapterT extends AdapterSync>(adapter: AdapterT): LowdbFpSync< AdapterT[ReferenceProperty]>;
interface LowdbFpAsync
interface LowdbFpAsync<SchemaT> extends LowdbBase<SchemaT> {}
method write
write: <T = void>(returnValue?: T) => Promise<T>;
Be careful: This function overwrites the whole database.
call signature
<TKey extends keyof SchemaT>( path: TKey | [TKey], defaultValue?: SchemaT[TKey]): FpReturnAsync<SchemaT[TKey]>;
Returns a function that allows you to access/modify the database at a given path.
Example 1
const posts = db('posts')const firstPost = posts(all => all[0])posts.write((allPosts) => [...allPosts, {title: 'Yup!'}])
call signature
<TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey]>( path: [TKey, TSubKey], defaultValue?: SchemaT[TKey][TSubKey]): FpReturnAsync<SchemaT[TKey][TSubKey]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey]>( path: [TKey, TSubKey, TSubKey2], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2]): FpReturnAsync<SchemaT[TKey][TSubKey][TSubKey2]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey], TSubKey3 extends keyof SchemaT[TKey][TSubKey][TSubKey2]>( path: [TKey, TSubKey, TSubKey2, TSubKey3], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]): FpReturnAsync<SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey], TSubKey3 extends keyof SchemaT[TKey][TSubKey][TSubKey2], TSubKey4 extends keyof SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]>( path: [TKey, TSubKey, TSubKey2, TSubKey3, TSubKey4], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2][TSubKey3][TSubKey4]): FpReturnAsync<SchemaT[TKey][TSubKey][TSubKey2][TSubKey3][TSubKey4]>;
call signature
<T = any>(path: string | string[], defaultValue?: T): FpReturnAsync<T>;
interface LowdbFpSync
interface LowdbFpSync<SchemaT> extends LowdbBase<SchemaT> {}
method write
write: <T = void>(returnValue?: T) => T;
Be careful: This function overwrites the whole database.
call signature
<TKey extends keyof SchemaT>( path: TKey | [TKey], defaultValue?: SchemaT[TKey]): FpReturnSync<SchemaT[TKey]>;
Returns a function that allows you to access/modify the database at a given path.
Example 1
const posts = db('posts')const firstPost = posts(all => all[0])posts.write((allPosts) => [...allPosts, {title: 'Yup!'}])
call signature
<TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey]>( path: [TKey, TSubKey], defaultValue?: SchemaT[TKey][TSubKey]): FpReturnSync<SchemaT[TKey][TSubKey]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey]>( path: [TKey, TSubKey, TSubKey2], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2]): FpReturnSync<SchemaT[TKey][TSubKey][TSubKey2]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey], TSubKey3 extends keyof SchemaT[TKey][TSubKey][TSubKey2]>( path: [TKey, TSubKey, TSubKey2, TSubKey3], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]): FpReturnSync<SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]>;
call signature
< TKey extends keyof SchemaT, TSubKey extends keyof SchemaT[TKey], TSubKey2 extends keyof SchemaT[TKey][TSubKey], TSubKey3 extends keyof SchemaT[TKey][TSubKey][TSubKey2], TSubKey4 extends keyof SchemaT[TKey][TSubKey][TSubKey2][TSubKey3]>( path: [TKey, TSubKey, TSubKey2, TSubKey3, TSubKey4], defaultValue?: SchemaT[TKey][TSubKey][TSubKey2][TSubKey3][TSubKey4]): FpReturnSync<SchemaT[TKey][TSubKey][TSubKey2][TSubKey3][TSubKey4]>;
call signature
<T = any>(path: string | string[], defaultValue?: T): FpReturnSync<T>;
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/lowdb
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/lowdb)
- HTML<a href="https://www.jsdocs.io/package/@types/lowdb"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2743 ms. - Missing or incorrect documentation? Open an issue for this package.