let get_all t =
let collection = "measurements" in
database t
>>= fun db ->
Database.get_all db ~collection
>>= fun all_keys ->
Deferred_list.while_sequential all_keys (fun key ->
Database.get db ~collection ~key
>>= function
| Some s ->
begin try
return (Ketrew_measurement.Collection.deserialize_exn s)
with e -> fail (`Deserialization (e, s))
end
| None -> fail (`Missing_data (fmt "Missing measurement (from %s)" key)))
>>| Ketrew_measurement.Collection.concat
>>= fun collection ->
return collection