-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema-todo.js
42 lines (31 loc) · 985 Bytes
/
schema-todo.js
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
import t from 'tcomb-form'
import {
Todos as MyCollection
}
from "/lib/collections/todos.js";
// this file should be generated from the application JSON
// see server.js for a example Apimoons.insert clauses which should match with this schema
// https://github.com/gcanti/tcomb-form/blob/master/GUIDE.md
// Import with import FormSchema from "schema-apimoon.js";
export default function() {
// this is like join field sharedTo: "users.profile.name" of type array in collection todos
// displayHelper is in columns-todo.jsx
var values = {};
Meteor.users.find().fetch().map((user) => {
values[user._id] = user.profile.name;
});
var User=t.struct({
profile: t.struct({
name: t.String,
})
},"User");
var Users = t.enums(values, "Users");
var Schema = t.struct({
_id: t.maybe(t.String),
name: t.String, // a required string
owner: t.maybe(User),
sharedTo: t.list(Users),
done: t.Boolean
});
return Schema;
}