# Using multiple fields for a unique key in Prisma

> Learn how to use a compound unique key in Prisma with @@unique, and how to query or delete those rows using the combined user_tweet field with an underscore.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-07-29 | Topics: [Database](https://flaviocopes.com/tags/database/) | Canonical: https://flaviocopes.com/prisma-multiple-fields-unique-key/

I ran into an issue with [Prisma](https://flaviocopes.com/prisma/) that made me lose a bit of time, so I'll write how I solved it.

The model didn't have an `id` field marked as `@id` so I added a `@@unique()` to say `user` and `tweet`, together, defined the `unique` constrain.

```
model Like {
  user      Int
  tweet     Int
  createdAt DateTime @default(now())
  @@unique([user, tweet])
}
```

This means we can't have more than 1 same entries of `(user, tweet)` entries.

When I tried to delete an entry with

```js
await prisma.like.delete({
  where: {
    user: 1,
    tweet: 1
  }
})
```

I run into an error message: 

```
PrismaClientValidationError: 
Invalid `prisma.like.delete()` invocation:

{
  where: {
    user: 12,
    ~~~~
    tweet: 22
    ~~~~~
  }
  ~~~~~~~~~~~
}

Argument where of type LikeWhereUniqueInput needs exactly one argument, but you provided user and tweet. Please choose one. Available args: 
type LikeWhereUniqueInput {
  user_tweet?: LikeUserTweetCompoundUniqueInput
}
```

What I had to do was change 

```js
await prisma.like.delete({
  where: {
    user: 1,
    tweet: 1
  }
})
```

to

```js
await prisma.like.delete({
  where: {
    user_tweet: {
      user: 1,
      tweet: 1
    }
  }
})
```

In other words, combining the unique fields concatenating them with an underscore.

In retrospect the error message was sort of explaining this, but I didn't get it.
