-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(repository): include navigation properties in JSON #3188
Conversation
Modify the code converting Model instances to JSON data to include navigational properties for the defined model relations. Signed-off-by: Miroslav Bajtoš <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
From #3171: it('includes TodoList in query result', async () => {
const list = await givenTodoListInstance(todoListRepo);
const todo = await givenTodoInstance(todoRepo, {todoListId: list.id});
const filter = JSON.stringify({include: [{relation: 'todoList'}]});
const response = await client.get('/todos').query({filter: filter});
expect(response.body).to.have.length(1);
expect(response.body[0]).to.deepEqual({
...toJSON(todo),
todoList: toJSON(list),
}); This test along with the symmetrical
From @bajtos:
|
|
||
target: () => Product, | ||
keyTo: 'categoryId', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: IIRC, {...} as HasManyDefinition
is a recommended style over <HasManyDefinition>{...}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. From what I remember, when using {...} as HasManyDefinition
, TypeScript is not able to offer correct suggestions (auto-completion) for members of the object being created :(
Modify the code converting Model instances to JSON data to include navigational properties for the defined model relations.
See #3171 and #2633
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈