Skip to content

How fix lint operator does not exist: uuid = text #198

Answered by Newbie012
sergiohdljr asked this question in Q&A
Discussion options

You must be logged in to vote

@sergiohdljr there are many libraries which support branded types such as zod's brand.

First, define your UUID brand:

import { z } from "zod";

const UUID = z.string.brand<"UUID">();
type UUID = z.infer<typeof UUID>;

Second, tell SafeQL to treat uuid as your branded UUID (instead of the default string) using overrides.types:

{
  "connections": {
    "overrides": {
      "types": {
        "uuid": "UUID"
      }
    }
  }
}

Lastly, this is how you code should like:

import { UUID } from "./uuid";

function run(id: UUID) {
  return sql`DELETE FROM farmacia WHERE id = ${id}`
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@pokedotdev
Comment options

@Newbie012
Comment options

@sergiohdljr
Comment options

@Newbie012
Comment options

Answer selected by Newbie012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants