Who Calls the Fleet Database

20240308.0.1 · abandoned · verified Wed Apr 22

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import Datastore from '@seald-io/nedb'; // Use @seald-io/nedb for modern Promise API
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

// Determine the path to the database file provided by whocallsthefleet-database
// This path assumes 'whocallsthefleet-database' is installed in node_modules
const dbPath = path.join(__dirname, 'node_modules', 'whocallsthefleet-database', 'db.json');

async function loadAndQueryData() {
  try {
    // Initialize a new Datastore instance, pointing to the data file
    const db = new Datastore({
      filename: dbPath,
      autoload: true // Automatically load the database on creation
    });

    // Wait for the database to be loaded (autoload handles this implicitly, but explicit wait is good practice for persistence setup)
    // If not using autoload, you would call await db.loadDatabaseAsync();

    console.log('Database loaded from:', dbPath);

    // Example: Find all documents in the database
    const allDocs = await db.findAsync({});
    console.log(`Found ${allDocs.length} documents.`);

    // Example: Find documents matching a specific criteria (e.g., a 'name' field, assuming data structure)
    // Note: The actual fields depend on the 'Who Calls the Fleet' data schema.
    // This is a placeholder example.
    const exampleDoc = await db.findOneAsync({ 'id': 'some_kancolle_id' }); // Replace with actual query
    if (exampleDoc) {
      console.log('Example document found:', exampleDoc);
    } else {
      console.log('No document found with example ID.');
    }

    // You can also count documents
    const count = await db.countAsync({});
    console.log(`Total documents (counted): ${count}`);

  } catch (error) {
    console.error('Error interacting with the database:', error);
  }
}

loadAndQueryData();

view raw JSON →