Format index.d.ts

pull/30/head
Pierre de la Martiniere 2 years ago committed by Timothée Rebours
parent 1daad3379e
commit 0faabdd5b8
  1. 99
      index.d.ts

99
index.d.ts vendored

@ -9,7 +9,7 @@
/// <reference types="node" /> /// <reference types="node" />
import { EventEmitter } from 'events'; import { EventEmitter } from "events";
export default Nedb; export default Nedb;
@ -18,17 +18,17 @@ declare class Nedb<G = any> extends EventEmitter {
persistence: Nedb.Persistence; persistence: Nedb.Persistence;
autoloadPromise: Promise<void>|null; autoloadPromise: Promise<void> | null;
loadDatabase(callback?: (err: Error | null) => void): void; loadDatabase(callback?: (err: Error | null) => void): void;
loadDatabaseAsync(): Promise<void>; loadDatabaseAsync(): Promise<void>;
dropDatabase(callback?: (err: Error |null) => void): void; dropDatabase(callback?: (err: Error | null) => void): void;
dropDatabaseAsync(): Promise<void>; dropDatabaseAsync(): Promise<void>;
compactDatafile(callback?: (err: Error |null) => void): void; compactDatafile(callback?: (err: Error | null) => void): void;
compactDatafileAsync(): Promise<void>; compactDatafileAsync(): Promise<void>;
@ -38,7 +38,10 @@ declare class Nedb<G = any> extends EventEmitter {
getAllData<T extends G>(): T[]; getAllData<T extends G>(): T[];
ensureIndex(options: Nedb.EnsureIndexOptions, callback?: (err: Error | null) => void): void; ensureIndex(
options: Nedb.EnsureIndexOptions,
callback?: (err: Error | null) => void
): void;
ensureIndexAsync(options: Nedb.EnsureIndexOptions): Promise<void>; ensureIndexAsync(options: Nedb.EnsureIndexOptions): Promise<void>;
@ -46,8 +49,14 @@ declare class Nedb<G = any> extends EventEmitter {
removeIndexAsync(fieldName: string | string[]): Promise<void>; removeIndexAsync(fieldName: string | string[]): Promise<void>;
insert<T extends G>(newDoc: T, callback?: (err: Error | null, document: T) => void): void; insert<T extends G>(
insert<T extends G>(newDocs: T[], callback?: (err: Error | null, documents: T[]) => void): void; newDoc: T,
callback?: (err: Error | null, document: T) => void
): void;
insert<T extends G>(
newDocs: T[],
callback?: (err: Error | null, documents: T[]) => void
): void;
insertAsync<T extends G>(newDoc: T): Promise<T>; insertAsync<T extends G>(newDoc: T): Promise<T>;
insertAsync<T extends G>(newDocs: T[]): Promise<T[]>; insertAsync<T extends G>(newDocs: T[]): Promise<T[]>;
@ -57,36 +66,72 @@ declare class Nedb<G = any> extends EventEmitter {
countAsync(query: any): Nedb.Cursor<number>; countAsync(query: any): Nedb.Cursor<number>;
find<T extends G>(query: any, projection: any, callback?: (err: Error | null, documents: T[]) => void): void; find<T extends G>(
query: any,
projection: any,
callback?: (err: Error | null, documents: T[]) => void
): void;
find<T extends G>(query: any, projection?: any): Nedb.Cursor<T>; find<T extends G>(query: any, projection?: any): Nedb.Cursor<T>;
find<T extends G>(query: any, callback: (err: Error | null, documents: T[]) => void): void; find<T extends G>(
query: any,
callback: (err: Error | null, documents: T[]) => void
): void;
findAsync<T extends G>(query: any, projection?: any): Nedb.Cursor<T[]>; findAsync<T extends G>(query: any, projection?: any): Nedb.Cursor<T[]>;
findOne<T extends G>(query: any, projection: any, callback: (err: Error | null, document: T) => void): void; findOne<T extends G>(
findOne<T extends G>(query: any, callback: (err: Error | null, document: T) => void): void; query: any,
projection: any,
callback: (err: Error | null, document: T) => void
): void;
findOne<T extends G>(
query: any,
callback: (err: Error | null, document: T) => void
): void;
findOneAsync<T extends G>(query: any, projection?: any): Nedb.Cursor<T>; findOneAsync<T extends G>(query: any, projection?: any): Nedb.Cursor<T>;
update<T extends G>(query: any, updateQuery: any, options?: Nedb.UpdateOptions, callback?: (err: Error | null, numberOfUpdated: number, affectedDocuments: T | T[] | null, upsert: boolean | null) => void): void; update<T extends G>(
query: any,
updateAsync<T extends G>(query: any, updateQuery: any, options?: Nedb.UpdateOptions): Promise<{numAffected: number, affectedDocuments: T|T[]|null, upsert: boolean}>; updateQuery: any,
options?: Nedb.UpdateOptions,
remove(query: any, options: Nedb.RemoveOptions, callback?: (err: Error | null, n: number) => void): void; callback?: (
err: Error | null,
numberOfUpdated: number,
affectedDocuments: T | T[] | null,
upsert: boolean | null
) => void
): void;
updateAsync<T extends G>(
query: any,
updateQuery: any,
options?: Nedb.UpdateOptions
): Promise<{
numAffected: number;
affectedDocuments: T | T[] | null;
upsert: boolean;
}>;
remove(
query: any,
options: Nedb.RemoveOptions,
callback?: (err: Error | null, n: number) => void
): void;
remove(query: any, callback?: (err: Error | null, n: number) => void): void; remove(query: any, callback?: (err: Error | null, n: number) => void): void;
removeAsync(query: any, options: Nedb.RemoveOptions): Promise<number>; removeAsync(query: any, options: Nedb.RemoveOptions): Promise<number>;
addListener(event: 'compaction.done', listener: () => void): this; addListener(event: "compaction.done", listener: () => void): this;
on(event: 'compaction.done', listener: () => void): this; on(event: "compaction.done", listener: () => void): this;
once(event: 'compaction.done', listener: () => void): this; once(event: "compaction.done", listener: () => void): this;
prependListener(event: 'compaction.done', listener: () => void): this; prependListener(event: "compaction.done", listener: () => void): this;
prependOnceListener(event: 'compaction.done', listener: () => void): this; prependOnceListener(event: "compaction.done", listener: () => void): this;
removeListener(event: 'compaction.done', listener: () => void): this; removeListener(event: "compaction.done", listener: () => void): this;
off(event: 'compaction.done', listener: () => void): this; off(event: "compaction.done", listener: () => void): this;
listeners(event: 'compaction.done'): Array<() => void>; listeners(event: "compaction.done"): Array<() => void>;
rawListeners(event: 'compaction.done'): Array<() => void>; rawListeners(event: "compaction.done"): Array<() => void>;
listenerCount(type: 'compaction.done'): number; listenerCount(type: "compaction.done"): number;
} }
declare namespace Nedb { declare namespace Nedb {
@ -113,7 +158,7 @@ declare namespace Nedb {
afterSerialization?(line: string): string; afterSerialization?(line: string): string;
corruptAlertThreshold?: number; corruptAlertThreshold?: number;
compareStrings?(a: string, b: string): number; compareStrings?(a: string, b: string): number;
modes?: {fileMode: number, dirMode: number}; modes?: { fileMode: number; dirMode: number };
testSerializationHooks?: boolean; testSerializationHooks?: boolean;
} }

Loading…
Cancel
Save