pgv / drive-db

:bar_chart: A Google Drive spreadsheet simple database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status

drive-db

A Google Drive spreadsheet simple database. Stop wasting your time when a simple table is enough. Perfect for collaboration with multiple people editing the same spreadsheet.

Usage

To access it with the default configuration you just need to provide the Google Drive's sheet id. Read more in the full documentation, but here's an example:

// Include the module and tell it which spreadsheet to use
var drive = require("drive-db")("1BfDC-ryuqahvAVKFpu21KytkBWsFDSV4clNex4F1AXc");

// Load the spreadsheet
drive.load(function(err, db){

  // Find all Johns by their last name
  var Johns = db.find({ firstname: "John" }).order('lastname');
});

The db.find() queries are the same as in mongoDB's comparison query operators:

// Return an array with one element that has the id 3
db.find({ id: 3 });

// Return an array of people called "John" or "Jack"
db.find({ firstname: { $in: ["John", "Jack"]] } });

Installation

npm install drive-db --save

To get the right google drive spreadsheet:

// Single argument can be passed as that
require('drive-db')("1fvz34wY6phWDJsuIneqvOoZRPfo6CfJyPg1BYgHt59k");

// If you want to add more options
require('drive-db')({ sheet: "1fvz34wY6phWDJsuIneqvOoZRPfo6CfJyPg1BYgHt59k" });

// Load it later on
var drive = require('drive-db')();
drive.sheet = "1BfDC-ryuqahvAVKFpu21KytkBWsFDSV4clNex4F1AXc";

Note: the table has to have a structure similar to this, where the first row are the alphanumeric field names:

id firstname lastname age city
1 John Smith 34 San Francisco
2 Mery Johnson 19 Tokyo
3 Peter Williams 45 London

See this document as an example. Note: please do not request access to edit it

Test

To run the tests, simply call:

npm test

Contributing

Please take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Areas where I'm seeking for help:

  • Testing. Adding coverage or improving existing ones.
  • Documentation. Make everything clear.

Thanks to

About

:bar_chart: A Google Drive spreadsheet simple database

License:MIT License


Languages

Language:JavaScript 100.0%