Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Latest commit

History

History
23 lines (17 loc) 路 887 Bytes

check-existence-GO-go01.mdx

File metadata and controls

23 lines (17 loc) 路 887 Bytes

import Collapse from 'components/Markdown/Collapse'

export const meta = { title: 'Check Existence (Go)', position: 110, technology: "go", technologyOrder: 3, articleGroup: "Check Existence", }

Overview

The Prisma client lets you check whether a certain record exists in the database using the Exists property. For each model type in your datamodel, the Prisma client exposes one function on this property named after the model (but lowercased). Each of these functions receives a a filter object as input argument that specifies the conditions for the record and returns a boolean value that's true if there's at least one database record matching the specified filter, false otherwise.

Examples

Check if a user with a certain ID exists:

userExists := client.Exists.User(&prisma.UserWhereUniqueInput{
  ID: "cjli6tko8005t0a23fid7kke7",
})