aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial-achat.md
blob: 82a2bcf39f0184fc4de84c6b74a08d5dd657a9ef (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
## authentication

TODO

## create user

```console
acms collection add user <<'EOF'
{
    "username": "joe"
}
EOF
```

```json
{
    "$id": "9474f0eb-06d7-4fd8-b89e-0ce996962508",
    "username": "joe"
}
```

## create chat

```console
acms collection add chat <<'EOF'
{
    "title": "how does acms work?"
}
EOF
```

## list chats

```console
acms collection list chat
```

```json
{
    "$id": "ccccc18c-f3dc-4f98-b4d2-290ef76adb6b",
    "title": "how does acms work?"
}
```

## create chat message

```console
acms collection add chat-message <<'EOF'
{
    "chat": {
        "$ref": "chat/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b"
    },
    "message": "please see the [docs]()",
    "user": {
        "$ref": "user/9474f0eb-06d7-4fd8-b89e-0ce996962508"
    }
}
EOF
```

```json
{
    "$id": "6dc0bf04-b453-4396-9efc-0b8b8f338d9c",
    "chat": {
        "$ref": "chat/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b"
    },
    "message": "please see the [docs]()",
    "user": {
        "$ref": "user/9474f0eb-06d7-4fd8-b89e-0ce996962508"
    }
}
```

## list chat messages

```console
acms query <<'EOF'
SELECT
  chat-message
FROM
  chat-message
WHERE
  chat-message.chat.$ref == "chat/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b"
EOF
```

```json
[
    {
        "$id": "6dc0bf04-b453-4396-9efc-0b8b8f338d9c",
        "chat": {
            "$ref": "chat/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b"
        },
        "message": "please see the [docs]()",
        "user": {
            "$ref": "user/9474f0eb-06d7-4fd8-b89e-0ce996962508"
        }
    }
]
```