You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by John Le Brasseur <jo...@gmail.com> on 2017/02/12 15:19:42 UTC

Getting, editing and (re-)Posting docs to update them:

Hi.
I am getting(GET) all the docs from my database in order to try and update
certain data in all of them and then POST the edited docs to update the
database.


However, the documents contain extra data which looks like this:

 "id": "d8d006c66c0e4555bf12e5d086003010",
      "key": "d8d006c66c0e4555bf12e5d086003010",
      "value": {
        "rev": "28-38526f3787b1fcedc82624419709c347"
      },
      "doc": { ....


This is followed by the actual document:

 "_id": "d8d006c66c0e4555bf12e5d086003010",
 "_rev": "28-38526f3787b1fcedc82624419709c347",
        ...........etc.



Is there a way to get output without this data added?

If not I presume one must remove this manually every time one wishes to
edit documents.

Many thanks.

John

Re: Getting, editing and (re-)Posting docs to update them:

Posted by John Le Brasseur <jo...@gmail.com>.
I have switched to (Ruby)ppjson.
Sorry about that.
(of course Couch would not sort the doc contents!!!)

Thanks again Joan.


On 13 February 2017 at 15:55, John Le Brasseur <jo...@gmail.com>
wrote:

> Mmmm!
> I think  (python)json.tool in Vim put each doc's contents in alphabetical
> order, not CouchDB. Is there a way of forcing json.tool NOT to sort??
> Can't find it so far.
>
> On 13 February 2017 at 14:39, John Le Brasseur <jo...@gmail.com>
> wrote:
>
>> Thanks Joan.
>> Thanks especially for the tip that _all_docs is a view!!
>> I am working on this matter, but find the GET docs are also sorted
>> alphabetically which is irritating as the original docs had a sequence for
>> a reason. Is there a way to avoid the sorting of the output.
>> I presume once updated the order is permanent.
>>
>>
>> On 12 February 2017 at 22:42, Joan Touzet <wo...@apache.org> wrote:
>>
>>> Hi John,
>>>
>>> The standard procedure generally is a GET-modify-PUT cycle, one document
>>> at a time.
>>>
>>> Remember that _all_docs is basically a built in view. You're presumably
>>> adding include_docs=true to that view request to get the format you're
>>> seeing (or your client is doing this for you).
>>>
>>> A simple:
>>>
>>> doc = doc.doc
>>>
>>> or equivalent in your language should limit scope to just the document
>>> itself.
>>>
>>> Good luck,
>>> Joan
>>>
>>> ----- Original Message -----
>>> > From: "John Le Brasseur" <jo...@gmail.com>
>>> > To: user@couchdb.apache.org
>>> > Sent: Sunday, February 12, 2017 10:19:42 AM
>>> > Subject: Getting, editing and (re-)Posting docs to update them:
>>> >
>>> > Hi.
>>> > I am getting(GET) all the docs from my database in order to try and
>>> > update
>>> > certain data in all of them and then POST the edited docs to update
>>> > the
>>> > database.
>>> >
>>> >
>>> > However, the documents contain extra data which looks like this:
>>> >
>>> >  "id": "d8d006c66c0e4555bf12e5d086003010",
>>> >       "key": "d8d006c66c0e4555bf12e5d086003010",
>>> >       "value": {
>>> >         "rev": "28-38526f3787b1fcedc82624419709c347"
>>> >       },
>>> >       "doc": { ....
>>> >
>>> >
>>> > This is followed by the actual document:
>>> >
>>> >  "_id": "d8d006c66c0e4555bf12e5d086003010",
>>> >  "_rev": "28-38526f3787b1fcedc82624419709c347",
>>> >         ...........etc.
>>> >
>>> >
>>> >
>>> > Is there a way to get output without this data added?
>>> >
>>> > If not I presume one must remove this manually every time one wishes
>>> > to
>>> > edit documents.
>>> >
>>> > Many thanks.
>>> >
>>> > John
>>> >
>>>
>>
>> John
>>
>>
>>
>
> John
>



John

Re: Getting, editing and (re-)Posting docs to update them:

Posted by John Le Brasseur <jo...@gmail.com>.
Mmmm!
I think  (python)json.tool in Vim put each doc's contents in alphabetical
order, not CouchDB. Is there a way of forcing json.tool NOT to sort??
Can't find it so far.

On 13 February 2017 at 14:39, John Le Brasseur <jo...@gmail.com>
wrote:

> Thanks Joan.
> Thanks especially for the tip that _all_docs is a view!!
> I am working on this matter, but find the GET docs are also sorted
> alphabetically which is irritating as the original docs had a sequence for
> a reason. Is there a way to avoid the sorting of the output.
> I presume once updated the order is permanent.
>
>
> On 12 February 2017 at 22:42, Joan Touzet <wo...@apache.org> wrote:
>
>> Hi John,
>>
>> The standard procedure generally is a GET-modify-PUT cycle, one document
>> at a time.
>>
>> Remember that _all_docs is basically a built in view. You're presumably
>> adding include_docs=true to that view request to get the format you're
>> seeing (or your client is doing this for you).
>>
>> A simple:
>>
>> doc = doc.doc
>>
>> or equivalent in your language should limit scope to just the document
>> itself.
>>
>> Good luck,
>> Joan
>>
>> ----- Original Message -----
>> > From: "John Le Brasseur" <jo...@gmail.com>
>> > To: user@couchdb.apache.org
>> > Sent: Sunday, February 12, 2017 10:19:42 AM
>> > Subject: Getting, editing and (re-)Posting docs to update them:
>> >
>> > Hi.
>> > I am getting(GET) all the docs from my database in order to try and
>> > update
>> > certain data in all of them and then POST the edited docs to update
>> > the
>> > database.
>> >
>> >
>> > However, the documents contain extra data which looks like this:
>> >
>> >  "id": "d8d006c66c0e4555bf12e5d086003010",
>> >       "key": "d8d006c66c0e4555bf12e5d086003010",
>> >       "value": {
>> >         "rev": "28-38526f3787b1fcedc82624419709c347"
>> >       },
>> >       "doc": { ....
>> >
>> >
>> > This is followed by the actual document:
>> >
>> >  "_id": "d8d006c66c0e4555bf12e5d086003010",
>> >  "_rev": "28-38526f3787b1fcedc82624419709c347",
>> >         ...........etc.
>> >
>> >
>> >
>> > Is there a way to get output without this data added?
>> >
>> > If not I presume one must remove this manually every time one wishes
>> > to
>> > edit documents.
>> >
>> > Many thanks.
>> >
>> > John
>> >
>>
>
> John
>
>
>

John

Re: Getting, editing and (re-)Posting docs to update them:

Posted by John Le Brasseur <jo...@gmail.com>.
Thanks Joan.
Thanks especially for the tip that _all_docs is a view!!
I am working on this matter, but find the GET docs are also sorted
alphabetically which is irritating as the original docs had a sequence for
a reason. Is there a way to avoid the sorting of the output.
I presume once updated the order is permanent.


On 12 February 2017 at 22:42, Joan Touzet <wo...@apache.org> wrote:

> Hi John,
>
> The standard procedure generally is a GET-modify-PUT cycle, one document
> at a time.
>
> Remember that _all_docs is basically a built in view. You're presumably
> adding include_docs=true to that view request to get the format you're
> seeing (or your client is doing this for you).
>
> A simple:
>
> doc = doc.doc
>
> or equivalent in your language should limit scope to just the document
> itself.
>
> Good luck,
> Joan
>
> ----- Original Message -----
> > From: "John Le Brasseur" <jo...@gmail.com>
> > To: user@couchdb.apache.org
> > Sent: Sunday, February 12, 2017 10:19:42 AM
> > Subject: Getting, editing and (re-)Posting docs to update them:
> >
> > Hi.
> > I am getting(GET) all the docs from my database in order to try and
> > update
> > certain data in all of them and then POST the edited docs to update
> > the
> > database.
> >
> >
> > However, the documents contain extra data which looks like this:
> >
> >  "id": "d8d006c66c0e4555bf12e5d086003010",
> >       "key": "d8d006c66c0e4555bf12e5d086003010",
> >       "value": {
> >         "rev": "28-38526f3787b1fcedc82624419709c347"
> >       },
> >       "doc": { ....
> >
> >
> > This is followed by the actual document:
> >
> >  "_id": "d8d006c66c0e4555bf12e5d086003010",
> >  "_rev": "28-38526f3787b1fcedc82624419709c347",
> >         ...........etc.
> >
> >
> >
> > Is there a way to get output without this data added?
> >
> > If not I presume one must remove this manually every time one wishes
> > to
> > edit documents.
> >
> > Many thanks.
> >
> > John
> >
>

John

Re: Getting, editing and (re-)Posting docs to update them:

Posted by Joan Touzet <wo...@apache.org>.
Hi John,

The standard procedure generally is a GET-modify-PUT cycle, one document
at a time.

Remember that _all_docs is basically a built in view. You're presumably
adding include_docs=true to that view request to get the format you're
seeing (or your client is doing this for you).

A simple:

doc = doc.doc

or equivalent in your language should limit scope to just the document
itself.

Good luck,
Joan

----- Original Message -----
> From: "John Le Brasseur" <jo...@gmail.com>
> To: user@couchdb.apache.org
> Sent: Sunday, February 12, 2017 10:19:42 AM
> Subject: Getting, editing and (re-)Posting docs to update them:
> 
> Hi.
> I am getting(GET) all the docs from my database in order to try and
> update
> certain data in all of them and then POST the edited docs to update
> the
> database.
> 
> 
> However, the documents contain extra data which looks like this:
> 
>  "id": "d8d006c66c0e4555bf12e5d086003010",
>       "key": "d8d006c66c0e4555bf12e5d086003010",
>       "value": {
>         "rev": "28-38526f3787b1fcedc82624419709c347"
>       },
>       "doc": { ....
> 
> 
> This is followed by the actual document:
> 
>  "_id": "d8d006c66c0e4555bf12e5d086003010",
>  "_rev": "28-38526f3787b1fcedc82624419709c347",
>         ...........etc.
> 
> 
> 
> Is there a way to get output without this data added?
> 
> If not I presume one must remove this manually every time one wishes
> to
> edit documents.
> 
> Many thanks.
> 
> John
>