[cherry-picked from 2.x.x] change signature in typings for loadDatabase

pull/27/head
Timothée Rebours 3 years ago
parent 6708541c72
commit ac3f412baa
  1. 6
      CHANGELOG.md
  2. 2
      index.d.ts
  3. 6
      typings-tests.ts

@ -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

2
index.d.ts vendored

@ -20,7 +20,7 @@ declare class Nedb<G = any> extends EventEmitter {
autoloadPromise: Promise<void>|null;
loadDatabase(): void;
loadDatabase(callback?: (err: Error | null) => void): void;
loadDatabaseAsync(): Promise<void>;

@ -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

Loading…
Cancel
Save