Query the database with MySQL Sequelize to retrieve all data that shares the same field but have different values

When searching for data using the same field in mysql with different values, I am experiencing issues with receiving empty values in response.

I attempted to use the $and condition in sequelize to find the data, but unfortunately, I am not getting any data in response.

 exports.multibranchdata = (req, res) => {

 const wherequery = { 
             $and: [{ id: { eq: 1 } },
                    { id: { eq: 2 } }
                   ] };
 branch.findAll(wherequery)

.then(data => res.status(200).send(data))

.catch(Sequelize.ValidationError, err => 
 res.status(422).send(err.errors[0].message))

.catch(err => res.status(400).send(err.message));
 };

Answer №1

Give the OR query a shot :-

 const wherequery = { 
             $or: [{ id: { eq: 10 } },
                    { id: { eq: 20 } }
                   ] };

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

I am currently attempting to find a color picker element within a parent class using Cypress CSS Locator. While I am able to reach the parent element, I am unsure of the correct method to target the

My user interface has a list of elements displayed in 2 columns. The first column shows the name of the item, such as Manager, Operator, and the list is expected to grow. The second column consists of a color picker element where you can choose a color. I ...

Looking to showcase an array in a MessageBox featuring rows of Assignment Names and columns of Student Names

I have successfully transposed an array of student grades on assignments, but I am struggling to display the data in a MessageBox with row and column labels. Currently, the output MessageBox only shows a 3x5 matrix of grades: decimal[,] decGrades = { ...

Why am I unable to attach this to JQuery?

$("input").keydown(function(event){ if(event.keyCode === 13){ return false; } }); I need to prevent the default action when the "enter" key is pressed in any of my text input fie ...

The functionality of create-react-app has been malfunctioning ever since the release of version 4.0.1. Is there a way to successfully remove the outdated version and

After running the command npx create-react-app ./ to create a React app, I encountered a warning message and the app was not created as expected. To resolve this issue, it is recommended to remove any global installs using one of the following commands: - ...

Tips for selecting and utilizing a drop-down menu in JavaScript

Having an issue with the drop-down list functionality. It seems to only work with the first option selected and not with all of them. Any assistance would be greatly appreciated. Thank you in advance. var form1 = document.getElementById('form1' ...

Can you explain the distinction between #define and int in C programming when utilizing arrays?

As I delve into learning C programming, I've encountered a question regarding the most efficient way to declare an array. My instructor suggests using a variable that stores the size value: #include <stdio.h> #include <stdlib.h> int main ...

What is the process for generating and combining two lists in a flutter application?

How can I merge two arrays and create a list in Flutter? I need to combine the lists for Background and Sound into separate lists. Below is the code snippet I have provided. class myModel { myModel({ required this.bg, }); List<Background> bg; fact ...

What causes a TypeError (Invalid response status code) when a 204 response is returned to a fetch() call within a React Server Component?

Take a look at this straightforward Next.js application: https://codesandbox.io/p/sandbox/next-js-app-router-1bvd7d?file=README.md Here is an API route (/api/hello): export default function handler(req, res) { res.status(204).end(); } And there's ...

Error: The 'encoding' property cannot be set on null objects in THREE.js

I have been trying to load a basic grass block from Minecraft, but I keep encountering an error message that says TypeError: Cannot set properties of null (setting 'encoding'). This error originates from line 2893 in GLTFLoader, specifically the ...

A step-by-step guide on generating an HTML table from JSON information

Hi there, I'm looking to create a table format using JSON data. Here is an example of the JSON data: var jsondata = [ { id: 1, name: 'Mani', subject: 'English', Score: 88 }, { id ...

Is there a way to use jQuery to retrieve the date and time from a timestamp within an input field?

Hey, I've encountered an issue with jQuery and the UI date picker. Currently, my NEW event form has 3 fields: Date, timeFrom, timeTo. In my SQL database, I have corresponding fields: Date(datetime), timeFrom(time), timeTo(time). When a user selects ...

The URL for the form action does not match the URL of the current page

Issue: I'm encountering an issue with a form where the form action URL is different from the page URL where the form is located. Page URL = www.page.com Form action = "" Problem: After submitting the form, it redirects to the form action URL inst ...

Obtain directive content in AngularJS prior to compilation

Is there a way to extract the HTML content of a directive prior to compilation? For instance, consider the following: <my-directive> <ul> <li ng-repeat="item in items">{{item.label}}</li> </ul> </my-directive> ...

What are the steps to crafting a basic JavaScript or jQuery function within CodeIgniter?

I'm currently working on creating a basic JavaScript function within CodeIgniter that is triggered when a radio button is clicked. <input type="radio" name="amount" value="<?php echo $plan['amount']; ?>" onclick="fn()" /> The J ...

Storing data with NPM global packages: Best practices

I have developed a global npm package that functions as a CLI tool. https://i.sstatic.net/PdT3Z.png My goal is to customize the user experience by having the package remember the user's previous choices. For example, if the user selects 'Iphone ...

Angular Swiper Integration: Maintaining Scope Inside Configuration Callback

Trying to grasp the concept of working with callbacks to maintain scope can be a bit tricky, as I've been experiencing. Specifically, I've been struggling with a callback in the Swiper library for Angular, where I am unable to keep my desired sco ...

The height of the div is set to zero within the $(document).ready() function

From what I understand, when we write JQuery code inside $(document).ready(), the code will only be executed after the DOM has finished rendering. I encountered an issue where I was trying to calculate the height of a div inside $(document).ready() but it ...

Sending arguments enclosed in double quotation marks

Having an issue while trying to pass a variable with the character ", especially when dealing with "Big Bang". <?php echo $aux; //Hi! "Text" Text2'Text3 ?> //mysql_real_escape_string($aux); addslashes($aux); //output Hi! \"Big Bang&bso ...

Utilizing Ajax to send IP addresses and obtain location data

Is there a website or webpage that can be used to input a user's IP address and receive their country or location as plain text? Below is a code snippet demonstrating how I attempted to retrieve the user's IP address: I inserted the following c ...

Disabling contentType and processData parameters in a POST request, causes the request to be processed without any

Attempting to send a file to my server through AJAX has been successful. However, the issue arises when I include contentType: false and processData: false. var formData = new FormData(); formData.append('image', input.files[0]); $.ajax({ u ...