 -----------------------------------------------------------"
 (defn update-all-views-for-query [ query-key ]
 
-  (let [  data-query         @(get @data-queries-v2  query-key)
-          list-of-views      @(get data-query  :list-of-view-keys)   ]
-
-    (doall
-
-     (map
-      (fn[view-key]  (update-view-for-query  view-key  query-key))
-      list-of-views ))))
+  (let [
+          data-query         @(get @data-queries-v2  query-key)
+          list-of-views      @(get data-query  :list-of-view-keys)
+          ]
+
+          (doall
+                (map
+                    (fn[view-key]
+                                 (update-view-for-query  view-key  query-key))
+                    list-of-views ))))
 
 
 

                              (fn[record-pos
                                  record-id]   {record-pos  record-id})

                              list-of-positions
                              records
                              ))
                (get @query-atom :values))))


    (let [
          list-of-ids         (map (fn[id]
                                     (get (@query-atom :values) id))
                                   list-of-positions)
          ]

      (doall
       (map
        (fn [ record-id ] (load-record  query-key  record-id))
        list-of-ids
        ))

      (update-all-views-for-query    query-key)
      )))



(defn add-data-query-result-v2  [query-key   params  records-count  records]

  (let [
         query-atom                 (get @data-queries-v2   query-key)
         list-of-record-positions   (range (:start params) (inc (:end params)))
       ]

    ;(log (pr-str "Record count returned: " records-count))

    ; -----------------------------------------------
    ; update the record count in the query
    ; -----------------------------------------------
    (reset!  query-atom
             (assoc @query-atom :count records-count))
    ;(log (str "Query Count: " records-count))




    ; -----------------------------------------------
    ; update the record IDs in the query
    ; -----------------------------------------------
    (reset!  query-atom
             (assoc @query-atom :values
               (merge
