Comments (5)
So I've been playing around with nosql-workbench from aws and they have a concept of a "facet".
Which is the "The access patterns of the application that will interact with the table."
In that GUI
You can define a name for your facet
an alias for the partion key
and an alias for your sort key
as well as "other attributes" to include
So perhaps in your domain object you can define a "facet" with its own primary and secondary key compositions as well as aliases. That way you're encouraging the end user to think about their access patterns before hand.
const item = {
globalSortKeyAlias,
primaryKeyAlias
}
User.query("facetName", item)
Perhaps other attribute projection is not part of the MVP
What do you think? I really like what you've done and I appreciate the care you've put in to encourage best practices and single table design with dynamo db. Thank you!
from dynamodb-toolbox.
Yes, querying seems to be the missing piece for my use cases as well. Thanks for a promising project!
from dynamodb-toolbox.
Thanks for the feedback and kind words @sreimer15! The access pattern/facet thing was something I was thinking about in issue #8, but that's an interesting thought to tie the two together.
I think there still needs to be a low-level querying capability, but definitely something to think of.
from dynamodb-toolbox.
@jeremydaly what do you think about this syntax for building the query params:
Model.query({
pk: 'hashKey', // you would use your Model's pk definition or alias here
index: 'gsiName', // optional, only if using a GSI with query
limit: 10, // optional limit
sortKey: { // optional, if omitted the query would just be on the partition key
operator: '=', // =, >, >=, <, <=, between, begins_with
value: '',
secondaryValue: '', // only used with between
consistentRead: true, // optional, default false
},
filter: { // filter is optional
key: 'keyName',
operator: '=', // =, >, >=, <, <=, between, begins_with
value: '',
secondaryValue: '' // only used with between
}
})
It seems like we could build all the syntax needed with that and it would similar syntax/methods as the get/put functionality in the library already. So a minimal example would look like:
const queryParams = MyModel.query({ pk: '123abc' })
And a more complete example:
const queryParams = MyModel.query({
pk: '123abc',
limit: 10,
sortKey: {
operator: 'begins_with'
value: 'meta' // the first part of a compounded key
}
})
from dynamodb-toolbox.
Added in the v0.2 branch.
from dynamodb-toolbox.
Related Issues (20)
- retrieve auto-generated partition key HOT 1
- EntityItem type infer not work HOT 3
- Typescript issue while declaring entity HOT 10
- ⭐️ Support for batch operations (get & put)
- ⭐️ Support for transactions
- Provided key element does not match the schema HOT 5
- Type inference for batch operations
- get,put,update method type inference incorrect when extending Entity HOT 3
- Document that `type: "set"` and `convertClassInstanceToMap: true` do not go well together HOT 1
- Attributes with defaults that have depend on unresolvable attribute should be ignored
- Type Inference Issue with `Entity.get()` When Used Inside a Class Constructor HOT 10
- Derived state HOT 5
- Invalid Entity ? Is it related to the some version ? HOT 1
- Type inference of entity using EntityItem<typeof MyEntity> not resolving alias HOT 1
- Inferred Type cannot be named without reference to "ts-toolbelt" HOT 4
- Overlays break many constructor inputs
- Error when importing abstraction that uses dynamodb-toolbox HOT 1
- Bug on Item.get, where unneeded properties are required HOT 2
- Error when sending EntityV2 `GetItemCommand` with property of type `binary()` HOT 2
- Undefined dependencies for Index keys cause Update / Put failures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamodb-toolbox.