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

indurate

v0.2.0

Published

Indurate.js is an asynchronous sqlite3 wrapper for the openDatabase module.

Downloads

3

Readme

Indurate Database

A wrapper to WebSql and node openDatabase

NPM

Author: Robert Edward Steckroth II

Digital Persona: Surgemcgee, Bustout [email protected]

Licence: GNU GENERAL PUBLIC LICENSE Version 3

Description:

Indurate.js is a user friendly API for server and mobile applications. Indurate uses WebSql node openDatabase with a strong object oriented structure. Indurate can provide database driven applications or supplement existing mobile applications.

Features:

  • Efficient design
  • Simple table management
  • Pretty database and table printing
  • Asynchronous or synchronous code structure

###Example usage

var path = require('path'),
    Indurate = require('indurate')


function log(message) {
    console.log('[Indurate Test Server] '+message)
}

var server_db = function() {

    this.appcwd = path.dirname(__filename)
    this.database_dir = path.join(this.appcwd, 'Indurate_test_database.sqlite')
    this.db = new Indurate({name: this.database_dir, version: "1.0", description: "Example database for indurate.js", size: 3})

}


server_db.prototype = {

    get_set_test: function(t_name) {
        var newThis = this // Gots to have the scope cheat to be functional
        var table_object = {}
        // First array value will be used as the primary key/object identifier
        // If the table was created outside of Indurate, the first column in the table will be used as the primary key
        this[t_name] = this.db.initTable(t_name, ['key', 'name', 'last_updated', 'has_failed'], function() {
            log('Initializing table '+this.name)
            this.getTable(function(table, out) {
                log('Fetching table '+this.name+' as js object')

                log('Retrieved '+out.rows.length+' from '+this.name) // This.name is the table name passed into initTable
                log('Table has columns: '+this.columns)
                log('Table colums is stored in results as a array '+out.rows.info().toString())
                log('The second paramater is optional and WebSql compliant./nout.rows.length: '+out.rows.length+'\nout.rows.item(0): ')
                console.dir(out.rows.item(0))
                log('Table columns are stored in results.rows.info() as an array '+out.rows.info().toString())
                table_object = table
                table_object['my_key'] = {}
                table_object['my_key'].name = 'Cool yo'
                table_object['my_key'].last_updated = new Date()
                table_object['my_key'].has_failed = false

                this.set(table_object, function(){
                    // Set it the table with the values we built in the getTable() call
                    this.describe(function(output) { log(output) }) // Provide us with pretty printing of the table

                })
            })
        })

    },

     change_table_test: function(t_name, key, name, value) {
         // If the table exists, the column fields are ignored so we will leave it empty here for convenience
         this[t_name].getTable(function(t_obj) {  // Second paramater (WebSql) is ommited here which uses less memory
             console.dir(t_obj)
             log('Columns in table '+this.name+' are '+this.columns.toString())
             if ( t_obj[key] ) // Does the rows/key exists? We can also check this.columns or out.row.info() in here
                t_obj[key][name] = value
             this.set(t_obj, function() {
                 this.describe() // All callbacks are optional and will log to console if not provided
                })
         })
    },


}


var tests = new server_db()


tests.get_set_test('my_table1')
setTimeout(function(){
    tests.change_table_test('my_table1', 'my_key', 'name', 'Surgemcgee') // DON'T SO THIS TOO QUICK. Remember that Indurate is asynchronous
}, 1000)

example output table describe

___________________________________________________________________________________________
|key        |name                      |last_updated                           |has_failed|
|___________|__________________________|_______________________________________|__________|
|my_key . . |Surgemcgee . . . . . . . .|Sat Oct 26 2013 10:58:54 GMT-0400 (EDT)|false . . |
|another_key|Robert Edward Steckroth II|Sat Oct 26 2013 10:52:52 GMT-0400 (EDT)|No way! . |
|___________|__________________________|_______________________________________|__________|

example output show database

| Show Database: example     Version: 1.0     Size(bytes): 3145728	 Description: Example database for indurate.js
| Rows: 5	 Columns: 5
______________________________________________________________________________________________________________________________________________________________________________________________________________________
|type |name                       |tbl_name                   |rootpage|sql                                                                                                                                          |
|_____|___________________________|___________________________|________|_____________________________________________________________________________________________________________________________________________|
|table|__WebKitDatabaseInfoTable__|__WebKitDatabaseInfoTable__|3 . . . |CREATE TABLE __WebKitDatabaseInfoTable__ (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,value TEXT NOT NULL ON CONFLICT FAIL)|
|table|userTable . . . . . . . . .|userTable . . . . . . . . .|5 . . . |CREATE TABLE userTable(name TEXT UNIQUE, value TEXT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
|table|peopleTable . . . . . . . .|peopleTable . . . . . . . .|7 . . . |CREATE TABLE peopleTable(name TEXT UNIQUE, value TEXT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
|_____|___________________________|___________________________|________|_____________________________________________________________________________________________________________________________________________|