鑑於我有一個名爲Model
的模型,其中包含一個包含字符串數組的items
列,如何查詢字符串queryString
是否在數組中或數組中有一個類似的元素?Sequelize PostgreSQL:查詢字符串是否在數組中
實施例:
items: ["cat", "dog", "bird", "turtle", "doe" ]
queryString = ["%do%","%b"]
應返回:
animalArray = ["dog", "doe", "bird"]
編輯:有沒有辦法將$重疊與iLike配對?
Model.findAll({
where: {
items: { $in: { $iLike: { $any: queryString } } }
}
}).then(function(array){
// Do whatever here with array
})
$iLike
是Sequelize
由於特殊的Postgres的事情!
錯誤的數據結構。參考postgresql數組文件(它說如果你正在搜索你的數組,你得到了錯誤的結果) – e4c5