基于此:http://docs.sequelizejs.com/manual/tutorial/models-usage.html#nested-eager-loading(在顶级条件下,您可以在其中使用'$ nested.column $')
我正在尝试根据嵌套对象内部的值查找对象。它应该返回父对象。这是我想出的,但是还没有成功:
return River.findAll({
where: {
'$geojson.features.properties.TMPRIV_ID$': TMPRIV_ID,
},
});
这是一个精品对象:
{
name: 'Olifants',
geojson: {
"type": "FeatureCollection",
"name": "olifants",
"features": [{
"type": "Feature",
"properties": {
"FNODE_": 8508,
"TNODE_": 8368,
"LPOLY_": 0,
"RPOLY_": 0,
"LENGTH": 0.1379216,
"TMPRIV_": 4683,
"TMPRIV_ID": 4683
}
},{...}]
}
}
我收到此错误:
SQLITE_ERROR:没有这样的列: geojson->功能->属性。TMPRIV_ID”,
{'$ nested.table.field $':'值'}
我尝试过:
"geojson.features.properties.TMPRIV_ID$": TMPRIV_ID
这是执行的SQL。如果我在SQL查询中运行它,则返回0列:
SELECT `id`, `name`, `alternative`, `geojson`, `createdAt`, `updatedAt` FROM `rivers` AS `river` WHERE CAST(json_extract(`river`.`geojson`, '$.features.properties.TMPRIV_ID$') AS DOUBLE PRECISION) = 4683;