{"library":"sheetsql","title":"sheetsql","description":"sheetsql is a JavaScript/TypeScript library (currently at version 0.1.7) that enables developers to interact with Google Spreadsheets as if they were a simple database. It provides a programmatic API for performing CRUD (Create, Read, Update, Delete) operations on spreadsheet data, effectively turning a Google Sheet into a 'single source of truth' for non-technical users. This approach is particularly useful for scenarios where a full-fledged Content Management System (CMS) is overkill, but programmatic access to frequently updated spreadsheet data is required. The library is currently in an early development stage, indicated by its low version number, suggesting that future releases might introduce breaking changes. It differentiates itself by offering a direct, code-driven interface to Google Sheets data without requiring intermediate database synchronization, simplifying workflows for data managed primarily by business users.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install sheetsql"],"cli":null},"imports":["import { Database } from 'sheetsql'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Database } from 'sheetsql';\nimport * as path from 'path';\n\n// Ensure your service account key file exists at this path.\n// For production, consider loading the key from environment variables or a secure secret management system.\nconst keyFilePath = path.resolve('./google-serviceaccount.json');\n\nconst runExample = async () => {\n  const db = new Database({\n    db: '1ya2Tl2ev9M80xYwspv7FJaoWq0oVOMBk3VF0f0MXv2s', // Replace with your actual Google Spreadsheet ID\n    table: 'Sheet1', // optional, default = Sheet1\n    keyFile: keyFilePath,\n    cacheTimeoutMs: 5000 // optional, default = 5000\n  });\n\n  // Load schema and data from google spreadsheet\n  await db.load();\n  console.log('Database loaded.');\n\n  // Insert multiple documents\n  let docs = await db.insert([\n    {\n      name: 'joway',\n      age: 18\n    },\n    {\n      name: 'alice',\n      age: 25\n    }\n  ]);\n  console.log('Inserted documents:', docs);\n\n  // Find documents and update them\n  docs = await db.update(\n    {\n      name: 'joway'\n    },\n    {\n      age: 100\n    }\n  );\n  console.log('Updated documents:', docs);\n\n  // Find documents\n  docs = await db.find({\n    name: 'joway'\n  });\n  console.log('Found documents:', docs);\n\n  // Find all documents\n  docs = await db.find({});\n  console.log('All documents:', docs);\n\n  // Find documents and remove them\n  docs = await db.remove({\n    name: 'alice'\n  });\n  console.log('Removed documents:', docs);\n};\n\nrunExample().catch(console.error);","lang":"typescript","description":"Demonstrates how to initialize a `Database` instance with a Google Service Account key, load data from a spreadsheet, and perform basic CRUD operations (insert, find, update, remove).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}