Comments (2)
For context, are you speaking about something like this?
/* Model queries, see results, share with friends */
import { Entity, Service } from "electrodb";
const table = "your_table_name";
/* Tasks Entity */
const listHolder = new Entity(
{
model: {
entity: "listHolder",
version: "1",
service: "app"
},
attributes: {
id: {
type: 'string',
required: true,
},
set: {
type: 'set',
items: 'string',
required: true,
default: [],
},
},
indexes: {
main: {
pk: {
field: 'pk',
composite: ['id'],
}
}
}
},
{ table }
);
async function demonstrateIssue() {
await listHolder
.create({ id: 'example', set: [] })
.go();
const { data } = await listHolder
.get({ id: 'example' })
.go();
if (!data) return;
console.log(data.set.length); // TypeError: Cannot read property 'length' of undefined
}
This one got me today.
from electrodb.
Our workaround:
- set
convertEmptyValues: true
DynamoDBDocumentClient.from(ddbClient, {
marshallOptions: {
convertEmptyValues: true,
},
})
Note that convertEmptyValues: true
also sets empty strings / blobs to null, so you have to use a get() hook there too.
- use a get() hook to replace null values:
attributes: {
set: {
type: 'set',
required: true,
items: ['A', 'B', 'C'] as const,
get: (val: any, item: any) => val !== null ? val : [],
},
},
It's weird that the document client allows empty strings, but doesn't allow empty sets, even though it's possible to add empty sets manually in AWS.
from electrodb.
Related Issues (20)
- 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
- Typescript Warning when Omitting Non Required Attributes on Create/ Put HOT 2
- How to create a map attribute with unknown keys? HOT 2
- How to get cursor for each item returned by a query? HOT 3
- How does it work with Python? HOT 2
- Filter expressions: Where In operation
- Malformed cursor causing issues with paginated queries HOT 3
- Index condition does only identify impacted pk on upsert and not on patch or update HOT 18
- key should be case sensitive HOT 1
- Support `ConsistentRead` option HOT 2
- Update nested Map value using set() method. HOT 2
- Incorrect key generated when using composite operation on patch/update HOT 3
- Doc example incorrect and misleading HOT 3
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.