gpt4 book ai didi

node.js - Sequelize findAll [Op.or] 是否按顺序返回?

转载 作者:行者123 更新时间:2023-12-03 22:34:32 25 4
gpt4 key购买 nike

假设我有这个非常基本的搜索


const from = 'something';
const to = 'somethingElse';

const firstSearchCondition = { from, to: 'test' };
const secondSearchCondition = { from: 'test', to };

const models = await Model.findAll({
where: {
[Op.or]: [
firstSearchCondition,
secondSearchCondition
],
},
});

const [toTest, fromTest] = models;

if (toTest && fromTest) {
// both models exist
}

当两种模型都存在时, toTest 是否 100% 来自 firstSearchCondition?或订单无法保证

最佳答案

除非您使用 order by 子句,否则无法保证订单。不管查询。

关于node.js - Sequelize findAll [Op.or] 是否按顺序返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62807746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com