Create or define a collection from a JSON column
Hi,
I want to manipulate a collection of documents stored in a JSON col via mysqlsh.
CREATE DATABASE bd_json;
CREATE TABLE bd_json.tab_vol_json
(vol_id INT AUTO_INCREMENT PRIMARY KEY,
details_vol JSON
);
INSERT INTO bd_json.tab_vol_json (details_vol) VALUES
(
'{"date_vol":"AF6143",
"num_vol":"2016-07-19",
"desc_vol":
{"porte": "20A",
"plan_vol": {
"depart": "21:45",
"parking": "3R2",
"SID": "AGN-2W",
"STAR": "TOU-5T",
"arrivee": null},
"sieges":
[{"prenom": "Guy",
"nom": "Blanchet",
"siege": "15A"},
{"prenom": "Gerard",
"nom": "Diffis",
"siege": "15B"},
{"prenom": "Victor",
"nom": "Ferrage",
"siege": "15C"}]
}
}'
);
INSERT INTO bd_json.tab_vol_json (details_vol) VALUES
(
'{"date_vol":"AF6143",
"num_vol":"2016-08-24",
"desc_vol":
{"porte": "20B",
"plan_vol": {
"depart": "21:45",
"parking": "5R1",
"SID": "AGN-2W",
"STAR": "GAI-1N",
"arrivee": null},
"sieges":
[{"prenom": "Alain",
"nom": "Escafi",
"siege": "15A"},
{"prenom": "David",
"nom": "Pizzinat",
"siege": "15B"},
{"prenom": "Pierre",
"nom": "Basque",
"siege": "15C"}]
}
}'
);
commit;
-- in mysqlsh, no collection is detected?
C:\Users\soutou>mysqlsh --uri=root@localhost --js
Creating an X Session to root@localhost:33060
Enter password:******
No default schema selected.
Welcome to MySQL Shell 1.0.4 Development Preview
Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type '\help', '\h' or '\?' for help.
Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \use bd_json
Schema `bd_json` accessible through db.
mysql-js> db.getCollections()
[
]
-- Thanks in advance