【发布时间】:2017-04-21 22:03:40
【问题描述】:
鉴于我有一个名为 Model 的模型,其中包含一个名为 items 的列,其中包含一个字符串数组,我如何查询字符串 queryString 是否在数组中或在数组?
示例:
items: ["cat", "dog", "bird", "turtle", "doe" ]
queryString = ["%do%","%b"]
应该返回:
animalArray = ["dog", "doe", "bird"]
编辑:有没有办法以某种方式将 $overlap 与 $iLike 配对?
Model.findAll({
where: {
items: { $in: { $iLike: { $any: queryString } } }
}
}).then(function(array){
// Do whatever here with array
})
$iLike 是 Sequelize 中一个特殊的 Postgres 东西
谢谢!
【问题讨论】:
-
错误的数据结构。请参阅 postgresql 数组文档(它说如果你正在搜索你的数组,你得到了错误的结构)
标签: javascript sql postgresql sequelize.js