You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benoit Chesneau <bc...@gmail.com> on 2009/09/13 10:00:14 UTC
POST/PUT on _show vs POST/PUT on _update + GET on _show
Following our discussion with jan____ and jchris on irc i'm asking
here my question if having POST/PUT on _show wouldn't be enough rather
than having a special handler for this. Main raison about it, would be
that it would me more restful. Imho it also offers a simple API on
client side.
jan__ args that it would mess the api. And indeed if you accept
POST/PUT you need to say to couchdb what you return (doc, http
response, newdoc ...). I guess defaults could be POST = new doc, PUT =
update doc like current api on /db/docid, maybe ther is a smart way to
handle it. I was thinking to something like sammyjs, with get/post/put
response and filter on Accept format which is now handle by
respondWith.
What do you think about it ? The proper point is to replace or skip
the need of another handler and make it more simple/restful.
- benoit
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Paul Davis <pa...@gmail.com>.
On Sun, Sep 13, 2009 at 4:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
> It seams intuitive that _show actually shows you something and does
> not handle update actions.
>
> On the other hand why would we need an _update thing? Doesn't CouchDB
> handle that itself?
> (Excuse me if the question is stupid, I was not on #couchdb at the
> time when this discussion took place.)
>
_update allows you to mutate incoming JSON docs before they get saved
to the database.
Paul Davis
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Jan Lehnardt <ja...@apache.org>.
On 13 Sep 2009, at 10:12, Vlad GURDIGA wrote:
> It seams intuitive that _show actually shows you something and does
> not handle update actions.
>
> On the other hand why would we need an _update thing? Doesn't CouchDB
> handle that itself?
> (Excuse me if the question is stupid, I was not on #couchdb at the
> time when this discussion took place.)
No worries, this is the only forum where dev-issues like this should
be discussed, you don't need an excuse for not being on IRC :)
The _update handler can take an arbitrary content and turn it into
a document. Like an XML doc, or HTML form and so on.
Cheers
Jan
--
>
>
> On Sun, Sep 13, 2009 at 1:00 AM, Benoit Chesneau
> <bc...@gmail.com> wrote:
>> Following our discussion with jan____ and jchris on irc i'm asking
>> here my question if having POST/PUT on _show wouldn't be enough
>> rather
>> than having a special handler for this. Main raison about it, would
>> be
>> that it would me more restful. Imho it also offers a simple API on
>> client side.
>>
>> jan__ args that it would mess the api. And indeed if you accept
>> POST/PUT you need to say to couchdb what you return (doc, http
>> response, newdoc ...). I guess defaults could be POST = new doc,
>> PUT =
>> update doc like current api on /db/docid, maybe ther is a smart way
>> to
>> handle it. I was thinking to something like sammyjs, with get/post/
>> put
>> response and filter on Accept format which is now handle by
>> respondWith.
>>
>> What do you think about it ? The proper point is to replace or skip
>> the need of another handler and make it more simple/restful.
>>
>> - benoit
>>
>
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Vlad GURDIGA <gu...@gmail.com>.
On Tue, Sep 15, 2009 at 8:46 AM, Chris Anderson <jc...@apache.org> wrote:
> On Mon, Sep 14, 2009 at 9:47 PM, Vlad GURDIGA <gu...@gmail.com> wrote:
>> Thank you Jan for the comment.
>>
>>
>> On Sun, Sep 13, 2009 at 8:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>>
>>> On 13 Sep 2009, at 19:37, Vlad GURDIGA wrote:
>>>
>>>> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com>
>>>> wrote:
>>>>>
>>>>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>>>>>>
>>>>>> It seams intuitive that _show actually shows you something and does
>>>>>> not handle update actions.
>>>>>>
>>>>> I agre that it in this case show isn't a good word. maybe "_page" and
>>>>> then "_pages" for _list but that another debate.
>>>>>
>>>>>> On the other hand why would we need an _update thing? Doesn't CouchDB
>>>>>> handle that itself?
>>>>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>>>>> time when this discussion took place.)
>>>>>>
>>>>>
>>>>>
>>>>> _upate allow you to handle any input before saving them in couch like
>>>>> xml, csv whatever or it could be also use to post some doc without
>>>>> requiring ajax to do it.
>>>>
>>>> To me, keeping the server simple (which also means less complicated
>>>> and buggy) and fast looks like a very nice idea. Splitting the
>>>> computation burden between clients and server looks to me like a fair
>>>> enough trade this time.
>>>>
>>>> And, I believe that the several percent of the clients that do not
>>>> speak AJAX or cannot produce JSON should not dictate such a big change
>>>> in CouchDB.
>>>
>>> _update already exists :) And it is very useful for webhooks that we don't
>>> control.
>>
>> Could you please give an example or two?
>>
>>> being able to tell google's svn to ping CouchDB about a new commit
>>> without resorting to proxies is very powerful :)
>>
>> I have no idea about how SVN would ping a CouchDB app. Could you
>> please elaborate on this?
>>
>> I really appreciate the work you are doing guys, I'd love to get
>> involved, and I'm trying to understand the flow of things here.
>>
>
> In the specific example, imagine a web service (A) that POSTs an
> XML-blob at a URL of your choosing, when particular events occur.
> Paypal's instant payment notification is one of these.
>
> With an _update handler you can POST these directly at CouchDB and it
> can parse the XML into a JSON document and save it. The same goes for
> CSV, multipart form, or any other format.
>
>>
>> Thanks a lot!
>>
>
> The bigger picture we're working on is like an app server, but
> different in one crucial regard: rather than let the developer do
> whatever they want (loop of a list of docids and make queries, make
> queries based on the results of other queries, etc) we're defining
> "safe" transformations, like view, show, list and update.
That is exactly what I was worried about!
I think that not giving the application developers too many
opportunities to screw up is a very good characteristic of a
development platform.
Thanks a lot for clearing this up!
>
> By safe I mean that they have well known performance characteristics,
> and otherwise fit into CouchDB's architecture in a streamlined way.
>
> The big picture goal is to provide a way to build standalone apps that
> can also be easily indexed by search engines and used via
> screen-readers. Hence the push for plain-old html. I agree that you
> can pretty much rely on JS getting executed (except when you can't).
> Having HTML resources means CouchDB is suitable for public-facing web
> apps.
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Chris Anderson <jc...@apache.org>.
On Mon, Sep 14, 2009 at 9:47 PM, Vlad GURDIGA <gu...@gmail.com> wrote:
> Thank you Jan for the comment.
>
>
> On Sun, Sep 13, 2009 at 8:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>>
>> On 13 Sep 2009, at 19:37, Vlad GURDIGA wrote:
>>
>>> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com>
>>> wrote:
>>>>
>>>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>>>>>
>>>>> It seams intuitive that _show actually shows you something and does
>>>>> not handle update actions.
>>>>>
>>>> I agre that it in this case show isn't a good word. maybe "_page" and
>>>> then "_pages" for _list but that another debate.
>>>>
>>>>> On the other hand why would we need an _update thing? Doesn't CouchDB
>>>>> handle that itself?
>>>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>>>> time when this discussion took place.)
>>>>>
>>>>
>>>>
>>>> _upate allow you to handle any input before saving them in couch like
>>>> xml, csv whatever or it could be also use to post some doc without
>>>> requiring ajax to do it.
>>>
>>> To me, keeping the server simple (which also means less complicated
>>> and buggy) and fast looks like a very nice idea. Splitting the
>>> computation burden between clients and server looks to me like a fair
>>> enough trade this time.
>>>
>>> And, I believe that the several percent of the clients that do not
>>> speak AJAX or cannot produce JSON should not dictate such a big change
>>> in CouchDB.
>>
>> _update already exists :) And it is very useful for webhooks that we don't
>> control.
>
> Could you please give an example or two?
>
>> being able to tell google's svn to ping CouchDB about a new commit
>> without resorting to proxies is very powerful :)
>
> I have no idea about how SVN would ping a CouchDB app. Could you
> please elaborate on this?
>
> I really appreciate the work you are doing guys, I'd love to get
> involved, and I'm trying to understand the flow of things here.
>
In the specific example, imagine a web service (A) that POSTs an
XML-blob at a URL of your choosing, when particular events occur.
Paypal's instant payment notification is one of these.
With an _update handler you can POST these directly at CouchDB and it
can parse the XML into a JSON document and save it. The same goes for
CSV, multipart form, or any other format.
>
> Thanks a lot!
>
The bigger picture we're working on is like an app server, but
different in one crucial regard: rather than let the developer do
whatever they want (loop of a list of docids and make queries, make
queries based on the results of other queries, etc) we're defining
"safe" transformations, like view, show, list and update.
By safe I mean that they have well known performance characteristics,
and otherwise fit into CouchDB's architecture in a streamlined way.
The big picture goal is to provide a way to build standalone apps that
can also be easily indexed by search engines and used via
screen-readers. Hence the push for plain-old html. I agree that you
can pretty much rely on JS getting executed (except when you can't).
Having HTML resources means CouchDB is suitable for public-facing web
apps.
--
Chris Anderson
http://jchrisa.net
http://couch.io
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Vlad GURDIGA <gu...@gmail.com>.
Thank you Jan for the comment.
On Sun, Sep 13, 2009 at 8:58 PM, Jan Lehnardt <ja...@apache.org> wrote:
>
> On 13 Sep 2009, at 19:37, Vlad GURDIGA wrote:
>
>> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com>
>> wrote:
>>>
>>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>>>>
>>>> It seams intuitive that _show actually shows you something and does
>>>> not handle update actions.
>>>>
>>> I agre that it in this case show isn't a good word. maybe "_page" and
>>> then "_pages" for _list but that another debate.
>>>
>>>> On the other hand why would we need an _update thing? Doesn't CouchDB
>>>> handle that itself?
>>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>>> time when this discussion took place.)
>>>>
>>>
>>>
>>> _upate allow you to handle any input before saving them in couch like
>>> xml, csv whatever or it could be also use to post some doc without
>>> requiring ajax to do it.
>>
>> To me, keeping the server simple (which also means less complicated
>> and buggy) and fast looks like a very nice idea. Splitting the
>> computation burden between clients and server looks to me like a fair
>> enough trade this time.
>>
>> And, I believe that the several percent of the clients that do not
>> speak AJAX or cannot produce JSON should not dictate such a big change
>> in CouchDB.
>
> _update already exists :) And it is very useful for webhooks that we don't
> control.
Could you please give an example or two?
> being able to tell google's svn to ping CouchDB about a new commit
> without resorting to proxies is very powerful :)
I have no idea about how SVN would ping a CouchDB app. Could you
please elaborate on this?
I really appreciate the work you are doing guys, I'd love to get
involved, and I'm trying to understand the flow of things here.
Thanks a lot!
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Jan Lehnardt <ja...@apache.org>.
On 13 Sep 2009, at 19:37, Vlad GURDIGA wrote:
> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau
> <bc...@gmail.com> wrote:
>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com>
>> wrote:
>>> It seams intuitive that _show actually shows you something and does
>>> not handle update actions.
>>>
>> I agre that it in this case show isn't a good word. maybe "_page"
>> and
>> then "_pages" for _list but that another debate.
>>
>>> On the other hand why would we need an _update thing? Doesn't
>>> CouchDB
>>> handle that itself?
>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>> time when this discussion took place.)
>>>
>>
>>
>> _upate allow you to handle any input before saving them in couch like
>> xml, csv whatever or it could be also use to post some doc without
>> requiring ajax to do it.
>
> To me, keeping the server simple (which also means less complicated
> and buggy) and fast looks like a very nice idea. Splitting the
> computation burden between clients and server looks to me like a fair
> enough trade this time.
>
> And, I believe that the several percent of the clients that do not
> speak AJAX or cannot produce JSON should not dictate such a big change
> in CouchDB.
_update already exists :) And it is very useful for webhooks that we
don't
control. being able to tell google's svn to ping CouchDB about a new
commit
without resorting to proxies is very powerful :)
> One reason I love CouchDB is it's simplicity. If we bring this
> middle-tier-like functionality in, we will end up with something like
> PHP, GCI, RoR, Java and millions of others in which you *have* to
> process information in one more intermediate tier before being able to
> put it into the DB.
>
> KISS.
No worries about KISS :)
Cheers
Jan
--
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Vlad GURDIGA <gu...@gmail.com>.
On Sun, Sep 13, 2009 at 8:55 PM, Chris Anderson <jc...@apache.org> wrote:
> On Sun, Sep 13, 2009 at 10:37 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com> wrote:
>>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>>>> It seams intuitive that _show actually shows you something and does
>>>> not handle update actions.
>>>>
>>> I agre that it in this case show isn't a good word. maybe "_page" and
>>> then "_pages" for _list but that another debate.
>>>
>>>> On the other hand why would we need an _update thing? Doesn't CouchDB
>>>> handle that itself?
>>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>>> time when this discussion took place.)
>>>>
>>>
>>>
>>> _upate allow you to handle any input before saving them in couch like
>>> xml, csv whatever or it could be also use to post some doc without
>>> requiring ajax to do it.
>>
>> To me, keeping the server simple (which also means less complicated
>> and buggy) and fast looks like a very nice idea. Splitting the
>> computation burden between clients and server looks to me like a fair
>> enough trade this time.
>>
>> And, I believe that the several percent of the clients that do not
>> speak AJAX or cannot produce JSON should not dictate such a big change
>> in CouchDB.
>>
>
> The notion is that by allowing non JSON updates, we are available to a
> wider range of clients without using a middle tier.
Excuse me, can I ask: what clients are you thinking about?
And regarding middle-tier: wouldn't that _update logic be the middle
tier now when it sits between HTTP-client and DB?
> So in particular a browser with JavaScript turned off could make a
> regular form post to an _update handler and it would manage parsing it
> into JSON and saving it.
I'm a web-developer for a few years now and it seams to me that i's
not really serious to turn Javascript off in a Web 2.0 world. I think
that it's just a very few paranoid people that do that. Event fewer
browsers do not support Javascript at all.
Both of those groups will be gone anyway in a few years, this is why I
believe we should prepare for the future more apt clients.
> I'm not sure about whether update should be the same as _show - it may
> be more restful in some cases, but as Jan mentioned, there are times
> when a single update request might result in multiple documents, in
> which case it's own resource makes more sense.
Could you please give an example of such a scenario? I just want to be
sure that I get it right.
Thank you!
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Chris Anderson <jc...@apache.org>.
On Sun, Sep 13, 2009 at 10:37 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
> On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>>> It seams intuitive that _show actually shows you something and does
>>> not handle update actions.
>>>
>> I agre that it in this case show isn't a good word. maybe "_page" and
>> then "_pages" for _list but that another debate.
>>
>>> On the other hand why would we need an _update thing? Doesn't CouchDB
>>> handle that itself?
>>> (Excuse me if the question is stupid, I was not on #couchdb at the
>>> time when this discussion took place.)
>>>
>>
>>
>> _upate allow you to handle any input before saving them in couch like
>> xml, csv whatever or it could be also use to post some doc without
>> requiring ajax to do it.
>
> To me, keeping the server simple (which also means less complicated
> and buggy) and fast looks like a very nice idea. Splitting the
> computation burden between clients and server looks to me like a fair
> enough trade this time.
>
> And, I believe that the several percent of the clients that do not
> speak AJAX or cannot produce JSON should not dictate such a big change
> in CouchDB.
>
The notion is that by allowing non JSON updates, we are available to a
wider range of clients without using a middle tier.
So in particular a browser with JavaScript turned off could make a
regular form post to an _update handler and it would manage parsing it
into JSON and saving it.
I'm not sure about whether update should be the same as _show - it may
be more restful in some cases, but as Jan mentioned, there are times
when a single update request might result in multiple documents, in
which case it's own resource makes more sense.
> One reason I love CouchDB is it's simplicity. If we bring this
> middle-tier-like functionality in, we will end up with something like
> PHP, GCI, RoR, Java and millions of others in which you *have* to
> process information in one more intermediate tier before being able to
> put it into the DB.
>
> KISS.
>
--
Chris Anderson
http://jchrisa.net
http://couch.io
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Vlad GURDIGA <gu...@gmail.com>.
On Sun, Sep 13, 2009 at 1:17 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
>> It seams intuitive that _show actually shows you something and does
>> not handle update actions.
>>
> I agre that it in this case show isn't a good word. maybe "_page" and
> then "_pages" for _list but that another debate.
>
>> On the other hand why would we need an _update thing? Doesn't CouchDB
>> handle that itself?
>> (Excuse me if the question is stupid, I was not on #couchdb at the
>> time when this discussion took place.)
>>
>
>
> _upate allow you to handle any input before saving them in couch like
> xml, csv whatever or it could be also use to post some doc without
> requiring ajax to do it.
To me, keeping the server simple (which also means less complicated
and buggy) and fast looks like a very nice idea. Splitting the
computation burden between clients and server looks to me like a fair
enough trade this time.
And, I believe that the several percent of the clients that do not
speak AJAX or cannot produce JSON should not dictate such a big change
in CouchDB.
One reason I love CouchDB is it's simplicity. If we bring this
middle-tier-like functionality in, we will end up with something like
PHP, GCI, RoR, Java and millions of others in which you *have* to
process information in one more intermediate tier before being able to
put it into the DB.
KISS.
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Benoit Chesneau <bc...@gmail.com>.
On Sun, Sep 13, 2009 at 10:12 AM, Vlad GURDIGA <gu...@gmail.com> wrote:
> It seams intuitive that _show actually shows you something and does
> not handle update actions.
>
I agre that it in this case show isn't a good word. maybe "_page" and
then "_pages" for _list but that another debate.
> On the other hand why would we need an _update thing? Doesn't CouchDB
> handle that itself?
> (Excuse me if the question is stupid, I was not on #couchdb at the
> time when this discussion took place.)
>
_upate allow you to handle any input before saving them in couch like
xml, csv whatever or it could be also use to post some doc without
requiring ajax to do it.
- benoit
Re: POST/PUT on _show vs POST/PUT on _update + GET on _show
Posted by Vlad GURDIGA <gu...@gmail.com>.
It seams intuitive that _show actually shows you something and does
not handle update actions.
On the other hand why would we need an _update thing? Doesn't CouchDB
handle that itself?
(Excuse me if the question is stupid, I was not on #couchdb at the
time when this discussion took place.)
On Sun, Sep 13, 2009 at 1:00 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> Following our discussion with jan____ and jchris on irc i'm asking
> here my question if having POST/PUT on _show wouldn't be enough rather
> than having a special handler for this. Main raison about it, would be
> that it would me more restful. Imho it also offers a simple API on
> client side.
>
> jan__ args that it would mess the api. And indeed if you accept
> POST/PUT you need to say to couchdb what you return (doc, http
> response, newdoc ...). I guess defaults could be POST = new doc, PUT =
> update doc like current api on /db/docid, maybe ther is a smart way to
> handle it. I was thinking to something like sammyjs, with get/post/put
> response and filter on Accept format which is now handle by
> respondWith.
>
> What do you think about it ? The proper point is to replace or skip
> the need of another handler and make it more simple/restful.
>
> - benoit
>