Reference

Description

Reference is a data type that stores a simple value and is interpreted by the system as a reference to a key attribute of an object of another class. This object can be an object of any class, including the source one. When you specify a parent class, you can create objects of the parent and child classes. References together with the object are loaded according to the semantics specified in the meta of the reference class or the reference attribute.

Values in the attribute of the reference type are displayed in accordance with the semantics, specified in the reference class of this attribute.

The ability to replace an object by a back reference is determined by the nullable parameter that binds the reference attribute. When you replace an object, the reference will be lost, and the referenced object will be deleted when you try to change the reference from the back reference collection.

Types of links implemented by the “Reference” type:

Reference type in context of the attribute part of the meta class:

  1. ``one-to-many ``- the classic connection of the heir object to the ancestor object. It is necessary to define the reference and indicate the class of the nested element - the connections are created when placed in the reference and stored as a separate entity in the database.
  2. one-to-one - similar to the one-to-many connection, means the presence of a reference and a nested object with a bonded reference to the source object. In the reference, you must specify a bonded reference, and in the bonded reference you must indicate the reference attribute of the nested object by which the connection is formed. Be sure to specify the "unique ": true property in the reference attribute.

Reference in JSON format

Example

{
      "orderNumber": 20,
      "name": "ssylka",
      "caption": "Ссылка",
      "type": 13,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "collRefCatalog@develop-and-test",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
 }

Display modes of the “Reference” type attribute on the form:

You can set the display mode in the meta view. Set the mode using the "mode" property or the "options" property to set it as a template.

  • “mode”: 0 - displaying only the semantics of an object by reference
  • “mode”: 1 - displaying the reference to the form of the object by reference
  • “mode”: 3 - hierarchical object search
  • “mode”: 4 - refining object search

Back reference

Back reference in the context of reference is obtained as follows:

  • Create an attribute with type 13 and specify the reference class refClass and specify the property "backRef" (where the attribute code from the reference class is written).
  • the reference class should contain the reference attribute, which refers to the initial class and has the "unique": true property.

Back reference in JSON format

Example

{
      "orderNumber": 30,
      "name": "backref",
      "caption": "Обратная ссылка",
      "type": 13,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "otorbrRef@develop-and-test",
      "itemsClass": "",
      "backRef": "ref",
      "backColl": "",
      "binding": "",
      "semantic": "data",
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": true,
      "formula": null
 }

Attention:

  • "type": 13 - attribute type “Reference”
  • "refClass" - the name of the class whose objects can store their identifiers in the reference and, thus, form a relationship with an object by its identifier.
  • "backRef" - specifies the name of the attribute that belongs to the class specified in the property "refClass". The attribute must have the type “Reference” and a reference to the source class.
  • When specifying a parent class, it is possible to create objects of the parent and child classes.
  • References with object are loaded according to the semantics specified in the meta of the reference class or reference attribute.

Example

Employee: {
    property: {
        aaa: {
            refClass: Post,
            backRef: bbb,
            ...
        },
        ...
    }
}

Post: {
    property: {
        bbb: {
            refClass: Employee,
            ...
        },
        ...
    }
}