sensedeep / dynamodb-onetable

DynamoDB access and management for one table designs with NodeJS
https://doc.onetable.io/
MIT License
680 stars 110 forks source link

Feature: Across entities query #503

Open yamatatsu opened 1 year ago

yamatatsu commented 1 year ago

Across entities query is the essence of single-table design. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-relational-modeling.html

As electrodb, if also onetable gets support of across entities query, it will be super extra value of this product I think. https://electrodb.dev/en/core-concepts/single-table-relationships/

mobsense commented 1 year ago

Generally, we try to design our keys and indexes so that a single query can fetch a collection. Is this what you mean or do you mean OneTable providing an API that will do multiple low level DynamoDB operations?

Can you give an example:

yamatatsu commented 1 year ago

Hi mobsense.

I mean to get multiple entities not items.

Example:

await table.find(["User", "Order"], { userId: "user_anyuuid1" });
// return: {
//   user: [
//     {
//       pk: "user_anyuuid1",
//       sk: "user_anyuuid1",
//       userId: "user_anyuuid1",
//     }
//   ],
//   order: [
//     {
//       pk: "user_anyuuid1",
//       sk: "order_anyuuid1",
//       orderId: "order_anyuuid1",
//       orderedBy: "user_anyuuid1",
//     },
//     {
//       pk: "user_anyuuid1",
//       sk: "order_anyuuid2",
//       orderId: "order_anyuuid2",
//       orderedBy: "user_anyuuid1",
//     },
//   ]
// }

ElectroDB can query like as this with typescript typing. https://electrodb.dev/en/modeling/collections/

I believe it is very helpful for users using TS.

mobsense commented 1 year ago

Thank you.

darbio commented 3 months ago

This would be a great addition to the library.