Skip to content

Commit a8ad4f0

Browse files
committed
or and not queries added.
1 parent ab4870c commit a8ad4f0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎src/java/datomic/samples/Query.java‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,35 @@ public static void main(String[] args) {
135135
System.out.println(res);
136136
pause();
137137

138+
System.out.println("Use not-join to bind variable in subquery. Artists w/o releases in 1970.");
139+
res = Peer.query("[:find (count ?artist) . " +
140+
":where [?artist :artist/name] " +
141+
"(not-join [?artist] " +
142+
" [?release :release/artists ?artist] " +
143+
" [?release :release/year 1970])]",
144+
db);
145+
System.out.println(res);
146+
pause();
147+
148+
System.out.println("Total of artists who are a group or female by use of 'or'.");
149+
res = Peer.query("[:find (count ?artist) . " +
150+
" :where (or [?artist :artist/type :artist.type/group] " +
151+
" (and [?artist :artist/type :artist.type/person] " +
152+
" [?artist :artist/gender :artist.gender/female]))]",
153+
db);
154+
System.out.println(res);
155+
pause();
156+
157+
System.out.println("Count of artists from Canada who released an album in 1970 using 'or-join'");
158+
res = Peer.query("[:find (count ?release) . " +
159+
" :where [?release :release/name] " +
160+
" (or-join [?release] " +
161+
" (and [?release :release/artists ?artist] " +
162+
" [?artist :artist/country :country/CA]) " +
163+
" [?release :release/year 1970])]",
164+
db);
165+
System.out.println(res);
166+
pause();
138167
}
139168

140169
private static final Scanner scanner = new Scanner(System.in);

0 commit comments

Comments
 (0)