Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenriqueSilverio/82fbe6825b6a1bfc59f075065ee7c4c0 to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/82fbe6825b6a1bfc59f075065ee7c4c0 to your computer and use it in GitHub Desktop.

In a book rental app, to query a book that isn't returned yet (returnedAt is either null or undefined):

const rented = await this.db.rental.findFirst({
  where: {
    book: {
      uuid: params.id,
    },
    OR: [
      {
        returnedAt: null,
      },
      {
        returnedAt: {
          isSet: false,
        },
      },
    ],
  },
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment