This repository has been archived by the owner on May 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata-modelling.ftd
71 lines (47 loc) · 1.79 KB
/
data-modelling.ftd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
-- my-ds.page: Data Modelling With `ftd`
`ftd` is an alternative to XML/JSON for storing data.
-- ds.h1: Optimized For Human Readability
`ftd` is designed for humans to write data. It tries to be a minimal
as possible, intuitive and readable, no quote character for strings, avoid
indentation etc.
-- ds.code: ftd file containing data
lang: ftd
\-- record person:
caption name:
string location:
optional body bio:
\-- person amitu: Amit Upadhyay
location: Banglore, India
Amit is the founder and CEO of FifthTry.
-- ds.markdown:
Consider this example. We have described our data, `person`, and notice we have
type for each field. Notice also our types `caption`, which like "heading of the
data", `body`, which lets people write multiline strings without worrying about
quoting or indentation etc.
Read our [`ftd::p1` grammar guide](/p1-grammar/) to understand the low
level grammer better.
-- ds.h1: Rich Data Modelling
It has support for [typed variables](variables/),
[`records`](record/) (`struct` in other languages),
[`or-type`](or-type/) (`enum` in Rust, also called "algebraic data
type") and [lists](list/).
FTD files can be validated to confirm to strict type or not, and this can be used
by editors to assist humans write correct ftd files.
-- ds.h1: Reading FTD Files
Programs can read ftd files:
-- ds.code:
lang: rs
#[derive(serde::Deserialize)]
struct Employee {
name: String,
location: String,
bio: Option<String>
}
let doc = ftd::p2::Document::from("some/id", source, lib)?;
let amitu: Employee = doc.get("amitu")?;
-- ds.markdown:
Read more about it in ["reading data" guide](/reading-data/).
-- ds.h1: Better Organization Of Data
`ftd` also supports referring to other `ftd` files, so one can describe the schema
or data in one file and refer it from other files.
-- end: my-ds.page