Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tywalch/electrodb
A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
https://github.com/tywalch/electrodb
aws dynamodb dynamodb-client dynamodb-database nosql nosql-data-storage nosql-database single-table-design
Last synced: about 1 month ago
JSON representation
A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
- Host: GitHub
- URL: https://github.com/tywalch/electrodb
- Owner: tywalch
- License: mit
- Created: 2020-03-11T03:20:03.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-18T21:05:19.000Z (about 2 months ago)
- Last Synced: 2024-10-18T23:51:04.983Z (about 2 months ago)
- Topics: aws, dynamodb, dynamodb-client, dynamodb-database, nosql, nosql-data-storage, nosql-database, single-table-design
- Language: JavaScript
- Homepage:
- Size: 8.28 MB
- Stars: 1,008
- Watchers: 13
- Forks: 63
- Open Issues: 80
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-faker - electrodb - A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable. (Projects using `@faker-js/faker`)
- awesome-dynamodb - ElectroDB
README
# ElectroDB
[![Download Count](https://img.shields.io/npm/dt/electrodb.svg)](https://www.npmjs.com/package/electrodb)
[![Coverage Status](https://coveralls.io/repos/github/tywalch/electrodb/badge.svg?branch=master)](https://coveralls.io/github/tywalch/electrodb?branch=master&kill_cache=please)
![NPM Bundle Size](https://img.shields.io/bundlephobia/min/electrodb)
[![Runkit Demo](https://img.shields.io/badge/runkit-electrodb-db4792)](https://runkit.com/tywalch/electrodb-building-queries)
[![Last Commit](https://img.shields.io/github/last-commit/tywalch/electrodb)](https://github.com/tywalch/electrodb/commits/master)
[![Issues](https://img.shields.io/github/issues/tywalch/electrodb)](https://github.com/tywalch/electrodb/issues)
[![Sponsors](https://img.shields.io/github/sponsors/tywalch)](https://github.com/tywalch)
[![Github Stars](https://img.shields.io/github/stars/tywalch/electrodb?style=social)](https://github.com/tywalch/electrodb/stargazers)![Logo](./assets/electrodb-drk-compressed.png#gh-dark-mode-only)
![Logo](./assets/electrodb.png#gh-light-mode-only)**_ElectroDB_** is a DynamoDB library to ease the use of having multiple entities and complex hierarchical relationships in a single DynamoDB table.
_Please submit issues/feedback or reach out on Twitter [@tinkertamper](https://twitter.com/tinkertamper)._
Visit the v3 migration page to learn more about this new update.
---
Documentation now found at ElectroDB.dev
ElectroDB's new website for Documentation is now live at electrodb.dev.
---
Try out and share ElectroDB Models, Services, and Single Table Design at electrodb.fun
---
## Features
- [**Single-Table Entity Isolation**](https://electrodb.dev/en/modeling/entities/) - Entities created with **ElectroDB** will not conflict with other entities when using a single DynamoDB table.
- [**Attribute Schema Enforcement**](https://electrodb.dev/en/modeling/attributes/) - Define a schema for your entities with enforced attribute validation, defaults, types, aliases, and more.
- [**Easily Compose Hierarchical Access Patterns**](https://electrodb.dev/en/modeling/indexes/) - Plan and design hierarchical keys for your indexes to multiply your possible access patterns.
- [**Simplified Sort Key Condition Querying**](https://electrodb.dev/en/queries/query/) - Write efficient sort key queries by easily building compose keys.
- [**Simplified Filter Composition**](https://electrodb.dev/en/queries/filters/) - Easily create complex readable filters for DynamoDB queries without worrying about the implementation of `ExpressionAttributeNames`, `ExpressionAttributeValues`, and `FilterExpressions`.
- [**Simplified Condition Composition**](https://electrodb.dev/en/mutations/conditions/) - Use the same interface to casily create complex readable mutation conditions for DynamoDB queries without worrying about the implementation of `ExpressionAttributeNames`, `ExpressionAttributeValues`, and `ConditionExpressions`.
- [**Simplified Update Expression Composition**](https://electrodb.dev/en/mutations/update/) - Easily compose type safe update operations without having to format tedious `ExpressionAttributeNames`, `ExpressionAttributeValues`, and `UpdateExpressions`.
- [**Easily Query Across Entities**](https://electrodb.dev/en/core-concepts/single-table-relationships) - Define "collections" to create powerful/idiomatic queries that return multiple entities in a single request.
- [**Automatic Index Selection**](https://electrodb.dev/en/queries/find/) - Use `.find()` or `.match()` methods to dynamically and efficiently query based on defined sort key structures.
- [**Simplified Pagination API**](https://electrodb.dev/en/queries/pagination/) - ElectroDB generates url safe cursors for pagination, allows for fine grain automated pagination, and supports async iteration.
- [**Strong TypeScript Inference**](https://electrodb.dev/en/reference/typescript/) - Strong **TypeScript** support for both Entities and Services now in Beta.
- [**Query Directly via the Terminal**](https://github.com/tywalch/electrocli#query-taskapp) - Execute queries against your `Entities`, `Services`, `Models` directly from the command line.
- [**Stand Up Rest Server for Entities**](https://github.com/tywalch/electrocli#query-taskapp) - Stand up a REST Server to interact with your `Entities`, `Services`, `Models` for easier prototyping.
- [**Use with your existing tables**](https://electrodb.dev/en/recipes/use-electrodb-with-existing-table/) - ElectroDB simplifies building DocumentClient parameters, so you can use it with existing tables/data.---
**Turn this**
```typescript
tasks
.patch({
team: "core",
task: "45-662",
project: "backend",
})
.set({ status: "open" })
.add({ points: 5 })
.append({
comments: [
{
user: "janet",
body: "This seems half-baked.",
},
],
})
.where(({ status }, { eq }) => eq(status, "in-progress"))
.go();
```**Into This**
```json
{
"UpdateExpression": "SET #status = :status_u0, #points = #points + :points_u0, #comments = list_append(#comments, :comments_u0), #updatedAt = :updatedAt_u0, #gsi1sk = :gsi1sk_u0",
"ExpressionAttributeNames": {
"#status": "status",
"#points": "points",
"#comments": "comments",
"#updatedAt": "updatedAt",
"#gsi1sk": "gsi1sk"
},
"ExpressionAttributeValues": {
":status0": "in-progress",
":status_u0": "open",
":points_u0": 5,
":comments_u0": [
{
"user": "janet",
"body": "This seems half-baked."
}
],
":updatedAt_u0": 1630977029015,
":gsi1sk_u0": "$assignments#tasks_1#status_open"
},
"TableName": "your_table_name",
"Key": {
"pk": "$taskapp#team_core",
"sk": "$tasks_1#project_backend#task_45-662"
},
"ConditionExpression": "attribute_exists(pk) AND attribute_exists(sk) AND #status = :status0"
}
```[![Try it out!](https://img.shields.io/badge/electrodb-try_out_this_example_›-%23f9bd00?style=for-the-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