Mapping Database Query Results to Branded Types in TypeScript

Hi, how do I map the results from a database query (using drizzle) to a version where some the values consist of branded types. For example my productId is a Schema.String.pipe(Schema.brand("ProductId"));

Effect.gen(function* () {
          const [createdProduct] = yield* Effect.tryPromise<
            Array<typeof Product.Type>,
            Error
          >({
            try: () =>
              // This is the part that errors, because the ID of the returned product is missing the branded type 
              database.drizzle
                .insert(productsTable)
                .values({
                  organizationId,
                  title: product.title,
                  description: product.description,
                  status: product.status,
                })
                .returning(),
            catch: () => {
              throw new Error();
            },
          });
          return createdProduct;
        }),`
Was this page helpful?