You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Michael Bykov <m....@gmail.com> on 2011/05/30 20:25:23 UTC

updates document question

Sorry, I am a complete newbie in couchdb.

I am in update function

function(doc, req) {
    doc.att = other_doc.att
    return [doc, "updated doc"];
}


How I can get other_doc in my update function?


-- 
М.

http://diglossa.org
xmpp://m.bykov@jabber.ru

Re: updates document question

Posted by Michael Bykov <m....@gmail.com>.
2011/5/30 Sean Copenhaver <se...@gmail.com>:
> I'm not completely sure what you are asking, but if you are trying to load or modify multiple documents with an update function I don't believe you can.
>
> You are allowed to create a new doc, modify the passed in doc, or do nothing (so long as you return [null, response]). If you want to retrieve a document, perform logic on them, then save, I believe you have to do that on the client and you can save them both at once using _bulk_docs API.
>

> https://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request
>
>
> --
> Sean Copenhaver
> Sent with Sparrow
> On Monday, May 30, 2011 at 2:25 PM, Michael Bykov wrote:
>> Sorry, I am a complete newbie in couchdb.
>>
>> I am in update function
>>
>> function(doc, req) {
>>  doc.att = other_doc.att
>>  return [doc, "updated doc"];
>> }
>>
>>
>> How I can get other_doc in my update function?
>>
>>
>> --
>> М.
>>
>> http://diglossa.org
>> xmpp://m.bykov@jabber.ru
>>
>


Thank you, Sean, ok


-- 
М.

http://diglossa.ru
xmpp://m.bykov@jabber.ru

Re: updates document question

Posted by Sean Copenhaver <se...@gmail.com>.
I'm not completely sure what you are asking, but if you are trying to load or modify multiple documents with an update function I don't believe you can. 

You are allowed to create a new doc, modify the passed in doc, or do nothing (so long as you return [null, response]). If you want to retrieve a document, perform logic on them, then save, I believe you have to do that on the client and you can save them both at once using _bulk_docs API.

https://wiki.apache.org/couchdb/HTTP_Bulk_Document_API#Modify_Multiple_Documents_With_a_Single_Request


-- 
Sean Copenhaver
Sent with Sparrow
On Monday, May 30, 2011 at 2:25 PM, Michael Bykov wrote: 
> Sorry, I am a complete newbie in couchdb.
> 
> I am in update function
> 
> function(doc, req) {
>  doc.att = other_doc.att
>  return [doc, "updated doc"];
> }
> 
> 
> How I can get other_doc in my update function?
> 
> 
> -- 
> М.
> 
> http://diglossa.org
> xmpp://m.bykov@jabber.ru
>