diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c07b8..e1b27a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - The option for passing `options.nodeWebkitAppName` to the Datastore and the Persistence constructors has been removed, subsequently, the static method `Persistence.getNWAppFilename` has been removed as well; - Compatibility with node < 10.1.0 (we use `fs.promises`). +## Fixed +- \[cherry picked from 2.2.2\] [#21](https://github.com/seald/nedb/issues/21) Typings for loadDatabase now support a callback. + +## [2.2.2] - 2022-03-10 +### Fixed +- [#21](https://github.com/seald/nedb/issues/21) Typings for loadDatabase now support a callback. ## [2.2.1] - 2022-01-18 ### Changed diff --git a/index.d.ts b/index.d.ts index 7cba2bb..1512156 100644 --- a/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ declare class Nedb extends EventEmitter { autoloadPromise: Promise|null; - loadDatabase(): void; + loadDatabase(callback?: (err: Error | null) => void): void; loadDatabaseAsync(): Promise; diff --git a/typings-tests.ts b/typings-tests.ts index ed98aa9..7d3b574 100644 --- a/typings-tests.ts +++ b/typings-tests.ts @@ -16,6 +16,12 @@ let db = new Datastore() db = new Datastore({ filename: 'path/to/datafile' }) db.loadDatabase() +// Type 2 bis: Persistent datastore with manual loading with a callback +db = new Datastore({ filename: 'path/to/datafile' }) +db.loadDatabase((err: Error | null) => { + // should not fail +}) + // Type 3: Persistent datastore with automatic loading db = new Datastore({ filename: 'path/to/datafile_2', autoload: true }) // You can issue commands right away