Retaining TypeScript Brands During Encoding and Database Insertion

Is there a way to retain the "branding" when encoding? I am asking specifically about a string brand.
The reason I'm asking is because I have some brand types defined in my table schema, using Drizzle like:
  author: varchar('author', { length: 50 }).$type<ContactId>(),

But then, this also forces me to provide a ContactId when inserting the value into the database which I usually do after an encoding:
      const saveMessage = (message: Message) =>
        pipe(
          MessageData.encode(MessageData.fromMessage(message)), // this removes the brandh from author
          Effect.andThen((messageData) =>
            db.execute((_) =>
              _.insert(messagesTable).values(messageData).execute()
            )
          ),
Was this page helpful?