Comments (2)
Hi @raryanpur 👋
Thanks for submitting this! Ultimately the reason this validation exists on the attribute name (as opposed to the field) is because the attribute name is what's used when performing a collection query. The validation prevents ambiguity around which attributes must be provided to perform the query, and keeps the api simple. For example, if the entities you included were not validated this way, which query would be correct?
service.collections.patrons({ restaurantId: 'wendys' }).go();
service.collections.patrons({ id: 'wendys' }).go();
service.collections.patrons({ id: 'wendys', restaurantId: 'wendys' }).go();
Going a step further, if the "customer" entity was defined with an id
field as well (which I think would be likely with this pattern, then id
it gains additional ambiguity:
{
model: {
entity: "customer",
service: "app",
version: "1"
},
attributes: {
id: {
type: "string"
},
restaurantId: {
type: "string"
},
name: {
type: "string"
}
},
indexes: {
record: {
collection: "patrons"
pk: {
field: "pk",
composite: ["restaurantId"],
},
sk: {
field: "sk",
composite: ["id"],
},
}
}
}
These are just a few examples to illustrate why the library optimizes a bit more for simplicity here. The typing system also benefits from this approach, which is a top priority for the library. Definitely share any thoughts you have about the above however, the more brains on this topic the better because it has come up before!
from electrodb.
Thanks for the info! Need some time to digest but makes sense on first pass 👍🏼
from electrodb.
Related Issues (20)
- ReturnValuesOnConditionCheckFailure is not available for non-transactional operations HOT 9
- Setter not triggered on removing a watching attribute HOT 1
- feature: support async getters/setters HOT 3
- Error: Cannot find module '@aws-sdk/lib-dynamodb/dist-cjs/commands/utils' HOT 6
- unmarshallOutput issue with @aws-sdk/lib-dynamodb HOT 8
- Bug: apply `default` on upsert only for new items HOT 2
- Item update FAILS - error message contains broken link - need help / would like to fix docs HOT 2
- Collections issue : Trying to query across entities using collections but getting error HOT 11
- Is this a feature or a bug? HOT 1
- Incorrect params for patch/update for clustered index with no sort key HOT 4
- Docs: Index Scope is not documented in 'index options' HOT 1
- Docs: 'project' index option is not documented HOT 1
- Reverse index (sk,pk) in addition to (pk,sk) leads to error message HOT 1
- Q: Is it possible to run a query for the count of items, not the items themselves? HOT 1
- Redundant FilterExpression in query of hierarchical sort key
- Item order is broken in BatchGet and in queries using hydration HOT 2
- More Hassle Than Help: Prefix Issues in Composite Keys and Other Frustrations Lead Us to Drop ElectroDB :( HOT 1
- validate using another fields value? HOT 1
- Empty array as default for "set" type shouldn't pass schema validation HOT 2
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 electrodb.