-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest3.dlq
135 lines (123 loc) · 2.91 KB
/
test3.dlq
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
;test.people.filter{$father}(
; $father.gender.eq('male')
; $father.age.gte(32)
; $father.children.filter{$child}(
; test.people.filter{$mother}(
; $mother.languages.contains('SE')
; $mother.gender.eq('female')
; $mother.children.contains($child)
; )
; )
;)
;{
; $father [*]
; $child [name]
;}
;
;
; JS mockup of above (without clear projection)
;test.people.filter(function($father) {
; return $father.gender === 'male' &&
; $father.age >= 32 &&
; $father.children.filter(function($child) {
; return test.people.filter(function($mother) {
; ~return $mother.languages.indexOf('SE') &&
; $mother.gender === 'female' &&
; ~$mother.children.indexOf($child);
; });
; });
;}).project(function($parent) {
; return $parent;
;});
;;test.people{father}.filter(
;; father.gender.eq('male')
;; father.age.gte(32)
;; father.children{test.people child idx}.filter(
;; idx.mod(2)
;; test.people{mother}.filter(
;; mother.languages.contains('swedish')
;; mother.gender.eq('female')
;; mother.children{test.people}.contains(child)
;; )
;; )
;;)
;;defn(
;; join-child(child idx)
;; test.people{p}.$filter(
;; child.$eq(p.name)
;; )
;;)
;;
;;test.people{father}.$filter(
;; father.gender.$eq('male')
;; father.children.$map(join-child){child}.$filter(
;; child.age.$gte(18)
;; test.people{mother}.$filter(
;; mother.$neq(father)
;; mother.children.$contains(child.name)
;; )
;; )
;;)
;;
;;test.people{person}.$filter(
;; person.gender.$eq('male')
;;){male}.filter(
;; male.children.$map(join-child){child}.$filter(
;; child.age.$gte(18)
;; test.people{person2}.$filter(
;; person2.$neq(male)
;; person2.children.$contains(child.name)
;; )
;; )
;;)
;; you have a collection of people, and you're looking for the children of all father older than 30 and all mothers who speak swedish
;; simple case: get all people who are children
;;test.people{person}.$filter(
;; person.children{child}
;;){parent}.$map(parent.children).$concat
;;
;;;; or simpler
;;
;;test.people{person}.$map(person.children).$concat
;;
;;;; which only returns the names or ids (foreign keys), so to get the children as documents....
;;
;;test.people{person}.$map(
;; person.children{child}.$map(
;; test.people{p}.$filter(child.$eq(p.name))
;; ).$concat
;;).$concat
;;
;;
;;test.people{person}.$map(
;; person.children{child test.people{p}.$filter(
;;).$concat
;;test.people{person}.$filter(
;; person.children
;;){parent}.$map(parent.children)
;;
;;$map(
;; $filter(
;; people(test){person}
;; children(person)
;; ){parent}
;; children(parent)
;;)
;;
;;(map
;; (filter
;; (people test)
;; (fn [person] children(person)))
;; (fn [parent] (children parent)))
$map(
$filter(
people(test)
fn([person] children(person))
)
fn([parent] children(parent))
)
test.people.$filter(
fn([person] person.children)
).$map(
fn([parent] parent.children)
).$cat