Answer the question
In order to leave comments, you need to log in
Why doesn't filtering work in ORM Sequelize by operator Op.ne?
Please tell me
why filtering users by id might not work
.
The goal is to get all users except the current one.
The code itself:
const Sequelize = require('sequelize')
const Op = Sequelize.Op
const User = require('../model/user.model')
exports.findUsers = async (request, response) => {
try {
const name = request.query.name;
const condition = { id: { [Op.ne]: request.userId } };
const data = await User.findAll({where: condition});
response.send(data);
} catch (e) {
response.status(500).send({
message:
'При получении списка пользователей возникла ошибка'
});
}
}
Answer the question
In order to leave comments, you need to log in
Turn on the logs and see what sql is generated when this query is called.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question