In the previous blog post we explained how work with the collection CRUD operations. In this blog post we are going to explain other functions that are related to document management.
We already know how to create collections, as well as how to add, delete, update and retrieve documents from them. But, how can we add a new field to a document or documents that are in a collection?
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) { var schema = session.getSchema('mySchema'); var coll = schema.getCollection('myColl'); var query = "$.name == 'NewField'"; var newDoc = { name: 'NewField', description: 'a new field', extra: ['hello', 'world'] …[Read more]