                               (fn[record-pos
                                   record-id]   {record-pos  record-id})
 
-                              list-of-positions
+                              list-of-record-positions
                               records
                               ))
                 (get @query-atom :values))))
 
 
+    ; -----------------------------------------------
+    ; load the records in
+    ; -----------------------------------------------
     (let [
-          list-of-ids         (map (fn[id]
-                                     (get (@query-atom :values) id))
-                                   list-of-positions)
+          list-of-ids         (map
+                                  (fn[id] (get (@query-atom :values) id))
+                                   list-of-record-positions)
           ]
 
       (doall
        (map
         (fn [ record-id ] (load-record  query-key  record-id))
         list-of-ids
-        ))
-
-      (update-all-views-for-query    query-key)
+        )
+       (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-positions   (range (:start params) (inc (:end params)))
       ]

    ;(log (pr-str "Record copunt 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 values in the query
    (reset!  query-atom
             (assoc @query-atom :values
               (merge

-----------------------------------------------------------"
(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 ))))



