forked from hellofresh/klepto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser-orders-using-matchers.toml
49 lines (46 loc) · 1.43 KB
/
user-orders-using-matchers.toml
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
[[Matchers]]
Latest100ActiveUsers = "users.active = true ORDER BY users.created_at DESC LIMIT 100"
[[Tables]]
Name = "users"
[Tables.Anonymise]
email = "EmailAddress"
firstName = "FirstName"
password = "SimplePassword"
[Tables.Filter]
Match = "Latest100ActiveUsers"
[[Tables]]
# Dump only orders which are related to the matching users
Name = "orders"
# Behind the scenes it will generate the following sql query:
# SELECT orders.* FROM orders
# JOIN users ON users.id = orders.user_id
# WHERE users.status = 'active'
# ORDER BY created_at DESC
[[Tables.Relationships]]
Table = "orders"
ForeignKey = "user_id"
ReferencedTable = "users"
ReferencedKey = "id"
[Tables.Filter]
Match = "Latest100ActiveUsers"
[[Tables]]
# Dump only order items which are related to the matching users orders
Name = "order_items"
# Behind the scenes it will generate the following sql query:
# SELECT order_items.* FROM order_items
# JOIN orders ON orders.id = order_items.order_id
# JOIN users ON users.id = orders.user_id
# WHERE users.status = 'active'
# ORDER BY created_at DESC
[[Tables.Relationships]]
Table = "order_items"
ForeignKey = "order_id"
ReferencedTable = "orders"
ReferencedKey = "id"
[[Tables.Relationships]]
Table = "orders"
ForeignKey = "user_id"
ReferencedTable = "users"
ReferencedKey = "id"
[Tables.Filter]
Match = "Latest100ActiveUsers"