Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Mappings

Ezequiel Foncubierta edited this page Jun 11, 2018 · 2 revisions

A mapping is used to define how a node is structured (i.e. its schema). All nodes in Hyperdoc must be created according to a mapping, which define:

  • strictness level
  • type of each property (i.e. string, float, integer, boolean, date, nested, node or resource)
  • which properties are mandatory
  • which properties are multi-valued
  • for a nested property, how its sub-properties are defined
  • for a node property, which is the mapping of the target node

Mappings can be created with different levels of strictness:

  • free: A free mapping is schemaless. Node properties are not validated. In fact, two nodes with the same free mapping can have different sets of properties.
  • organic: An organic mapping is also schemaless, but only for the first instances of a property. For example, if a node is created with a property year of type string, a second node cannot be created with a property year of type integer. However, that second node can be created with new properties. The mapping grows, that's why it is called organic ;-)
  • strict: A strict mapping is not schemaless. It must be defined before any node is created. All nodes must be created exactly as the mapping defines them.

Model

Mapping

{
  mappingId: <<uuid>>,
  name: <<string>>,
  type: <<MappingType>>,
  properties: {
    <<string>>: <<MappingPropertyType>>
  }
}

MappingType

<<"strict" | "organic" | "free">>

MappingProperty

<<MappingScalarProperty | MappingNestedProperty | MappingNodeProperty | MappingResourceProperty>>

MappingScalarProperty

{
  type: <<"integer" | "float" | "text" | "boolean" | "date">>,
  mandatory: <<boolean>>,
  multiple: <<boolean>>
}

MappingNestedProperty

{
  type: "nested",
  mandatory: <<boolean>>,
  multiple: <<boolean>>,
  properties: {
    <<string>>: <<MappingProperty>>
  }
}

MappingNodeProperty

{
  type: "node",
  mandatory: <<boolean>>,
  multiple: <<boolean>>,
  mapping: <<string>>
}

MappingResourceProperty

{
  type: "resource",
  mandatory: <<boolean>>,
  multiple: <<boolean>>,
  provider: <<string>>
}

Example

Movie

{
  mappingId: "8b12e15b-8b83-4cd9-8a59-d86142dc3789",
  name: "movie",
  properties: {
    title: {
      type: "string",
      mandatory: true,
      multiple: false
    },
    year: {
      type: "date",
      mandatory: true,
      multiple: false
    },
    director: {
      type: "node",
      mandatory: true,
      multiple: false,
      mapping: "director"
    },
    cast: {
      type: "node",
      mandatory: false,
      multiple: true,
      mapping: "moviecast"
    }
  }

Director

{
  mappingId: "4572dda7-13cd-4271-b43f-1e43c41d1f37",
  name: "director",
  properties: {
    name: {
      type: "string",
      mandatory: true,
      multiple: false
    }
  }
}

MovieCast

{
  mappingId: "d3815a31-d013-423c-b3cd-63792bb7eda0",
  name: "moviecast",
  properties: {
    actor: {
      type: "node",
      mandatory: true,
      multiple: false,
      mapping: "actor"
    },
    roles: {
      type: "string",
      mandatory: true,
      multiple: true
    }
  }

Actor

{
  mappingId: "8311f991-c459-43ec-b28f-ce25174db9d1",
  name: "actor",
  properties: {
    name: {
      type: "string",
      mandatory: true,
      multiple: false
    },
    birthDay: {
      type: "date",
      mandatory: false,
      multiple: false
    }
  }
}

Clone this wiki locally