YAML Format - nshmura/dsio GitHub Wiki

Simple

scheme:
  kind: Book

entities:
  - Title: "Brave New World"
    Sort: 100
    CreatedAt: "1932-01-01"

  - Title: "The Old Man and the Sea"
    Sort: 200
    CreatedAt: "1952-01-01"

kind

kind in scheme section is a kind of entities.

entities

Values in entities sections are the entities in datastore.

Detailed

scheme:
  namespace: production
  kind: Book
  time-format: "2006-01-02"
  time-locale: America/New_York

entities:
  - __key__: "123"
    Title: "The Old Man and the Sea"
    Sort: 200
    Price: 15.27
    Public: true
    CreatedAt: "1952-01-01"
    RegisteredAt: __current__
    Types: ["Hardcover", "PaperBack"]
    Info:
      Language: English
      Pages: 128
      Weight: 2.9
      New: true
      ReviewedAt: "2015-02-24"

Namespace

namespace in scheme section is the namespace of kind.

Time Format and Locale

time-format is format for parsing datetime value. This format is golang time format.

time-locale is the locale of datetime.

Key

__key__ is a key of entity.

  • if the value of __key__ is string, it will be a key of Custom Name.
  • if the value of __key__ is integer, it will be a key of Numeric ID.
  • if the value of __key__ is null or __key__ is not exists, key will be automatically generated.
  • if the value of __key__ is array like [ Category, "ScienceFictionFantasy", SubCategory, "GeneticEngineering", Book, "1"], it will be a Ancestor Paths.

Current Datetime

__current__ is a keyword of dsio. It is replaced by current datetime.

Auto type detecting

string, integer, foat, boolean, datetime, array, embed types are automatically detected. But key, geo, blob types are not automatically detected.

Default Values

The values in default section are the default values of entities. You can override the default value by the value in entities section.

scheme:
  kind: Book

default:
  Public: false
  RegisteredAt: "2017-01-01"

entities:
  - Title: "Brave New World"
    Sort: 100
    CreatedAt: "1932-01-01"

  - Title: "The Old Man and the Sea"
    Public: true
    Sort: 200
    CreatedAt: "1952-01-01"

Define Types In Scheme Section

The types of properties can be specified in scheme section.

scheme:
  kind: Book
  properties:
    Title: string
    Sort: int
    Price: float
    Public: bool
    CreatedAt: datetime
    Location: geo
    Types: array
    Authoer: key
    Image: [blob, noindex]
    Info: [embed, noindex]
    Empty: "null"

entities:
  - __key__: "1"
    Title: "Brave New World"
    Sort: 100
    Price: 18.38
    Public: true
    CreatedAt: "1932-01-01"
    UpdatedAt: __current__
    Location: [51.507222, -0.1275]
    Types: [Hardcover, PaperBack]
    Authoer: [ class, HumanKind, author, "Aldous Huxley" ]
    Image: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="
    Condition: null

Directly Specified Types

The types of properties can be specified in entities section.

scheme:
  kind: Book

entities:
  - Title:
      __string__: "Brave New World"
      __noindex__: true

    CreatedAt:
      __datetime__: "1932-01-01"

    Sort:
      __int__: 100

    Price:
      __float__: 18.38

    Public:
      __bool__: true

    Authoer:
      __key__: [ class, HumanKind, author, "Aldous Huxley" ]

    Location:
      __geo__: [51.507222, -0.1275]

    Types:
      __array__: [ Hardcover, PaperBack ]

    Image:
      __blob__: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="

    Condition:
      __null__: null

    Info:
      Language:
        __string__: English

      Pages:
        __int__: 128

      Weight:
        __float__: 2.9

      New:
        __bool__: true

      SubTypes:
        __array__: [Hardcover, PaperBack]

      Condition:
        __null__: null

The order of detecting typs

scheme:
  kind: Book
  properties:
    Title: string
    Sort: int

entities:
  - Title: "Brave New World"
    Sort: 
      __int__: 100
    CreatedAt:
      __datetime__: "1932-01-01"

The order of detecting types is Directly Specified Types > Scheme Specified Types > Automatically Detected Types.

  • if Directly Specified Types exists (like Sort), Scheme Specified Types is ignored.
  • if Directly Specified Types is not exists, the type of value is detected in scheme section.
  • if Directly Specified Types and Scheme Specified Types are not exists, the type of value is automatically detected.