{"id":15293260,"url":"https://github.com/contiguity/base","last_synced_at":"2025-09-09T19:20:30.027Z","repository":{"id":257800704,"uuid":"862627854","full_name":"contiguity/base","owner":"contiguity","description":"Just because Deta Space shut down doesn't mean your projects have to. Contiguity Base is a one to one replacement for Deta Base \u0026 (soon) Deta Drive","archived":false,"fork":false,"pushed_at":"2024-10-13T21:22:26.000Z","size":432,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-20T14:45:19.514Z","etag":null,"topics":["contiguity","database","deta","nosql"],"latest_commit_sha":null,"homepage":"https://base.contiguity.co","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contiguity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-24T23:24:41.000Z","updated_at":"2024-10-13T21:22:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"11cd696d-8ba3-4e75-a370-a6b075cabdaf","html_url":"https://github.com/contiguity/base","commit_stats":null,"previous_names":["contiguity/base"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/contiguity/base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contiguity%2Fbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contiguity%2Fbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contiguity%2Fbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contiguity%2Fbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contiguity","download_url":"https://codeload.github.com/contiguity/base/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contiguity%2Fbase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273997155,"owners_count":25204479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contiguity","database","deta","nosql"],"created_at":"2024-09-30T16:45:16.888Z","updated_at":"2025-09-09T19:20:30.001Z","avatar_url":"https://github.com/contiguity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align='center'\u003e\u003cimg src=\"https://contiguity.co/assets/icon-black.png\" height=\"150px\"/\u003e\u003c/p\u003e\n\u003ch1 align='center'\u003e@contiguity/base\u003c/h1\u003e\n\n\u003cp align='center'\u003e\n    \u003cimg display=\"inline-block\" src=\"https://img.shields.io/npm/v/@contiguity/base?style=for-the-badge\" /\u003e \u003cimg display=\"inline-block\" src=\"https://img.shields.io/bundlephobia/minzip/@contiguity/base?style=for-the-badge\" /\u003e \u003cimg display=\"inline-block\" src=\"https://img.shields.io/badge/Made%20with-JavaScript-yellow?style=for-the-badge\" /\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003eContiguity's official JavaScript SDK for Contiguity Base\u003c/p\u003e\n\n## Installation 🏗 \u0026 Setup 🛠\nYou can install the SDK using NPM. \n```shell\n$ npm install @contiguity/base\n```\n\nThen, import \u0026 initialize it like this:\n\nUsing CommonJS (require):\n```js\nconst contiguity = require('@contiguity/base')\nconst db = contiguity.db(\"your-api-key\", \"your-project-id\")\n```\n\nUsing ES6 modules (import):\n```js\nimport contiguity from '@contiguity/base'\nconst db = contiguity.db(\"your-api-key\", \"your-project-id\")\n```\n\nYou can get an API key by fetching it in the [dashboard](https://base.contiguity.co), and a project ID is given to you when creating a project.\n\n## \u003cimg src=\"https://avatars.githubusercontent.com/u/47275976?s=280\u0026v=4\" alt=\"Deta Logo\" style=\"vertical-align: middle;\" height=\"30\"\u003e For those moving from Deta Space \u003cimg src=\"https://avatars.githubusercontent.com/u/47275976?s=280\u0026v=4\" alt=\"Deta Logo\" style=\"vertical-align: middle;\" height=\"30\"\u003e\nContiguity Base is a one-to-one replacement for the old Deta Base API, Deta Base JavaScript SDK, Deta Base Python SDK, and Deta Base Go SDK. The only thing that has changed is initialization. \n\nInstead of ```const deta = Deta(projectKey)```, you'll use ```const db = contiguity.db(apiKey, projectId)```\n\nThe rest stays the same, because at Contiguity, we think it's crazy for a cloud provider to give you 45 days to move dozens of apps from their proprietary database.\n\nIf you're transitioning from Deta Space to Contiguity, welcome! \n\n## Creating your first \"base\" 📊\n\nTo start working with a base, you can create a Base instance:\n\n```js\nconst myBase = db.Base(\"my-awesome-base\")\n```\n\nNow you're ready to perform some cool database operations!\n\n## Putting data into your base 📥\n\nTo add an item to your base, use the `put` method:\n\n```js\nconst item = {\n    name: \"Contiguity\",\n    is_awesome: true,\n    coolness_level: 9000\n}\n\nawait myBase.put(item)\n```\n\nYou can also specify a key for your item:\n\n```js\nawait myBase.put(item, \"unique-key-1\")\n```\n\nYou can set an expiration time for the item:\n\n```js\n// Expire in 3600 seconds (1 hour)\nawait myBase.put(item, \"unique-key-1\", { expireIn: 3600 })\n\n// Expire at a specific date/time\nawait myBase.put(item, \"unique-key-1\", { expireAt: \"2023-12-31T23:59:59Z\" })\n```\n\n## Batch putting 📦\nNeed to add multiple items at once? No problem! Just pass an array of items:\n\n```js\nconst items = [\n    { name: \"Item 1\", value: 100 },\n    { name: \"Item 2\", value: 200 },\n    { name: \"Item 3\", value: 300, key: \"some-unique-key\" }\n]\n\nawait myBase.putMany(items)\n```\n\n## Getting data from your base 🔍\n\nTo retrieve an item, use the `get` method:\n\n```js\nconst myItem = await myBase.get(\"unique-key-1\")\nconsole.log(myItem.name) // Outputs: Contiguity\n```\n\n## Updating data in your base 🔄\n\nNeed to update an item? Use the `update` method:\n\n```js\nawait myBase.update({ coolness_level: 9001 }, \"unique-key-1\")\n```\n\nYou can also use utility operations for updating:\n\n```js\n// Increment a value\nawait myBase.update({ views: myBase.util.increment(1) }, \"blog-post-1\")\n\n// Append to an array\nawait myBase.update({ tags: myBase.util.append(\"awesome\") }, \"product-1\")\n\n// Prepend to an array\nawait myBase.update({ recent_visitors: myBase.util.prepend(\"Alice\") }, \"website-stats\")\n\n// Trim a string\nawait myBase.update({ description: myBase.util.trim() }, \"user-bio\")\n```\n\n## Deleting data from your base 🗑️\n\nTo remove an item, use the `delete` method:\n\n```js\nawait myBase.delete(\"unique-key-1\")\n```\n\n## Querying (fetching) your base 🕵️‍♀️\n\nYou can perform complex queries using the `fetch` method:\n\n```js\nconst results = await myBase.fetch({ \n  \"is_awesome\": true, \n  \"profile.name?contains\": \"John\" \n});\n\nconsole.log(results.items); // Array of matching items\nconsole.log(results.count); // Total count of matching items\nconsole.log(results.last);  // Last evaluated key for pagination\n```\n\n### Query Operators\n\nContiguity Base supports various query operators. Here are some examples:\n\n- **Equal**: `{ \"age\": 22 }`\n- **Not Equal**: `{ \"age?ne\": 22 }`\n- **Less Than**: `{ \"age?lt\": 22 }`\n- **Greater Than**: `{ \"age?gt\": 22 }`\n- **Less Than or Equal**: `{ \"age?lte\": 22 }`\n- **Greater Than or Equal**: `{ \"age?gte\": 22 }`\n- **Prefix**: `{ \"name?pfx\": \"Jo\" }`\n- **Range**: `{ \"age?r\": [18, 30] }`\n- **Contains**: `{ \"tags?contains\": \"javascript\" }`\n- **Not Contains**: `{ \"tags?not_contains\": \"python\" }`\n\nFor more detailed information on query operators, please refer to our documentation.\n\n## Pagination\n\nWhen fetching large datasets, you can use pagination:\n\n```js\nlet lastKey = undefined;\ndo {\n  const results = await myBase.fetch(query, { limit: 1000, last: lastKey });\n  // Process results.items\n  lastKey = results.last;\n} while (lastKey);\n```\n\n## Debug mode 🐛\n\nIf you enable debug mode during initialization, the SDK will log detailed information about your requests. This can be super helpful for troubleshooting!\n\n```js\nconst db = contiguity.db(\"your-api-key\", \"your-project-id\", true)\n```\n\n## Error handling 🚨\n\nThe SDK won't throw errors when things don't go as planned. Instead, it will return `undefined` in most cases, like if you attempt to GET a non-existent key. However, it is always recommended to put database calls in a try/catch block:\n\n```js\ntry {\n    const item = await myBase.get(\"non-existent-key\")\n    if (item === undefined) {\n        console.log(\"Item not found\")\n    } else {\n        console.log(\"Item:\", item)\n    }\n} catch (error) {\n    console.error(\"Oops!\", error.message)\n}\n```\n\n## Roadmap 🚦\n- Support for more complex query operations\n- Batch operations for deleting multiple items\n- \"Deta Drive\" support (file storage)\n- And many more exciting features!\n\nFor more detailed information and advanced usage, please refer to our full documentation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontiguity%2Fbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontiguity%2Fbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontiguity%2Fbase/lists"}