npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gtfs-sequelize

v3.0.1

Published

A model for the static GTFS using sequelize.

Downloads

47

Readme

gtfs-sequelize

npm version Build Status Dependency Status Test Coverage

A model of the static GTFS using sequelize.js.

Currently works only with PostgreSQL (including PostGIS), MySQL (with spatial capabilities) and sqlite (but NOT spatialite).

Table of Contents

Installation

In order to use this library, you must also install the additional libraries in your project depending on the database that you use.

PostgreSQL

npm install pg --save
npm install pg-copy-streams --save
npm install pg-query-stream --save
npm install pg-hstore --save

With pg and node v0.10.x

You must also install the package promise-polyfill and write additional code. See here for more details.

MySQL

npm install mysql --save
npm install streamsql --save

SQLite

npm install sqlite3 --save
npm install streamsql --save

Usage with SQLite requires that sqlite is installed and is available via a unix command line.

API:

GTFS(options)

Create a new GTFS API.

Example:

var GTFS = require('gtfs-sequelize');

var pgConfig = {
  database: 'postgres://gtfs_sequelize:gtfs_sequelize@localhost:5432/gtfs-sequelize-test',
  downloadsDir: 'downloads',
  gtfsFileOrFolder: 'google_transit.zip',
  spatial: true,
  sequelizeOptions: {
    logging: false
  }
}

var gtfs = GTFS(pgConfig);
gtfs.loadGtfs(function() {
  //database loading has finished callback
});

options

| Key | Value | | -- | -- | | database | A database connection string. You must specify a user and a database in your connection string. The database must already exist, but the tables within the db do not need to exist. | | downloadsDir | The directory where you want the feed zip fils downloaded to or where you're going to read the feed read from. | | gtfsFileOrFolder | The (zip) file or folder to load the gtfs from | | interpolateStopTimes | Default is undefined. If true, after loading the stop_times table, all stop_times with undefined arrival and departure times will be updated to include interpolated arrival and departure times. | | sequelizeOptions | Options to pass to sequelize. Note: to use a specific schema you'll want to pass something like this: { schema: 'your_schema' } | | spatial | Default is undefined. If true, spatial tables for the shapes and stops will be created. |

gtfs.connectToDatabase()

Return a sequelize api of the database.

Example:

var db = gtfs.connectToDatabase()

db.stop.findAll()
  .then(stops => {
    console.log(stops)
  })

gtfs.downloadGtfs(callback)

If a url is provided, the feed will be attempted to be downloaded. Works with http, https and ftp.

gtfs.interpolateStopTimes(callback)

Interpolate stop_times with undefined arrival and departure times. If you load a gtfs with the interpolateStopTimes flag set to true, you don't need to call this.

gtfs.loadGtfs(callback)

Load the gtfs into the database.