V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Joway
V2EX  ›  Node.js

SheetSQL - Google Spreadsheet as a Database

  •  
  •   Joway · 2020-07-30 11:26:42 +08:00 · 1681 次点击
    这是一个创建于 1359 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Github

    之前经常需要和运营同事打交道,将她们 Google Spreadsheet 上维护的内容映射到数据库里,如果数据变动比较频繁,这种需求又要单独做成一个运营后台,非常麻烦。与此同时,她们也会需要看到一些 sheets 上数据在生产上的反馈,比如每条内容的点击量。

    但如果 Spreadsheet 自身就是一个可以增删改查的数据库,运营可以编辑她自己的内容,程序也可以反过来写入一些反馈数据到 sheets 中的其他列中去。这样完全不需要什么运营后台,对开发和运营都是个好事。所以写了这个 SheetSQL 的库,在很多数据量不大,实时性要求不那么高的场景非常适合。

    Example

    const db = new Database({
      db: '1ya2Tl2ev9M80xYwspv7FJaoWq0oVOMBk3VF0f0MXv2s',
      table: 'Sheet1', // optional, default = Sheet1
      keyFile: './google-serviceaccount.json',
      cacheTimeoutMs: 5000, // optional, default = 5000
    })
    
    // load schema and data from google spreadsheet
    await db.load()
    
    // insert multiple documents
    let docs = await db.insert([
      {
        name: 'joway',
        age: 18,
      },
    ])
    
    // find documents and update them
    docs = await db.update(
      {
        name: 'joway',
      },
      {
        age: 100,
      },
    )
    
    // find documents
    docs = await db.find({
      name: 'joway',
    })
    
    // find all documents
    docs = await db.find({})
    
    // find documents and remove them
    docs = await db.remove({
      name: 'joway',
    })
    
    1 条回复    2020-07-30 23:12:26 +08:00
    tikazyq
        1
    tikazyq  
       2020-07-30 23:12:26 +08:00
    ShitSQL?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1352 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:31 · PVG 01:31 · LAX 10:31 · JFK 13:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.