JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q67575F
  • License MIT

Using Google Sheets as a database.

Package Exports

  • @sheetbase/sheets-server

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sheetbase/sheets-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Sheetbase Module: @sheetbase/sheets-server

Using Google Sheets as a database.

Build Status Coverage Status NPM License clasp Support me on Patreon PayPal Ask me anything

Install

Using npm: npm install --save @sheetbase/sheets-server

import * as Sheets from "@sheetbase/sheets-server";

As a library: 1pbQpXAA98ruKtYTtKwBDtdgGTL_Nc_ayGzdRR2ULosG6GcKQJUF5Qyjy

Set the Indentifier to SheetsModule and select the lastest version, view code.

declare const SheetsModule: { Sheets: any };
const Sheets = SheetsModule.Sheets;

Scopes

https://www.googleapis.com/auth/spreadsheets

Usage

Examples

import * as Sheets from "./public_api";

function load_() {
  const databaseId = "1Zz5kvlTn2cXd41ZQZlFeCjvVR_XhpUnzKlDGB8QsXoI";
  return Sheets.sheets({
    databaseId,
    keyFields: { foo: "slug" },
    searchFields: { foo: ["content"] }
  });
}

export function example1(): void {
  const { SQL } = load_();

  // get all items from 'foo' table
  const all = SQL.all("foo");
  Logger.log(all);
}

export function example2(): void {
  const { SQL } = load_();

  // get item eith the # of 3 from 'foo' table
  const item = SQL.item("foo", 3);
  Logger.log(item);
}

export function example3(): void {
  const { SQL } = load_();

  // update item with # of 6
  SQL.update("foo", { content: new Date().getTime() }, 6);
  Logger.log("foo-6 updated using SQL.");
}

export function example4(): void {
  const { SQL } = load_();

  // create foo-8
  SQL.update("foo", {
    slug: "foo-8",
    title: "Foo 8",
    content: new Date().getTime()
  });
  Logger.log("foo-8 added using SQL.");
}

export function example5(): void {
  const { NoSQL } = load_();

  // get all item of 'foo' collection
  const collection = NoSQL.collection("foo");
  // get content of foo-2 as a list
  const list = NoSQL.list("/foo/foo-2/content");
  Logger.log(collection);
  Logger.log(list);
}

export function example6(): void {
  const { NoSQL } = load_();

  // get item foo-3
  const doc = NoSQL.doc("foo", "foo-3");
  const object = NoSQL.object("/foo/foo-3");
  Logger.log(doc);
  Logger.log(object);
}

export function example7(): void {
  const { NoSQL } = load_();

  // update foo-6
  NoSQL.update({
    "/foo/foo-6/content": new Date().getTime()
  });
  Logger.log("foo-6 updated using NoSQL.");
}

export function example8(): void {
  const { NoSQL } = load_();

  // create foo-8
  NoSQL.update({
    "/foo": { slug: "foo-8", title: "Foo 8", content: new Date().getTime() }
  });
  Logger.log("foo-8 added using NoSQL.");
}

export function example9(): void {
  const { SQL } = load_();

  const search = SQL.search("foo", "me");
  Logger.log(search);
}

License

@sheetbase/sheets-server is released under the MIT license.