gatelogue-types
    Preparing search index...

    gatelogue-types

    JS utility library for using Gatelogue data in JS/TS projects. It will load the database for you to access via ORM or raw SQL.

    Installation

    The data can be imported into your JavaScript/TypeScript project with classes and type definitions.

    • retrieving from npmjs.com:
      • npm: npm i gatelogue-types
      • yarn: yarn add gatelogue-types
      • pnpm: pnpm add gatelogue-types
      • denoL deno add npm:gatelogue-types
      • bun: bun add gatelogue-types
    • retrieving from jsr.io:
      • npm: npx jsr add @mrt-map/gatelogue-types
      • yarn: yarn add jsr:@mrt-map/gatelogue-types
      • pnpm: pnpm i jsr:@mrt-map/gatelogue-types
      • deno: deno add jsr:@mrt-map/gatelogue-types
      • bun: bunx jsr add @mrt-map/gatelogue-types

    To import directly from the repository:

    • npm: npm i 'https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'
    • yarn: yarn add 'https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'
    • pnpm: pnpm add mrt-map/gatelogue#path:/gatelogue-types-ts
    • bun: bun add 'git+https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'

    Usage

    To retrieve the data:

    import { GD } from "gatelogue-types";
    const gd = await GD.get() // retrieve data, no sources
    const gd = await GD.get(true) // retrieve data, with sources

    Using the ORM does not require SQL and makes for generally clean code. However, doing this is very inefficient as each attribute access is one SQL query.

    for (const airport of gd.airAirports) {
    for (const gate of airport.gates) {
    console.log(`Airport ${airport.code} has gate ${gate.code}`);
    }
    }

    Querying the underlying SQLite database directly with sql.js is generally more efficient and faster. It is also the only way to access the *Source tables, if you retrieved the database with those.

    for (const [airportCode, gateCode] of gd.execGetMany<[string, string]>(
    "SELECT A.code, G.code FROM AirGate G INNER JOIN AirAirport A ON G.airport = A.i")
    ) {
    console.log(`Airport ${airportCode} has gate ${gateCode}`);
    }

    Classes

    AirAirline
    AirAirport
    Aircraft
    AirFlight
    AirGate
    BusBerth
    BusCompany
    BusConnection
    BusLine
    BusStop
    GD
    LocatedNode
    Node
    Proximity
    RailCompany
    RailConnection
    RailLine
    RailPlatform
    RailStation
    SeaCompany
    SeaConnection
    SeaDock
    SeaLine
    SeaStop
    SpawnWarp
    Town

    Type Aliases

    AirMode
    BusMode
    ID
    RailMode
    Rank
    SeaMode
    WarpType
    World