forked from romshark/dgraph_graphql_go
/
setupSchema.go
45 lines (38 loc) · 988 Bytes
/
setupSchema.go
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
package dgraph
import (
"context"
"github.com/dgraph-io/dgo/protos/api"
)
func (str *impl) setupSchema(ctx context.Context) error {
return str.db.Alter(ctx, &api.Operation{
Schema: `
users: uid .
posts: uid .
sessions: uid @reverse .
Session.key: string @index(exact) .
Session.creation: dateTime .
Session.user: uid .
User.id: string @index(exact) .
User.creation: dateTime .
User.email: string @index(exact) .
User.displayName: string @index(exact) .
User.posts: uid .
User.sessions: uid .
User.password: string .
User.publishedReactions: uid .
Post.id: string @index(exact) .
Post.creation: dateTime .
Post.title: string .
Post.contents: string .
Post.author: uid .
Post.reactions: uid .
Reaction.id: string @index(exact) .
Reaction.subject: uid .
Reaction.creation: dateTime .
Reaction.emotion: string .
Reaction.message: string .
Reaction.author: uid .
Reaction.reactions: uid .
`,
})
}