Versioning allows you to store multiple versions of metadata. When you change and save the object, it gets the version that contains proceeded changes. So, versioning provides the ability to work with different versions of the same objects. It greatly reduces the work required to manage the changes that occur with an object.

Versioning is set in the "version" field of the general part of the meta class. Add the version property (” version “: 2) to the attribute to change the meta version.

Principle of work

When loading metadata, if there is a version attribute (“version”: 2), the meta with the version will be uploaded, otherwise version = 1.

  "isStruct": false,
  "key": "id",
  "semantic": "caption",
  "name": "ion_filter",
  "caption": "Фильтры",
  "ancestor": null,
  "container": null,
  "creationTracker": "",
  "changeTracker": "",
  "version" : 2

When creating objects, the latest version of the metadata from the current database will be added to them, and when editing objects, they will be edited based on the saved version.

Example of saved objects with different versions in the database:

    "_id" : ObjectId("567cfa1eb869fc2833690ea4"),
    "id" : 24006,
    "class" : "ALL",
    "caption" : "11",
    "html" : "",
    "filter" : "[\"{\\\"property\\\":\\\"contact\\\",\\\"operation\\\":20,\\\"value\\\":\\\"11\\\",\\\"title\\\":\\\"Контактная информация содержит 11\\\",\\\"type\\\":7}\"]",
    "period" : "2015-12-08,2016-02-05",
    "version" : 1,
    "semanticTitle" : "11 "

    "_id" : ObjectId("56944e5cb73f51ec182c7369"),
    "class" : "ALL",
    "caption" : "fffffff",
    "filter" : "[\"{\\\"property\\\":\\\"class\\\",\\\"operation\\\":0,\\\"value\\\":\\\"fff\\\",\\\"title\\\":\\\"Класс фильтра равно fff\\\",\\\"type\\\":1}\"]",
    "version" : 2,
    "id" : NaN,
    "semanticTitle" : "fffffff "

Realization in code

When reading the class meta, the data is separated by version. The names of the versioned classes have names that look like “<nameof class><version number>”. For example, ion_filter_1, ion_filter_2 is the ion_filter class of versions 1 and 2, respectively.

When selecting objects, the data is taken based on the version. The version of the object is passed as the version parameter of the request to open the object.