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 (constairportofgd.airAirports) { for (constgateofairport.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] ofgd.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}`); }
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.
npm i gatelogue-typesyarn add gatelogue-typespnpm add gatelogue-typesdeno add npm:gatelogue-typesbun add gatelogue-typesnpx jsr add @mrt-map/gatelogue-typesyarn add jsr:@mrt-map/gatelogue-typespnpm i jsr:@mrt-map/gatelogue-typesdeno add jsr:@mrt-map/gatelogue-typesbunx jsr add @mrt-map/gatelogue-typesTo import directly from the repository:
npm i 'https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'yarn add 'https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'pnpm add mrt-map/gatelogue#path:/gatelogue-types-tsbun add 'git+https://gitpkg.vercel.app/mrt-map/gatelogue/gatelogue-types-ts?main'Usage
To retrieve the data:
Example
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.
Querying the underlying SQLite database directly with
sql.jsis generally more efficient and faster. It is also the only way to access the*Sourcetables, if you retrieved the database with those.