GithubHelp home page GithubHelp logo

kaviarasankk / drive-db Goto Github PK

View Code? Open in Web Editor NEW

This project forked from franciscop/drive-db

1.0 2.0 0.0 102 KB

:bar_chart: A Google Drive spreadsheet simple database

License: MIT License

JavaScript 100.00%

drive-db's Introduction

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.

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

Becomes a JSON file and an array of objects in your code:

[
  {
    "id": "1",
    "firstname": "John",
    "lastname": "Smith",
    "age": "34",
    "city": "San Francisco"
  },
  {
    "id": "2",
    "firstname": "Merry",
    "lastname": "Johnson",
    "age": "19",
    "city": "Tokyo"
  },
  {
    "id": "3",
    "firstname": "Peter",
    "lastname": "Williams",
    "age": "45",
    "city": "London"
  }
]

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().then(db => {

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

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';

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 Merry Johnson 19 Tokyo
3 Peter Williams 45 London

See this document as an example. 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

drive-db's People

Contributors

franciscop avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar Kaviarasan K K avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.