Introducing PRISMA's innovative WHERE clause that filters arrays of enums

Here is my Prisma schema:

model User {
  id                         String    @id @default(uuid())
  email                      String    @unique
  mailing_address            String
  password                   String
  verification_token         String?
  verification_token_expires DateTime?
  reset_password_token       String?
  reset_password_expires     DateTime?
  name                       String?
  roles                      Role[]
  last_auth_change           DateTime  @default(now())
}

enum Role {
  SUPER_ADMIN
  ADMIN
  USER
  EMAIL_VERIFIED
  UNVERIFIED
}

I need to notify all super admins when a user verifies their email.

The SQL query for this task is :

'SELECT "id", "mailing_address", "roles" FROM "User" WHERE "roles" @> ARRAY[\'SUPER_ADMIN\']::"Role"[] ;'
However, I am having trouble figuring out how to achieve this using Prisma. When constructing the where clause for roles in Prisma, the only available option is equal.

Answer №1

Currently, there is an ongoing request for enhancements here, so the only available argument is equals.

If you need a workaround, you can utilize a raw query as demonstrated above by using prisma.$queryRaw.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

An example of using quotes within quotes is an HTML tag embedded within JavaScript code

Currently, I'm working on a JavaScript code where clicking assigns the function getImage the source of an image to be displayed later on the page. The issue I'm facing revolves around dealing with quotation marks. <img src="bill.jpg" class=" ...

React: Dealing with null values when making a PUT request using axios

I have a list obtained from an external API through the use of axios. Each element in the list is an editable input field with its own corresponding update button. Upon modifying the data in an input, and while executing a PUT request to update it, consol ...

What is the best method for retrieving a JSON string that contains commas?

I have a JSON data with coordinates: "geometry":{"type":"Point","coordinates":[95.9174,3.8394,59]},"id":"us10002b0v" I am looking to extract each value in the coordinates array that is comma separated. In PHP, I would use extract(",",$geometry[coordinat ...

Angular - Uncaught TypeError: XX is not a function on the site

Seems like I might be overlooking a property somewhere, but as I'm following this project, I encountered this error in my controller. TypeError: loginService.signin is not a function This is the content of my controller.js file angular.module(&apos ...

refreshing the webpage's content following the completion of an asynchronous request

I am working on an Ionic2 app that utilizes the SideMenu template. On the rootPage, I have the following code: export class HomePage { products: any = []; constructor(public navCtrl: NavController, public navParams: NavParams, private woo: WooCommer ...

Tips on preventing unexpected growth of rect width or height when snapping in Konva

While trying to resize a rectangle in order to make it into a perfect square, I encountered an issue where the height or width of the rectangle would unexpectedly grow. This can be seen in the GIF below: https://i.sstatic.net/SBFZR.gif You can view the c ...

How can I color the first, second, and third buttons when the third button is clicked? And how can I color all the buttons when the fourth button is clicked?

I am trying to achieve a task with 4 buttons. When the third button is clicked, I want the first, second, and third buttons to change color. Similarly, when the fourth button is clicked, I want all buttons to change color. Additionally, I need to save a va ...

Can you guide me on implementing an onclick event using HTML, CSS, and JavaScript?

I am looking for a way to change the CSS codes of the blog1popup class when the image is clicked. I already know how to do this using hover, but I need help making it happen on click instead. The element I want to use as the button; <div class=&quo ...

Troubleshooting focus problems with ng-if

Currently experiencing a focus issue while using Angular 1.6. Any suggestions on how to resolve this would be greatly appreciated. HTML <button type="button" data-ng-click="showPan()"> Show</button> <div data-ng-if="showPanDiv"& ...

OIDC - Additional parameters included in sign-in URL query string

I am working on a Javascript client that utilizes OIDC for authentication with the authorization code flow. Below is a snippet of the code: var config = { authority: "http://localhost:5000", client_id: "js", redirect_uri: &q ...

Prevent memory leakage by utilizing Angular's $interval feature in countdown processes

I have a controller set up to handle a countdown feature: var addzero; addzero = function(number) { if (number < 10) { return '0' + number; } return number; }; angular.module('theapp').controller('TematicCountdownCo ...

Retrieve information from Angular service's HTTP response

Calling all Angular/Javascript aficionados! I need some help with a service that makes API calls to fetch data: app.service("GetDivision", ["$http", function($http){ this.division = function(divisionNumber){ $http.post("/api/division", {division:di ...

Converting a multipart form data string into JSON format

Can you help me figure out how to convert a multipart form data into a JSON object in Node.js? I've been looking for the right module but haven't had any luck so far. Here is an example of my form data: ------WebKitFormBoundaryZfql9GlVvi0vwMml& ...

Showing the `ViewBag` data within the `@Html.DropDownListFor` method enclosed

I'm currently working with a DropDownListFor that is set up like this: <div class="form-horizontal" id=CurrencyDataBlock> @Html.DropDownListFor(model => model.Code, ViewBag.Currency as SelectList, "--Select Currency--", n ...

VARIABLE_NAME isn't functioning properly on the window

The code window.VARIABLE_NAME is not functioning properly and is causing the following error. Can you please provide assistance? Uncaught SyntaxError: Unexpected token. This is the code I have written: var window.testing ...

What is the process of creating a table in Oracle 11g R2 using a SELECT AS statement and then setting up range-list partitioning for the table?

In my current project, I am working on creating a brand new table called Titles2 that is derived from an existing table named Titles. The task involves utilizing a SELECT AS statement to establish the columns in Titles2 based on those in Titles. Additional ...

The issue of useEffect triggering twice is caused by React router redirection

In my route setup, I have the following configuration: <Route path={`list`} element={<ListPage />}> <Route path={`sidePanel1`} element={<SidePanel1 />} /> <Route path={`sidePanel2`} element={<SidePanel2 />} /> < ...

Tips for managing player rounds updates

How can I make the number of rounds increase by 1 every time a card is clicked, rather than jumping to 4 and staying there? The initial value is set at 'let rounds = 0;' in my code. <!DOCTYPE html> <html lang="en"> < ...

browsing through a timeline created using HTML and CSS

I am currently working on a web project that involves creating a timeline with rows of information, similar to a Gantt chart. Here are the key features I need: The ability for users to scroll horizontally through time. Vertical scrolling capability to na ...

Looking for a way to design versatile image sliders featuring multiple buttons for various sliders? I'm interested in crafting an image slider gallery tailored to different years

I am currently working on creating an image slider gallery displaying different years. However, I'm facing challenges in making it work properly. If I select a specific year like 2017, only the corresponding images should be displayed. Can someone ass ...