This documentation is deprecated. It covers rspc 0.3.0, which is no longer maintained.
Selection
If you are using Prisma Client Rust with rspc generally use select & include instead of this.
It is very common when building an API to fetch some data from the database but you only want to expose a subset of the data to the client. With rspc you can use the selection! macro to easily return a subset of fields on a struct.
For example say you have a User struct like the following:
If your database returns a User struct you are unable to return it directly from your procedure as that would leak the value in the password field. Traditionally you would have to create a second struct without the password field, however this isn't optimal as it adds unnecessary boilerplate to your project. Instead you can use the selection! macro like below to select only certain fields from the struct.
