Commit 5d056f69 authored by Gaetan Carabetta's avatar Gaetan Carabetta
Browse files

update json

parent 2ffbb9e0
...@@ -28,11 +28,21 @@ INSERT INTO animal VALUES ( ...@@ -28,11 +28,21 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"quantité": 4 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4
}
}, },
{ {
"nom": "DOLIPRANE", "nom": "DOLIPRANE",
"quantité": 3 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
} }
] ]
}, },
...@@ -45,15 +55,30 @@ INSERT INTO animal VALUES ( ...@@ -45,15 +55,30 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"quantité": 4 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4
}
}, },
{ {
"nom": "DOLIPRANE", "nom": "DOLIPRANE",
"quantité": 3 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
}, },
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"quantité": 2 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
} }
] ]
} }
...@@ -73,11 +98,21 @@ INSERT INTO animal VALUES ( ...@@ -73,11 +98,21 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "IMODIUM", "nom": "IMODIUM",
"quantité": 2 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
}, },
{ {
"nom": "FORLAX", "nom": "FORLAX",
"quantité": 3 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3
}
} }
] ]
} }
...@@ -96,7 +131,12 @@ INSERT INTO animal VALUES ( ...@@ -96,7 +131,12 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "PLAVIX", "nom": "PLAVIX",
"quantité": 2 "posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2
}
} }
] ]
} }
......
/*
Exemple de requête pour récupérer des éléments
d'un tableau dans un tableau JSON
*/
select m->>'nom'
from animal a, json_array_elements(a.traitements) t, json_array_elements(t->'medicaments') m;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment