• This repository has been archived on 03/Mar/2023
  • Stars
    star
    108
  • Rank 320,099 (Top 7 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Google Spreadsheet implementation of leveldown

sheet-down

Build Status

A Google Spreadsheet implementation of leveldown.

This library uses abstract-leveldown to turn a worksheet within a Google Spreadsheet into a leveldown-compatible store for use with levelup. It was built to provide a convenient and familiar UI for two use cases:

  1. As a write-only store, to enable simple data entry without having to create or maintain a custom CRUD app with its own authentication/authorization.
  2. As a read-only view of an upstream data store, with built in sort and filter functionality.

Keep in mind that there are some differences between LevelDB and Google Spreadsheets. For example, unlike LevelDB, Google Spreadsheets does not guarantee batch write atomicity, and does not snapshot reads.

Currently only io.js has been tested.

Example

import fs from "fs"
import levelup from "levelup"
import {Token} from "google-oauth-jwt-stream"
import {CellDOWN} from "sheet-down"

let email = "[email protected]"
let key = fs.readFileSync("./key.pem")
let scopes = ["https://spreadsheets.google.com/feeds"]
let token = new Token(email, key, scopes)

let location = "<spreadsheet-id>/<worksheet-id>"
let table = levelup(location, new CellDOWN({token}))

table.batch()
  // put header row
  .put([1, 1], "name")
  .put([1, 2], "github handle")

  // put data rows
  .put([2, 1], "Jed Schmidt")
  .put([2, 2], "@jed")
  .put([3, 1], "Brian J. Brennan")
  .put([3, 2], "@brianloveswords")

  .write(err => {
    // read cells
    table.createReadStream().on("data", console.log)

    // { key: [ 1, 1 ], value: 'name' }
    // { key: [ 1, 2 ], value: 'github handle' }
    // { key: [ 2, 1 ], value: 'Jed Schmidt' }
    // { key: [ 2, 2 ], value: '@jed' }
    // { key: [ 3, 1 ], value: 'Brian J. Brennan' }
    // { key: [ 3, 2 ], value: '@brianloveswords' }
  })

screenshot

Installation

npm install sheet-down

Setup

Follow these steps to create and share a spreadsheet that this library can access, and get its spreadsheet and worksheet IDs.

API

import {CellDOWN, RowDOWN} from "sheet-down"

This backend provides two interfaces, for each cells and rows. Each of these constructors take an object whose token property is an instance of google-oauth-jwt-stream, and return an object whose db, keyEncoding, and valueEncoding properties match those accepted by levelup.

let cells = levelup("spreadsheetId/worksheetId", CellDOWN({token}))

This creates a backend that operates on a Google worksheet by cell. Each key is an 8-byte buffer of two UInt32BEs that specify the row number and column number, and each value is a utf-8 string. Unless otherwise specified, cell keys are transparently converted from integer arrays by the provided keyEncoding.

let rows = levelup("spreadsheetId/worksheetId", RowDOWN({token}))

This creates a backend that operates on a Google worksheet by row. Each key is a 4-byte UInt32BE that specifies the row number, and each value is a JSON-encoded string. Unless otherwise specified, cell keys are transparently converted from integers by the provided keyEncoding.

This backend is built on top of the cell interface by using the first row of the worksheet as a schema, grouping all cells in a given row into an array, and then using the schema keys to replace the column numbers with property names.

More Repositories

1

140bytes

Once a tweet-sized, fork-to-play, community-curated collection of JavaScript.
HTML
1,031
star
2

lave

eval in reverse: stringifying all the stuff that JSON.stringify won't
JavaScript
895
star
3

fab

a modular async web framework for node.js
JavaScript
732
star
4

browserver-client

ΰ·΄ A node.js HTTP server in your browser ΰ·΄
JavaScript
638
star
5

authom

A zero-dependency mutli-service authentication tool for node.js
JavaScript
401
star
6

browserver-node

ΰ·΄ Browserver proxy for node.js ΰ·΄
JavaScript
333
star
7

domo

Markup, style, and code in one language.
JavaScript
308
star
8

certbot-route53

Helping create Let's Encrypt certificates for AWS Route53
Shell
175
star
9

kibi

a client-side web framework in 1,024 bytes
JavaScript
144
star
10

dynamo

DynamoDB client for node.js
JavaScript
141
star
11

building-brooklynjs

My story of how we built BrooklynJS.
136
star
12

rndr.me

an HTTP server that uses PhantomJS to render HTML
JavaScript
133
star
13

weenote

A quick/dirty/tiny tool for creating simple Takahashi-style presentations.
HTML
119
star
14

hyperspider

A declarative HATEOAS API crawler for node.js
JavaScript
114
star
15

cookie-node

signed cookie functionality for node.js
JavaScript
82
star
16

config-leaf

Hide your sensitive node.js bits in plain sight.
JavaScript
53
star
17

sajak

Simple Authenticated JSON API Kit
JavaScript
33
star
18

dynamo-down

A leveldown API implementation on AWS DynamoDB
JavaScript
31
star
19

localhose

Hose your hosts file for easier local web development
JavaScript
29
star
20

browserver.org

The code for the browserver.org web site.
CoffeeScript
29
star
21

emit

A reactive toolkit for JavaScript
JavaScript
29
star
22

dynamo-client

A low-level client for accessing DynamoDB from node.js
JavaScript
28
star
23

osx-browser-vm

Evaluate JavaScript in local OS X browsers
JavaScript
28
star
24

dynamo-streams

A stream-flavored wrapper for the AWS DynamoDB JavaScript API
JavaScript
25
star
25

wc-jsx-runtime

A JSX transform for Web Components
JavaScript
23
star
26

tmpl-node

a template module for node.js
JavaScript
20
star
27

esbuild-plugin-http-fetch

An esbuild plugin that resolves http(s) modules
JavaScript
19
star
28

skeyma

A JavaScript parser & serializer for {key, value} objects & streams
JavaScript
18
star
29

browserver-router

A platform-agnostic router for HTTP listeners that follow the node.js spec
JavaScript
18
star
30

cfn-api-gateway-custom-domain

API Gateway custom domains as CloudFormation resources, backed by Let's Encrypt
JavaScript
18
star
31

alReady.js

a terse, embeddable, and cross-browser domReady implementation
JavaScript
17
star
32

electric-objects

A node.js API for the Electric Objects EO1 frame
JavaScript
17
star
33

monot

Unique JavaScript dates
JavaScript
15
star
34

google-worksheet-stream

A streaming interface for Google Spreadsheets
JavaScript
14
star
35

dinkumise

Keep ya JavaScripts Dinki-di!
11
star
36

pbsb

getters/setters and pub/sub in one tiny javascript function
JavaScript
11
star
37

twil-eo

Using Twilio, AWS, and Electric Objects to create an MMS-powered family photo frame.
JavaScript
10
star
38

textpanda

web-based text shortcuts for the lazy
JavaScript
8
star
39

diff-stream2

Merges multiple sorted streams into a diffed tuple stream
JavaScript
7
star
40

namedrop

minification for DOM-heavy code
JavaScript
7
star
41

eartag

Tag browsers like farmers tag livestock
JavaScript
7
star
42

autorequire

small module for autorequiring. warning: MAGIC!
JavaScript
6
star
43

sort-stream2

Array.prototype.sort for streams
JavaScript
6
star
44

dynamo-sync

Differential data synchronization for Amazon's DynamoDB
6
star
45

google-oauth-jwt-stream

A readable stream of OAuth access tokens for use with Google APIs
JavaScript
6
star
46

dom-jsx-runtime

A tiny library that turns JSX into DOM operations
JavaScript
6
star
47

node-lacrosse

A node.js streaming API for Lacrosse Alert sensors
JavaScript
6
star
48

abstract-stream-leveldown

A stream-based abstract prototype matching the LevelDOWN API
JavaScript
5
star
49

gist-in-time

a stylesheet for displaying github gist metadata on hover
5
star
50

typd.in

a web-based input method editor for japanese
JavaScript
4
star
51

esbuild-plugin-eval

An esbuild plugin that evaluates a module before importing it
JavaScript
4
star
52

one-character-identifiers

every javascript identifier that fits in a character
JavaScript
4
star
53

jed.is

personal web site
3
star
54

domogenize

Turn static HTML and CSS into declarative JavaScript
JavaScript
3
star
55

ramendan

CoffeeScript
3
star
56

census-topologies

Topologies from the U.S. Census Bureau
Shell
3
star
57

20x20

a simple pecha kucha timer optimized for my iPhone
JavaScript
3
star
58

utfn

a test of the utf-n encoding
3
star
59

esbuild-plugin-bundle

An esbuild plugin that bundles modules before importing them
JavaScript
2
star
60

deno_bundle

A temporary workaround to support bundling with sourcemaps in Deno
JavaScript
2
star
61

ordered-kv-tuple-stream

Aligns multiple ordered k/v readable streams into one
JavaScript
2
star
62

tuple-stream2

Aligns multiple readable object streams into one stream
JavaScript
2
star
63

esbuild-plugin-deno-http

An esbuild plugin that uses Deno to resolve and cache HTTP modules
JavaScript
2
star
64

esbuild-plugin-env

An esbuild plugin that exports the current environment as a module
JavaScript
2
star
65

deno-file-system-access-api

File System Access API for Deno
JavaScript
1
star
66

level-sync

One-way sync for levelup data stores
JavaScript
1
star
67

abevigoda

Abe Vigoda as a Service
JavaScript
1
star
68

esbuild-plugin-view-source

An esbuild plugin that enables built modules to be imported as source
JavaScript
1
star