couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken tashiro <>
Subject Re: how to use an included document's key?
Date Fri, 17 Apr 2015 02:45:01 GMT
Thank you again, Giovanni.

> I don't know if I understood it correctly. Why would you need two queries
> for fetching the current prescription and the last prescription? You can do
> limit=2 and get the current and the last prescriptions at the same time.

I am sorry for my complicated explanation.

At the time of these two queries,current prescription data is not yet
uploaded to couchDB,so If I do limit=1 then get the last prescription data.

If the current prescription has N drugs prescribed,first query gets at most
N  "last prescriptions" that include each drug prescribed in the current
prescription regardless of who prescribed it.
So, key is  [pharmacy_code,patient_code,drug_code,date],
value is phase,

Second query gets at most one "last prescription" which is prescribed
by the same prescriber.
So, key is  [pharmacy_code,patient_code,prescriber_code,date],
value is [drug_code],

I thought these queries could be united using reduce function and different
key levels,but could not find the way.

> For example. Then you can query this view with
> ?include_docs=true&descending=true and get all the data at once.

By adding at most (N + 1) document ids of  "the last prescription
('last' has two meanings)" to the current prescription data which is
not yet uploaded and setting  "?include_docs=true" instead of
adding "optional_information" , I want to use the content of linked
document within a map function, but it is impossible.Only client side
program which gets the query result can use linked documents?

You indicated me to PUT the current prescription data without any
optional data, then using update functions add optional data to this
prescription data.
Am I correct?

ken tashiro

View raw message