如何从 sql 对象(CRATE DB)中查询项目
How to query an item from an sql object (CRATE DB)
我正在尝试使用新的 crate 数据库。 link
我有一个 table,其中包含一个 "infrastructure" 和 "network" 个对象:
CREATE TABLE servers (infrastructure object(strict) as (
#etc...
os_name string,
#etc...
network array(object as
(etc.., hosting_id string, etc... ))
我需要从 "infrastructure" 中查询 os_name 并从网络数组中查询 hosting_id。我该怎么做?我试图 google 找到正确的语法但没有成功。我想要这样的东西:
SELECT * FROM servers WHERE infrastructure[os_name] = "some value"
和
SELECT * FROM servers WHERE infrastructure["network"]["hosting_id"] = "some value"
ANY() is your friend, but be aware that it does not with arrays of objects. So you need to also consider this information。以下解决方案适用于最新的 Crate 版本 1.0.1:
SELECT * FROM servers
WHERE
os_name = 'some value'
AND
'some value' = ANY(network['hosting_id']);
我正在尝试使用新的 crate 数据库。 link 我有一个 table,其中包含一个 "infrastructure" 和 "network" 个对象:
CREATE TABLE servers (infrastructure object(strict) as (
#etc...
os_name string,
#etc...
network array(object as
(etc.., hosting_id string, etc... ))
我需要从 "infrastructure" 中查询 os_name 并从网络数组中查询 hosting_id。我该怎么做?我试图 google 找到正确的语法但没有成功。我想要这样的东西:
SELECT * FROM servers WHERE infrastructure[os_name] = "some value"
和
SELECT * FROM servers WHERE infrastructure["network"]["hosting_id"] = "some value"
ANY() is your friend, but be aware that it does not with arrays of objects. So you need to also consider this information。以下解决方案适用于最新的 Crate 版本 1.0.1:
SELECT * FROM servers
WHERE
os_name = 'some value'
AND
'some value' = ANY(network['hosting_id']);