The `whocallsthefleet-database` package provides a dataset specifically structured as an embedded NeDB database for the 'Who Calls the Fleet' project (https://fleet.moe), which focuses on Kantai Collection game data. NeDB is a lightweight, embedded document-oriented database written in JavaScript, offering a subset of MongoDB's API for querying. It is designed for small-scale applications, capable of operating in-memory or persisting data to a local file. The current version of this data package is `20240308.0.1`. The original NeDB project by louischatriot is considered abandoned, with development ceasing around 2017, although forks like `@seald-io/nedb` continue active maintenance and introduce modern JavaScript features like Promises. This package's primary differentiator is its specific dataset content for 'Who Calls the Fleet', using NeDB for local, file-based storage without requiring a separate database server. It is ideal for desktop applications (Electron, nw.js) or small Node.js services requiring a local, non-concurrent data store.
npm install whocallsthefleet-databaseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load the `whocallsthefleet-database` data files using `@seald-io/nedb` and perform basic query operations. It initializes a `Datastore` instance, loads the data automatically, and then fetches and logs documents.
Users should be aware that future compatibility issues or bugs related to the package's structure might not be addressed. Consider extracting the underlying JSON data for custom processing if long-term stability or active development is crucial.
Install `@seald-io/nedb` instead of `nedb` and update your import statements: `import Datastore from '@seald-io/nedb';`.
For concurrent access, multi-user applications, or large datasets, consider migrating to a dedicated database solution like MongoDB (due to API similarity) or PostgreSQL. For single-process, local data storage, ensure only one instance accesses the database file at a time.
If file size becomes a concern, especially after numerous updates/deletes, ensure your application reloads the database periodically or explicitly calls `db.persistence.compactDatafile()` (or `db.compactDatafileAsync()` in `@seald-io/nedb`) to compact the data file. Note that manual compaction requires pausing other operations.
Ensure the `filename` option points to a valid path for the NeDB data file (e.g., `path.join(__dirname, 'node_modules', 'whocallsthefleet-database', 'db.json')`) and that `autoload: true` is set, or explicitly call and `await db.loadDatabaseAsync()` before performing any operations.
Avoid calling `loadDatabaseAsync()` multiple times. If `autoload: true` is used in the constructor, the database loads once, and subsequent calls are unnecessary. For programmatic control, initialize the `Datastore` once and then use its methods without re-loading.
Before inserting, check if a document with the conflicting unique field value already exists. Alternatively, handle the error gracefully or remove the unique constraint if it's not strictly required for your data model. Ensure your `ensureIndexAsync` calls correctly define unique constraints.