change signature in typings for loadDatabase

2.x.x
Timothée Rebours 3 years ago
parent 750f6b7095
commit 8ce18469b9
  1. 4
      CHANGELOG.md
  2. 2
      index.d.ts
  3. 6
      typings-tests.ts

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [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 ## [2.2.1] - 2022-01-18
### Changed ### Changed
- [#20](https://github.com/seald/nedb/pull/20) storage.js: check fsync capability from return code rather than using process.platform heuristics (Thanks [@bitmeal](https://github.com/bitmeal)). - [#20](https://github.com/seald/nedb/pull/20) storage.js: check fsync capability from return code rather than using process.platform heuristics (Thanks [@bitmeal](https://github.com/bitmeal)).

2
index.d.ts vendored

@ -17,7 +17,7 @@ declare class Nedb<G = any> extends EventEmitter {
persistence: Nedb.Persistence; persistence: Nedb.Persistence;
loadDatabase(): void; loadDatabase(callback?: (err: Error | null) => void): void;
getAllData<T extends G>(): T[]; getAllData<T extends G>(): T[];

@ -16,6 +16,12 @@ let db = new Datastore()
db = new Datastore({ filename: 'path/to/datafile' }) db = new Datastore({ filename: 'path/to/datafile' })
db.loadDatabase() 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 // Type 3: Persistent datastore with automatic loading
db = new Datastore({ filename: 'path/to/datafile_2', autoload: true }) db = new Datastore({ filename: 'path/to/datafile_2', autoload: true })
// You can issue commands right away // You can issue commands right away

Loading…
Cancel
Save