創建一個模式
一個模式可以幫助你定義一個模型。 用相當單純的情報,就可以由模式產生一個模型。 然後你就可以開始編纂一個模型。
Create a schema
在 System Designer 上創建模式
- 點擊Schemas 頁,
- click on the '+' button on the left toolbar,
- 輸入你要創建的模式名稱
- then click on Create button,
- 一個新的模式就此創建完畢。你將可以看到它出現在Schema 一覽中:
Edit a schema
- 點擊你所創建完的模式,
- 編輯器會切換至模式詳情編輯頁,
- you can now edit the configuration of the schema:
- 點擊回到Schemas 頁,
- 設定已經成功更新。
What is a configuration?
A configuration is an object in which you declare the property / link / collection / method / event of the model.
In the configuration object you have by default these properties:
- _id : string, unique id of your schema.
- _name : string, name of your schema.
Define inheritance
To add inheritance between your schemas you need to add the _inherit property. This property is an array in which you put all the schema names that this schema must inherit.
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"_inherit": ["Person"]
}
In this example Jedi schema inherits from Person.
Define a property
To define a property add a key that has got a property value.
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"name": "property"
}
In this example Jedi has a name property.
Define a link
To define a link between models, add a key that has got a link value. A link is a 1-1 link between models.
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"father": "link"
}
In this example Jedi has a father link.
Define a collection
To define a collection add a key that has got a collection value. A collection can be:
- a collection of typed objects (example: adresse, ...) or
- a collection of components (i.e. like a 1-N link between models).
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"children": "collection"
}
In this example Jedi has a children collection.
Define a method
To define a method add a key that has got a method value.
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"fullName": "method"
}
In this example we have defined a fullName method for Jedi.
Important note on renaming
If you rename an existing method, it will delete the method and create a new one. So any code related to the previous method will be deleted.
Define an event
To define an event add a key that has got an event value. An event is a asynchronous method.
{
"_id": "ee8b5c97-cb89-4cdf-82b3-d9d8bea23ac5",
"_name": "Jedi",
"statusChanged": "event"
}
In this example we have defined a statusChanged event for Jedi.
想知道更多?
For more information on schemas, go to the System Runtime documentation.