Comments (6)
Can you test if using params.fields
works. i.e.
ProjectionExpression: params.fields.length ? params.fields.join(', ') : undefined
from dynamodb-onetable.
@mobsense
I tried with this.params.fields.length ? this.params.fields.join(', ') : undefined
and it was working, but then i faced with another issue.
entity filed can not has a name as name
, and these cases should use ExpressionAttributeNames,
I am trying to say that params.fields
solves the problem only partially.
from dynamodb-onetable.
Can you please give more details and an example. I don't fully understand your comment. Sorry.
If it is a new issue, please open a new issue.
from dynamodb-onetable.
I did your fix in Expression.js
...
ProjectionExpression: params.fields && params.fields.length ? params.fields.join(', ') : undefined,
...
Then created a small test.
const { Model, Table } = require('dynamodb-onetable');
const { documentClient } = require('./src/db');
const myTableName = `myTable`;
const table = new Table({
client: documentClient,
name: myTableName,
});
const RoleModel = new Model(table, 'Role', {
fields: {
pk: { value: 'rbac' },
sk: { value: 'Role:${name}' },
name: { type: String, required: true },
permissions: { type: Array, required: true },
},
});
(async () => {
// ### add three role1, role2, role3
await Promise.all(
['1', '2', '3'].map(async (name) => {
await RoleModel.create({
name: `role${name}`,
permissions: [`get:/api/endpoint${name}`],
});
}),
);
// this Model.get() works fine
const roleOk = await RoleModel.get(
{
_type: `Role`,
},
{
fields: [
//
'updated',
],
},
);
console.log('### logOK:', roleOk);
// ### logOK: { updated: 1620050849535 }
const roleErr = await RoleModel.get(
{
name: `role1`,
},
{
fields: [
//
'name',
'permissions',
],
},
);
console.log('### log Err:', roleErr);
// it throws error
// Invalid ProjectionExpression: Attribute name is a reserved keyword; reserved keyword: name
// the same error for 'permissions' field name
})();
@mobsense
Hope now it's clear.
from dynamodb-onetable.
Thank you. We can reproduce this now. Will update with a fix later today.
from dynamodb-onetable.
The core issues is that ProjectionExpressions must use symbolic Attribute Names and Values to avoid the huge DynamoDB reserved word list.
This fix is cleaning up the handling of Attribute Names and Values by adding two functions addName and addValue, and also adding duplicate removal and optimization. i.e. you can use the same attribute name / value and it will only use one reference.
from dynamodb-onetable.
Related Issues (20)
- BatchWrite does not handle Unprocessed Items correctly and ignores them HOT 1
- "?boolean" in Table.d.ts triggers typescript build error HOT 2
- model.upsert({ ...data }) returns a data with encrypted values HOT 2
- Need release to resolve Typescript ESM Resolution issues HOT 2
- params.fields are not respected when using table.getItem() or table.queryItems()
- Metrics.d.ts should not include function interfaces declared as 'async' HOT 7
- Improve: Prohibit the removal of nested object required fields. HOT 1
- Feature: Across entities query HOT 3
- Empty strings are filtered out HOT 2
- Cannot resolve type when ESM HOT 3
- Compound global index not updated if only 1 of 2 properties passed to the update function HOT 1
- Updating unique template field does not remove unique record HOT 2
- "CredentialsProviderError: The SSO session associated with this profile has expired" in "overview" sample... HOT 2
- Create method does not create the sort key if one attribute is undefined HOT 4
- Connecting OneTable to a local dynamodb instance
- Support for Mapped Types HOT 3
- Please Help: Update Problem (referenced attribute) HOT 3
- OneSchema type for getCurrentSchema() not set HOT 2
- Update operation does not remove object from array HOT 1
- Help: retrieving items by GSI1 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 dynamodb-onetable.