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

data-drive

v1.0.0

Published

A simple wrapper to write to GDrive

Downloads

2

Readme

Data-Drive

A wrapper to do some easy logging and writing and parsing stuff from and to Google Spreadsheets.

Install

npm install data-drive

Or

Clone the repo to your localhost

git clone [email protected]:RamonGebben/data-drive.git

Quick example


var config = require('./config.json');
var DD = require('data-drive')( config );

DD.connect(function(){
	DD.create( { "test": "testing", "test2": "OK" }, function(){
		console.log( "done" );
	} )
});

Configurations

First you must create a doc to write to. Open your Drive and sign in.

Use this template to create a new sheet.

Next we need to configure the config.json. The config expects the following values to be present:

"auth": {
	"username": "[email protected]",
	"password": "password"
},
"sheet": {
	"name": "name of sheet",
	"id": "optional id",
	"worksheet": {
		"name": "worksheet name",
		"id": "optional id"
	}
}

The sheet.id and sheet.worksheet.id are optional. These will appear in the console when not given, after that you could add them to make the connection faster.

Mapping the sheet

Because Google sheets provides us with a json we can't really work with the data gets remapped. You can ajust the names of the columns in the config.json. A mapping would look like this:

"mapping": {
	"columns":[
		["1", "key"],
		["2", "key1"],
		["3", "key2"]
	]
}
How we receive the data
{
	"1": {
	    "1": "pizza",
	    "2": "koffie",
	    "3": "kebab"
	}
}
After mapping
{
    "key": "pizza",
    "key1": "koffie",
    "key2": "kebeb",
    "id": 1
}

Actions

The action have a very simple syntax:

DD.name_of_action( [id], data, function(){
	//Gets executed when done.
});

Although some action may require an id like:

  • GET
  • UPDATE
  • DESTROY

Because else we wouldn't not know which record to update.

GET

The GET action requires an id or an query to find a array of records to match the query.

// With an ID
DD.get( id, function(){
	//Gets executed when done.
});
// => {} returns an Object

// With an query
// NOTE: Only `===` is supported at this point
DD.get( 'key === pizza', data, function(){
	//Gets executed when done.
});
// => [{}, {}, {}] returns an Array of Objects

CREATE

Adds a new record field to the db and updates it with the data that is given.

DD.create( data, function(){
	//Gets executed when done.
});

UPDATE

Update a record.

DD.update( id, data, function(){
	//Gets executed when done.
});

DESTROY

Removal is not possible. The record field will be made empty so count as inactive.

DD.destroy( id, function(){
	//Gets executed when done.
});

DB

If you want to provide al the info to a client side application you can just dump the entire db.


DD.db() // return entire db

Testing

To run the tests, first cd into the test dir, edit the test_config.json and run:

npm test