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

protolus-data

v0.0.5-alpha

Published

A multi source ORM supporting normalized queries across many instances of datasources

Downloads

5

Readme

protolus-data.js

A Node.js data layer supporting a variety of data sources using a single SQL based query syntax

Usage

Datasources are registered by creating an entry in the configuration

Let's say you want to create a class to represent alien invaders (in this case Red 'Lectroids) containing a few fields('ganglia_state', 'institutionalized', 'ship_completeness', 'origin_dimension'), you'd name your file based on your classname in the 'Classes' directory, such as 'RedLectroid.js'.

an example looks like:

new Class({
    Extends : Data,
    initialize : function(options){
        //if options comes in as a string, we assume it's the key we're selecting (AKA 'id')
        if(typeOf(options) == 'string') options = {key:options};
        if(!options) options = {};
        //link this to a particular datasource (defined in your configuration)
        options.datasource = 'myAwesomeDatasource';
        //this is the storage location for this object (think table or collection name)
        options.name = 'red_lectroid';
        this.fields = [
            'ganglia_state',
            'institutionalized',
            'ship_completeness',
            'origin_dimension'
        ];
        this.primaryKey = 'id';
        this.parent(options);
        if(options.key) this.load(options.key);
    }
});

You would use this class like this:

var DrEmilioLizardo = new RedLectroid();
DrEmilioLizardo.set('ganglia_state', 'twitching');
DrEmilioLizardo.set('institutionalized', true);
DrEmilioLizardo.set('ship_completeness', 0.90);
DrEmilioLizardo.set('origin_dimension', 8);
DrEmilioLizardo.save();

And you would search for a set using:

Data.search('RedLectroid', "institutionalized == true");

or if you only wanted the data payload (not a set of objects)

Data.query('RedLectroid', "institutionalized == true");

One thing to note: This data layer is designed to discourage both streaming data sets and joins. If you need these features or you find this level of indirection uncomfortable you should probably manipulate the DB directly and skip the whole data layer (or even better, interface with an API).

Other Datasource specific features (for example MapReduce under mongo) must be accessed from the DB driver which may be accessed directly:

Datasource.get('myAwesomeDatasource').connection;

But when you do this you are circumventing the data layer (other than letting protolus negotiate the connection for you).