Documentation Home
MySQL Connector/Node.js Release Notes
Download these Release Notes
PDF (US Ltr) - 92.8Kb
PDF (A4) - 93.6Kb
HTML Download (TGZ) - 27.8Kb
HTML Download (Zip) - 55.3Kb


MySQL Connector/Node.js Release Notes  /  Changes in MySQL Connector/Node.js 8.0  /  Changes in MySQL Connector/Node.js 8.0.21 (2020-07-13, General Availability)

Changes in MySQL Connector/Node.js 8.0.21 (2020-07-13, General Availability)

Functionality Added or Changed

  • Creating a collection now supports options to enable validation of a JSON schema that documents must adhere to before they are permitted to be inserted or updated. The new ModifyCollection method allows updating the schema of an existing collection. In the createCollection method, the option to re-use an existing collection was renamed from ReuseExistingObject to reuseExisting.

    Schema validation is performed by the server, which returns an error message if a document in a collection does not match the schema definition or if the server does not support validation.

    If a given collection already exists in the database, the createCollection fails unless the reuseExisting property is enabled in an additional options object such as the following example:

    const mysqlx = require('@mysql/xdevapi');
    
    mysqlx.getSession('mysqlx://localhost:33060')
        .then(sesion => {
            return session.getSchema('mySchema').createCollection('myCollection', { reuseExisting: true })
        });

    You can also use the options object to, for example, create a server-side document validation schema. For that, you can include a schema property matching a valid JSON schema definition within an outer validation object. You should also include the level property where STRICT enables it and OFF disables it. For example:

    const mysqlx = require('@mysql/xdevapi');
    const validation = { schema: { type: 'object', properties: { name: { type: 'string' } } }, level: mysqlx.Schema.ValidationLevel.STRICT };
    
    mysqlx.getSession('mysqlx://localhost:33060')
        .then(sesion => {
            return session.getSchema('mySchema').createCollection('myCollection', { validation })
        });

    The same level property logic applies to modifyCollection. Here's an example to enable a JSON schema on an existing collection (or to update it if it already exists) using the STRICT validation level:

    const mysqlx = require('@mysql/xdevapi');
    const validation = { schema: { type: 'object', properties: { name: { type: 'string' } } }, level: mysqlx.Schema.ValidationLevel.STRICT };
    
    mysqlx.getSession('mysqlx://localhost:33060')
        .then(sesion => {
            return session.getSchema('mySchema').modifyCollection('myCollection', { validation })
        });

Bugs Fixed

  • Row values for columns of type BIGINT were not correctly decoded by Connector/Node.js. Upgrading the google-protobuf library (to 3.11.4) fixed this problem. (Bug #27570685)