You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When querying DynamoDB using Table.getItem() or Table.queryItems(), params.fields are ignored and full objects are returned. When querying using Model.get() or Model.find(), everything works as expected and only the requested fields are returned.
To Reproduce
Full details can be found the test/debug.ts file here. I'll copy/paste an outline of the issue below.
const User = table.getModel('User')
const userProperties = {
name: "Daenerys I Targaryen",
nickName: "Breaker of chains",
email: "iHeartDragons@example.com",
}
const user = await User.create(userProperties)
const userId = user.id!
test('model.get() respects the fields.', async () => {
// Works as expected, only returns id and name.
const user = await User.get({pk: userId}, {fields: ["id", "name"], parse: true})
expect(user).toMatchObject({
name: "Daenerys I Targaryen",
});
expect(user!.id).toMatch(Match.ulid);
expect(user!.nickName).toBeUndefined();
expect(user!.email).toBeUndefined();
})
test('table.getItem() does not respect the fields.', async () => {
// Should break but doesn't because the entire record is returned.
let tableGetItem = await table.getItem({pk: userId}, {fields: ["id", "name"], parse: true})
expect(tableGetItem).toMatchObject(userProperties);
})
Expected behavior Table.getItem() and Table.queryItems() should respect the params.fields and return only the requested fields.
Environment (please complete the following information):
OS: macOS Venture 13.4.1 (22F82)
Node Version: v18.16.0
OneTable Version: 2.6.4
TypeScript Version: 5.1.6
The text was updated successfully, but these errors were encountered:
Describe the bug
When querying DynamoDB using
Table.getItem()
orTable.queryItems()
,params.fields
are ignored and full objects are returned. When querying usingModel.get()
orModel.find()
, everything works as expected and only the requested fields are returned.To Reproduce
Full details can be found the
test/debug.ts
file here. I'll copy/paste an outline of the issue below.Cut/Paste
Schema
Test
Expected behavior
Table.getItem()
andTable.queryItems()
should respect theparams.fields
and return only the requested fields.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: