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

seql

v0.0.1

Published

Easy cross-platform sql database querying and migration

Downloads

5

Readme

Important: Database migrations are not yet implemented as I am looking for a good solution, if you have any ideas please do share :)

Seql

SQL can get pretty tricky, there are different dialects to consider, different features to know about, these problems inevitably spawn many projects each trying to fix a different problem. Seql aims to combine some of the best packages out there to make using a SQL database much more painless.

Seql was also written with ES7 in mind, and also literally written in ES6. All asynchronous operations are promise based and the module is exported with ES6 consumers in mind. If you don't know ES6/7 see the Babel reference page. If you are using ES5 and are confused on how to get this module to work, read the "Dear ES5 User" note.

Usage

Querying

import Seql from 'seql';

let db = new Seql('sqlite://db.sqlite');

let Person = db.define({
  name: 'person',
  columns: ['id', 'givenName', 'familyName', 'email']
});

let person = {
  givenName: 'Sara',
  familyName: 'Smith',
  email: '[email protected]'
};

Person.insert(person).exec()
.catch(error => console.error(error.stack))
.then(() => console.log('done!'));

Seql extends the sql module, so see that repository for more details on the querying syntax. Notable differences include new Seql(...) and the .exec() function.

Streaming

let stream = Person.select(person).stream();

stream.on('data', row => console.log(row));

The .stream() method returns a readable stream in object mode for your consumption.

API

new Database(connectionConfig)

Returns a new database instance which extends the sql package's Sql function, thus it shares all of the same methods such as .define(). One notable difference is that the .setDialect() method is disabled, this is because the dialect should be immutable, defined in the connectionConfig parameter and never changed.

  • connectionConfig: A connection object or a url string. Whatever the value it is directly passed to the driver which will parse it. The dialect must be defined somewhere in the config. If it is a url string, the dialect must be the protocol, e.g. mysql://.... If it is an object, a dialect property must be set, e.g. { dialect: 'postgres' }. For more information on what information should be included in this value, take a look at your specific driver's documentation.

Database#executeQuery(query)

Executes a query from the sql package.

Database#streamQuery(query)

Streams a query from the sql package.

Node#executeQuery() || Node#exec()

Seql extends the sql package's API and adds this method which is just a shortcut for Database#executeQuery(query) where the query parameter is the node.

Node#streamQuery() || Node#stream()

Ditto except it shortcuts Database#streamQuery(query).

Supports:

Want support for more databases? Submit a pull request! Mysql and Postgres are on Caleb's TODO list, if you want these drivers faster, either start an issue thread or add them yourself using the src/driver/sqlite.js file as your base.

Behind the curtain

Currently Seql is using the awesome sql module as its base for building queries, on top of that Seql adds two methods to the Node function's prototype: exec and stream. In the src/driver folder is the implementation for these methods.

Dear ES5 User:

To use Seql with the CommonJS API, do the following:

var Seql = require('seql').Seql;

Also, this module uses promises instead of the traditional callbacks.