WL#12965: X Protocol: add schema validation to create collection

Affects: Server-8.0   —   Status: Complete

Motivation

User can insert any kind of document into a collection created by X Plugin. Thus it is the users responsibility to validate the content of inserted document.

In case when multiple applications operate on the same collection, all need to implement their own document validation.

Moving the validation from the client to the server allows to:

  • there will be no mismatches in patters on different clients, only "server" is going to be responsible for it,
  • detect inconsistencies in the dataset
  • describe/document the schema of the collection

In case of: bulk insert, prototyping, buggy json-schema, user might want to disable the validation and re-enable it again.

Goal

X Plugin's "createCollection()" functionality should allow to specify a JSON Schema for a collection.

WL#11999 introduces JSON_SCHEMA_VALID()

<bool> = JSON_SCHEMA_VALID(<json_schema>, <json_document>); # introduced by WL#11999

which will be called by the X Plugin when the user calls

var coll = schema.createCollection("mycollection", {
    validator: validationDoc
})

on the DevAPI.