electrodb
Advanced tools
Comparing version 0.8.15 to 0.8.16
{ | ||
"name": "electrodb", | ||
"version": "0.8.15", | ||
"version": "0.8.16", | ||
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,43 @@ # ElectroDB | ||
Turn this: | ||
```javascript | ||
let MallStores = new Entity(model, client); | ||
let mallId = "EastPointe"; | ||
let stateDate = "2020-04-01"; | ||
let endDate = "2020-07-01"; | ||
let maxRent = "5000.00"; | ||
let minRent = "2000.00"; | ||
let promotion = "1000.00"; | ||
let stores = MallStores.query | ||
.leases({ mallId }) | ||
.between({ leaseEndDate: stateDate }, { leaseEndDate: endDate }) | ||
.filter(({rent, discount}) => ` | ||
${rent.between(minRent, maxRent)} AND ${discount.lte(promotion)} | ||
`) | ||
.params(); | ||
``` | ||
Into This: | ||
```javascript | ||
{ | ||
"IndexName": idx2', | ||
TableName: 'electro', | ||
ExpressionAttributeNames: { | ||
'#rent': 'rent', | ||
'#discount': 'discount', | ||
'#pk': 'idx2pk', | ||
'#sk1': 'idx2sk' | ||
}, | ||
ExpressionAttributeValues: { | ||
':rent1': '2000.00', | ||
':rent2': '5000.00', | ||
':discount1': '1000.00', | ||
':pk': '$mallstoredirectory_1#mallid_eastpointe', | ||
':sk1': '$mallstore#leaseenddate_2020-04-01#rent_', | ||
':sk2': '$mallstore#leaseenddate_2020-07-01#rent_' | ||
}, | ||
KeyConditionExpression: '#pk = :pk and #sk1 BETWEEN :sk1 AND :sk2', | ||
FilterExpression: '(#rent between :rent1 and :rent2) AND #discount <= :discount1' | ||
} | ||
``` | ||
Table of Contents | ||
@@ -36,3 +77,3 @@ ================= | ||
- [Sort Key Operations](#sort-key-operations) | ||
- [Using Facets to Make Heretical Keys](#using-facets-to-make-heretical-keys) | ||
- [Using facets to make hierarchical keys](#using-facets-to-make-hierarchical-keys) | ||
- [Shopping Mall Stores](#shopping-mall-stores) | ||
@@ -47,3 +88,3 @@ - [Query Chains](#query-chains) | ||
- [Partition Key Facets](#partition-key-facets) | ||
- [Execute Query `.go() and .params()`](#execute-query-go-and-params) | ||
- [Execute Query `.go() and .params()`](#execute-query-go-and-params) | ||
- [`.params()`](#params) | ||
@@ -67,3 +108,3 @@ - [`.go()`](#go) | ||
- [Find Stores that match core access patterns](#find-stores-that-match-core-access-patterns) | ||
- [Coming Soon:](#coming-soon) | ||
- [Coming Soon:](#coming-soon) | ||
@@ -205,4 +246,4 @@ # Installation | ||
"cast": ["number"|"string"|"boolean"], | ||
get: (attribute, schema) => value, | ||
set: (attribute, schema) => value | ||
"get": (attribute, schema) => value, | ||
"set": (attribute, schema) => value | ||
} | ||
@@ -584,3 +625,3 @@ } | ||
### Using Facets to Make Heretical Keys | ||
### Using facets to make hierarchical keys | ||
Carefully considering your **Facet** order will allow ***ElectroDB** to express hierarchical relationships and unlock more available **Access Patterns** for your application. | ||
@@ -777,4 +818,4 @@ | ||
// Each Access Pattern is available on the Entity instance | ||
// MallStore.stores() | ||
// MallStore.malls() | ||
// MallStore.query.stores() | ||
// MallStore.query.malls() | ||
``` | ||
@@ -794,9 +835,9 @@ | ||
// Good: As an object | ||
MallStore.stores({storeId}); | ||
MallStore.query.stores({storeId}); | ||
// Bad: Facets missing, will throw | ||
MallStore.stores(); // err: Params passed to ENTITY method, must only include storeId | ||
MallStore.query.stores(); // err: Params passed to ENTITY method, must only include storeId | ||
// Bad: Facets not included, will throw | ||
MallStore.stores({mallId}); // err: Params passed to ENTITY method, must only include storeId | ||
MallStore.query.stores({mallId}); // err: Params passed to ENTITY method, must only include storeId | ||
``` | ||
@@ -806,3 +847,3 @@ | ||
### Execute Query `.go() and .params()` | ||
## Execute Query `.go() and .params()` | ||
Lastly, all query chains end with either a `.go()` or a `.params()` method invocation. These will either execute the query to DynamoDB (`.go()`) or return formatted parameters for use with the DynamoDB docClient (`.params()`). | ||
@@ -1096,6 +1137,6 @@ | ||
``` | ||
## Coming Soon: | ||
# Coming Soon: | ||
- `Collection` class for relating and querying across multiple entities, configuring/enforcing relationships | ||
- `.page()` finish method (like `.params()` and `.go()`) to allow for easier pagination of results | ||
- Additional query options like `limit`, `pages`, `attributes`, `sort` and more for easier querying. | ||
- Default query options defined on the `model` to give more general control of interactions with the Entity. | ||
- Default query options defined on the `model` to give more general control of interactions with the Entity. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228286
1133