Comments (7)
@tywalch I tried using CustomAttributeType
per your example but I'm getting this error:
Exported variable 'MyEntity' has or is using name 'OpaquePrimitiveSymbol' from external module "/Users/me/Projects/app/node_modules/electrodb/index" but cannot be named.
Any ideas? Your playground link works fine though.
Typescript version: 4.9.4 (latest)
ElectrodDB version: 2.3.5 (latest)
from electrodb.
@ari-becker checking in, we're you able to resolve your typing issue?
Hey, this came up in a side project of mine, no further progress beyond my last comment 🙂
from electrodb.
For this, I would recommend use of CustomAttributeType to accomplish this -- would that work in your case? I'd imagine given your example it'd be able to accomplish your needs and has the benefit of already being available.
My hesitancy around numeric enums is that Electro can't really enforce what values could end up in the table, when you consider atomic mutations like add and subtract, etc. A formal numeric enum might give users the impression that'd be handled by the library somehow.
from electrodb.
Got it. The following seems (at first glance) to work:
{
attributes: {
ratingNumStars: {
type: CustomAttributeType<0 | 1 | 2 | 3 | 4 | 5>('number'),
default: 0
}
}
}
although, for what it's worth, putting an invalid value in for the default (e.g. 6
) doesn't cause a type error.
from electrodb.
Could it be your version of TypeScript? Here is an example in the playground, which uses the latest version of TypeScript:
from electrodb.
@ari-becker checking in, we're you able to resolve your typing issue?
from electrodb.
Thanks for checking back in, if you ever pick things back up be sure to let me know and we can get to the bottom of what you're looking at 👍
from electrodb.
Related Issues (20)
- Map attribute with required property creates undefined when property is not present or empty HOT 2
- Support readonly attributes for rebuilding a composite sort key HOT 7
- Computed attributes ignore `field` property during update HOT 4
- Secondary index keys not updated when using composite attributes from table's primary index HOT 13
- RFC: Add support for namespacing partitions HOT 7
- Setting initial value for attribute AND performing ADD operation within single `update` call on an Entity object HOT 4
- Feature request: Add Conditional Indexing Based on Attribute Presence HOT 2
- Missing `add` Method in Upsert for Transactional Writes HOT 2
- Table in Section "Attribute Options" malformed HOT 1
- Numeric sort key being ignored when building query params on a query operation. HOT 1
- Feature Request: BatchWrite across entities HOT 2
- UpdateExpression created by `.patch` doesn't account for custom attribute `field` value HOT 3
- ExpressionAttributeNames/Values can include hyphens HOT 5
- Modeling single-partition data HOT 2
- ElectroDB playground: After Page Load, the caret in code-editor is not aligned with the letters sometimes
- Specifying `response: 'all_new'` on `.update()` returns `Partial<T>` instead of `T` HOT 2
- Broken link in docs (Pagination) HOT 2
- Improve schema type using const type parameters
- Removing attributes with upsert HOT 9
- Invalid params generated for patch/update where table/GSI specified with Composite Attribute Templates HOT 1
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.