6. Insertion of `arbitrarily` formatted data:
    a - books containing users:

(adi/insert! ds [{:book {:name "Charlie and the Chocolate Factory"
                         :author "Roald Dahl"
                         :accounts #{{:user "adi3" :password "hello3" :credits 
100}
                                     {:user "adi4" :password "hello4" :credits 
500}
                                     {:user "adi5" :password "hello5" :credits 
500}}}}
                 {:book {:name "The Book and the Sword"
                         :author "Louis Cha"
                         :accounts users}}])


 b. users containing books

(adi/insert! ds
         [{:account {:user "adi1" :password "hello1"}}
          {:account {:user "adi2" :password "hello2"
                     :books #{{:name "The Count of Monte Cristo"
                               :author "Alexander Dumas"}
                              {:name "Tom Sawyer"
                               :author "Mark Twain"}
                              {:name "Les Misérables"
                               :author "Victor Hugo"}}}}])


7. Expressive Search

;; Full expressiveness on searches:;;(->> ;; Find the teacher that teaches a 
student called Harry
 (adi/select class-datastore {:teacher/teaches/students/name "Harry"})
 (map #(-> % :teacher :name))) ;=> ("Mr. Anderson" "Mr. Carpenter" "Mr. Blair")
(->> ;; Find all students taught by Mr Anderson
 (adi/select class-datastore {:student/classes/teacher/name "Mr. Anderson" })
 (map #(-> % :student :name))) ;=> ("Ivan" "Bobby" "Erin" "Kelly"
                               ;;   "David" "Harry" "Francis" "Jack")
(->> ;; Find all the students that have class with teachers with fish
 (adi/select class-datastore {:student/classes/teacher/pets :fish })
 (map #(-> % :student :name)) sort);=> ("Anna" "Charlie" "David" "Francis" 
"Harry" "Ivan" "Jack" "Kelly")

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to