Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add support for serialization groups (#5416)
Every property can specify its serialization groups, which are then used with explicit serialization. > Properties without the `groups` option are always included. Let's consider the following entity: ```ts @entity() class User { @PrimaryKey() id!: number; @Property() username!: string; @Property({ groups: ['public', 'private'] }) name!: string; @Property({ groups: ['private'] }) email!: string; } ``` Now when you call `serialize()`: - without the `groups` option, you get all the properties - with `groups: ['public']` you get `id`, `username` and `name` properties - with `groups: ['private']` you get `id`, `username`, `name` and `email` properties - with `groups: []` you get only the `id` and `username` properties (those without groups) ```ts const dto1 = serialize(user); // User { id: 1, username: 'foo', name: 'Jon', email: 'jon@example.com' } const dto2 = serialize(user, { groups: ['public'] }); // User { id: 1, username: 'foo', name: 'Jon' } ```
- Loading branch information
Showing
8 changed files
with
151 additions
and
39 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
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
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