Is there a smarter way to use optional query values

let newParentFolderId: string | undefined = getValue();

return db.query.imageFiles
  .findFirst({
    where: newParentFolderId ? eq(imageFiles.parentFolderId, newParentFolderId) : isNull(imageFiles.parentFolderId)
  })
.execute();

is there a cleaner way to not have to do things this way?
Was this page helpful?