Working with zod and fastify, my UserModel includes the username and device properties. The username is a string, while the device consists of "name", "id", and "verified" fields in an object (DeviceModel).
For the sign-up process, I need to return the complete user object but exclude certain nested properties from DeviceModel. To address this, I plan to create a UserSignUpResponse by using the following method:
const UserSignUpResponse = UserModel.pick({
username: true,
// struggling with the next step
device: DeviceModel.pick({
id: true,
name: true,
verified: false,
})
});
My query is whether I should ".pick fields from the UserModel schema and add a device field with the same properties as DeviceModel?"