In a previous post we explained how to connect to a MySQL server configured as a document store using the new MySQL Connector/Node.js. In this post we are going to explain how to create a schema, create a collection and add documents to the collection.
Creating a new schema is very easy; the following code demonstrates how to do it:
var mysqlx = require('mysqlx'); mysqlx.getSession({ host: 'host', port: '33060', dbUser: 'root', dbPassword: 'my pass' }).then(function (session) { session.createSchema('mySchema').then(function(schema){ console.log('Schema created'); session.close(); }); }).catch(function (err) { console.log(err.message); console.log(err.stack); });
In the previous code example we created a connection and then used the XSession object to create a schema, finally we closed the connection.
The first …
[Read more]