8000 docs(todo-example): clarify schema comments (#12) · homebaseio/homebase-react@1c4f1e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c4f1e8

Browse files
docs(todo-example): clarify schema comments (#12)
1 parent d047daa commit 1c4f1e8

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

js/todo-example.jsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,32 @@ export const App = () => {
1010
}
1111

1212
const config = {
13-
// Schema is optional. Add as much or as little as you want.
13+
// Schema is only used to enforce
14+
// unique constraints and relationships.
15+
// It is not a type system, yet.
1416
schema: {
15-
user: { name: { type: 'string' } },
1617
project: { name: { unique: 'identity' } },
1718
todo: {
1819
// refs are relationships
1920
project: { type: 'ref' },
2021
owner: { type: 'ref' }
2122
}
2223
},
24+
// Initial data let's you conveniently transact some
25+
// starting data on DB creation to hydrate your components.
2326
initialData: [
2427
{
2528
todoFilter: {
26-
// identity is a special attribute for user generated ids
27-
// E.g. this is a setting that should be easy to lookup by name
29+
// identity is a special unique attribute for user generated ids
30+
// E.g. todoFilters are settings that should be easy to lookup by their identity
2831
identity: 'todoFilters',
2932
showCompleted: true,
3033
project: 0
3134
}
3235
}, {
3336
user: {
34-
// negative numbers can be used as temporary ids in a transaction
37+
// Negative numbers can be used as temporary ids in a transaction.
38+
// Use them to relate multiple entities together at once.
3539
id: -1,
3640
name: 'Stella'
3741
}
@@ -87,7 +91,7 @@ const NewTodo = () => {
8791
transact([{
8892
todo: {
8993
name: e.target.elements['todo-name'].value,
90-
createdAt: new Date
94+
createdAt: new Date()
9195
}
9296
}])
9397
e.target.reset()

src/js_gen/todo-example.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ const App = () => {
2424

2525
exports.App = App;
2626
const config = {
27-
// Schema is optional. Add as much or as little as you want.
27+
// Schema is only used to enforce
28+
// unique constraints and relationships.
29+
// It is not a type system, yet.
2830
schema: {
29-
user: {
30-
name: {
31-
type: 'string'
32-
}
33-
},
3431
project: {
3532
name: {
3633
unique: 'identity'
@@ -46,17 +43,20 @@ const config = {
4643
}
4744
}
4845
},
46+
// Initial data let's you conveniently transact some
47+
// starting data on DB creation to hydrate your components.
4948
initialData: [{
5049
todoFilter: {
51-
// identity is a special attribute for user generated ids
52-
// E.g. this is a setting that should be easy to lookup by name
50+
// identity is a special unique attribute for user generated ids
51+
// E.g. todoFilters are settings that should be easy to lookup by their identity
5352
identity: 'todoFilters',
5453
showCompleted: true,
5554
project: 0
5655
}
5756
}, {
5857
user: {
59-
// negative numbers can be used as temporary ids in a transaction
58+
// Negative numbers can be used as temporary ids in a transaction.
59+
// Use them to relate multiple entities together at once.
6060
id: -1,
6161
name: 'Stella'
6262
}

0 commit comments

Comments
 (0)
0