Reputation: 31
{
"Volcano Name": "Agua de Pau",
"Country": "Portugal",
"Region": "Azores",
"Location": {
"type": "Point",
"coordinates": [
-25.47,
37.77
]
},
"Elevation": 947,
"Type": "Stratovolcano",
"Status": "Historical",
"Last Known Eruption": "Last known eruption from 1500-1699, inclusive",
"id": "d44c94b6-81f8-4b27-4970-f79b149529d3",
"_rid": "Sl8fALN4sw4BAAAAAAAAAA==",
"_ts": 1448049512,
"_self": "dbs/Sl8fAA==/colls/Sl8fALN4sw4=/docs/Sl8fALN4sw4BAAAAAAAAAA==/",
"_etag": "\"0000443f-0000-0000-0000-564f7b680000\"",
"_attachments": "attachments/"
}
In MS SQL, we have like below to read column names from a table.
select column_name, data_type, character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = 'table_name' .
I am expecting the same for document db. is it possible from the above sample document which has the Type "Stratovolcano" to retrieve the json names "Volcano Name", "Country", "Region", "Location"... etc
Upvotes: 2
Views: 1973
Reputation: 1072
An Azure Cosmos SQL container is a schema-agnostic container of items. The items in a container can have arbitrary schemas unlike rows in a table. So, Cosmos DB will not be able to do what you are asking for.
In your case it looks like all your items will have the same schema. So, you could do a " select * from c where c.id = "someid" " and infer the schema from the retuned item.
Upvotes: 2