How to check if an entry already exist?

I found this query to check if an entry in the table already exists:
      await db.execute(
        sql`select exists(select 1 from ${posts} where ${posts.slug} = ${slug})`,
      )

Which returns the response: Result(1) [ { exists: false } ]
but how do I use it in a typescript if statement to run conditional code?
Was this page helpful?