-
-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): strict partial loading (#4092)
The `Loaded` type is now improved to support the partial loading hints (`fields` option). When used, the returned type will only allow accessing selected properties. Primary keys are automatically selected. ```ts // book is typed to `Selected<Book, 'author', 'title' | 'author.email'>` const book = await em.findOneOrFail(Book, 1, { fields: ['title', 'author.email'], populate: ['author'], }); const id = book.id; // ok, PK is selected automatically const title = book.title; // ok, title is selected const publisher = book.publisher; // fail, not selected const author = book.author.id; // ok, PK is selected automatically const email = book.author.email; // ok, selected const name = book.author.name; // fail, not selected ``` BREAKING CHANGE: `FindOptions.fields` now accepts only array of strings, like `populate`. Closes #3443
- Loading branch information
Showing
29 changed files
with
305 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.