tadam313 / sheet-db Goto Github PK
View Code? Open in Web Editor NEWUse google spreadsheet very similar to Mongo DB
License: MIT License
Use google spreadsheet very similar to Mongo DB
License: MIT License
Instead initiating many requests simultaneously in async manner, the same effect could be achieved by using batch operation, so handle every entires in one single batch operation instead of multiple.
Upon worksheet creation, the column count/row count values are burnt-in, meaning a worksheet area won't extend as the user inserts new entries. This eventually end up causing an error if the content grows too big. The insertion logic should be aware of this behaviour and dynamically increase the worksheet area by X lines/columns. (where X should be significantly bigger than the amount of entries being inserted to avoid doing this on every insert)
The Google Sheets v3 API will be shut down on March 3, 2020. Follow this migration guide to update your applications so that they use the v4 API. Learn more
https://developers.google.com/sheets/api/v3/authorize
It seems that we need to upgrade our API to v4 before March 2020.
Here's a great google spreadsheet API module with v4 which we can learn from: Google Sheets API (v4) wrapper for Node.js
My google spreadsheet is public read & write able.
My code t.js is as the following:
const connect = require('sheet-db')
// https://docs.google.com/spreadsheets/d/106lfsqgEOMqRX3apK3qGbVcjQIaCK7EudHHI3-TpEKQ/edit?usp=sharing
const sheet = connect('106lfsqgEOMqRX3apK3qGbVcjQIaCK7EudHHI3-TpEKQ')
sheet
.info().then(console.info)
.catch(console.error)
It show the following error message when I run it:
$ node t.js
Error: The response contains invalid data
at _callee$ (/home/huan/git/mike-bo/node_modules/sheet-db/lib/rest_client.js:44:31)
at tryCatch (/home/huan/git/mike-bo/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/home/huan/git/mike-bo/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/home/huan/git/mike-bo/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/home/huan/git/mike-bo/node_modules/sheet-db/lib/rest_client.js:588:191)
at /home/huan/git/mike-bo/node_modules/sheet-db/lib/rest_client.js:588:361
at process._tickCallback (internal/process/next_tick.js:68:7)
The current process is very tedious. Especially when a token expires need to manually reissue the request with the newly fetched token which is delegated to the user. This results in many manual preparatory/integration work before someone can start using this package. The amount of LOC spent on integrating this package should be dramatically reduced.
If the current process can not be improved anyhow, need to provide built-in authentication solutions (e.g separate auth namespace) to mitigate this problem.
Keeping authentication detached seemed a reasonable way, but it should not degrade the ease of integration.
The current callback like API is very obsolete. Promises are clearly the direction of JS world and this project should follow that.
The idea is that every high-level call (user facing) would return a promise instead invoking a callback. Here we need to bear in mind the backward compatibility so might need to support both callback/promise way. Maybe worth considering ES6 transition as well, just random thoughts...
Hi @tadam313 !
I search a lot on the internet and try to find a MongoDB interface for the google spreadsheet, but I found nothing.
Then I try to search the npm module name as spreadsheet-db
, it's a 404.
At last, I try sheet-db
and I arrived here! It seems is exactly what I want, I will try it later.
Do you want to support TypeScript for your module? If so, I'd love to contribute.
We have two options:
I would love to help you with either of the above two options, please let me know what I can start with if you want it.
Thanks for your great module, and I hope you have a nice day!
Huan
A script or a tool will be a great help for the user to get the token.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.