meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
Michael Nardell 2021-03-31T14:44:02.029700Z

I am using Meander to build up nested data structures rather than using it to query nested data. I am able to do roughly what I want with Meander, and it seems like an elegant way to express how I both retrieve the data and build a result. The problem is that I get a result that needs to be merged subsequently. For example I have normalized data from my schools student information system that expresses course, section, meeting and enrollment data (users are associated with courses, courses with sections, and sections with meetings).

Michael Nardell 2021-03-31T15:02:30.031900Z

(defn retrieve-data-for-user [courses-lookup sections-lookup meetings-lookup  user]
  (m/search {:user user 
             :courses-lookup courses-lookup   ;; Look up course by user-id
             :sections-lookup sections-lookup ;; Look up section by course-id
             :meetings-lookup meetings-lookup } ;; Look up meetings by section-id
      ;; Input------------------------------------------------------
      {:user 
         {"user_id" ?user-id "last_name" ?last-name}
       :courses-lookup 
       {?user-id  (m/scan {"course_id" ?course-id "status" ?status})}
       :sections-lookup
       {?course-id (m/scan {"section_id" ?section-id "name" ?section-name})}
        :meetings-lookup
       {?section-id (m/scan {"Meeting ID" ?meeting-id})}
       }
      
      ;; Output ---- build nested data structure of the form --- 
      ;; {:user :courses [{:sections [{:meetings } ...] }...] }
      {:user 
         {:last-name ?last-name} 
       :courses [{:course-id ?course-id :status ?status 
                     :sections [{:section-name ?section-name
                                 :section-id ?section-id
                                  :meetings [{:meeting-id ?meeting-id}] 
                                 } ]} ]}))
With the above code I get the data I want, however each the data is not fully nested - I get

Michael Nardell 2021-03-31T15:06:27.034300Z

({:user {:last-name "Name"},
  :courses
  [{:course-id "2208-022...",
    :sections
    [{:section-name "Senior Research",
      :meetings [{:meeting-id "2...}]}]}]}
 {:user {:last-name "Name"},
  :courses
  [{:course-id "2208-02288...",
    :sections
    [{:section-name "Syntax I-22917",
      :meetings [{:meeting-id "... "}]}]}]}
 {:user {:last-name "Name"},
  :courses
  [{:course-id "2208-11",
    :sections
    [{:section-name "Ellipsis-24042",
      :meetings [{:meeting-id "2208-116"}]}]}]})

jimmy 2021-03-31T23:53:18.034600Z

Sorry I haven't been able to look at this. Will try to find time tonight.