Skip to content

How can i get mask from Inet field type #17903

Answered by RrredHead
RrredHead asked this question in Q&A
Discussion options

You must be logged in to vote

OK, I've found one workaround:

async function findIPs() {
    const result = await prisma.$queryRaw<
        IP[]
    >`SELECT id, description, "updatedAt", text(address) as address FROM public."IP"`;
    return result;
}

// ... later in route handler

const ips = await findIPs();
return ips;

This gives me output as I expected:

[
  {
    "id": 2,
    "description": "Localhost",
    "updatedAt": "2023-02-13T14:05:04.121Z",
    "address": "127.0.0.0/16"
  }
]

But I'm quite sure that function text have to be applied when casting postgres INET datatype to JS String by default 🤔

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ludralph
Comment options

Answer selected by RrredHead
Comment options

You must be logged in to vote
1 reply
@ludralph
Comment options

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