Using MySQL to save and query JSON documents

mysql> INSTALL PLUGIN mysqlx SONAME 'mysqlx.so';
mysql> SHOW PLUGINS;
mysqlsh -u username your_database
mysql-js> db = session.getSchema("your_database");
<Schema:your_database>
mysql-js> db.createCollection("YourCollection");
<Collection:YourCollection>
mysql-js> db.YourCollection.add({_id: "oba", name: "OneBitAhead"})
Query OK, 1 item affected
mysql-js> db.YourCollection.find("_id = 'oba'")
[{_id: "oba", name: "OneBitAhead"}]
1 document in set
mysql-js> db.TableA.insert("id", "name") values ("oba", "OneBitAhead");mysql-js> db.TableA.select(["id", "name"]).where("id = 'oba'");
1 row in set

--

--

The tech staff of OneBitAhead GmbH, putting the web stack to work. Here to discuss daily bits & bytes. #javascript #nodejs #webcomponents #rdbms #php

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store