You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Benjamin Young <by...@bigbluehat.com> on 2013/12/03 15:01:48 UTC
[PROPOSAL] new underscore namespacing
Hi all,
Recently the "doc._*" reservation has been causing me trouble when
pulling in "arbitrary" JSON from various sources that also use the
underscore prefixed names for things (HAL [1], vnd.error [2], other
APIs). I've also hit the wall several times when trying to import
filesystem contents (Sphinx, ghpages, and the like) that use _*
prefixing for their "special folders."
As such, I'd like to propose the following:
1. Begin storing new reserved terms in doc._.* (rather than doc._*).
- this gives developers one object to look into for the meta-data
about a doc
- you can see the scope creep of our current doc._* best in the
replicator status messages.
- doc._ replication_* would become doc._.replication.*
2. Move "magic" API endpoints under "/_/" term as well (for the sake of
attachments.
- _design/doc would stay the same
- but the child endpoints would live under "_design/doc/_/*"
- _design/doc/_/view/by_date
- _design/doc/_/list/by_date/ul
- _design/doc/_/rewrite
I realize these are extreme API shifts, and would need to wait for
CouchDB 2.0.
The first steps this direction would be to put new reserved word keys
into a "doc._.*" namespace going forward. Closer to the "cut over" for
2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
could also live at their new underscore prefixed names (doc._.id,
doc._.rev) which would give devs a chance to migrate code and content.
Doing this would:
1. Give us "limitless" space to add content.
2. Encourage a namespacing pattern for things like doc._.replication.*
or other logically grouped content.
3. Free up CouchDB to accept a far broader range of content and remove
the "hey, you can't put that there! I was here first!" errors. :)
Thanks for considering this,
Benjamin
[1] http://stateless.co/hal_specification.html
[2] https://github.com/blongden/vnd.error
Re: [PROPOSAL] new underscore namespacing
Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Dec 3, 2013 at 7:12 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>
>
> On Tue, Dec 3, 2013 at 3:01 PM, Benjamin Young <by...@bigbluehat.com>wrote:
>
>> Hi all,
>>
>> Recently the "doc._*" reservation has been causing me trouble when
>> pulling in "arbitrary" JSON from various sources that also use the
>> underscore prefixed names for things (HAL [1], vnd.error [2], other APIs).
>> I've also hit the wall several times when trying to import filesystem
>> contents (Sphinx, ghpages, and the like) that use _* prefixing for their
>> "special folders."
>>
>> As such, I'd like to propose the following:
>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>> - this gives developers one object to look into for the meta-data about
>> a doc
>> - you can see the scope creep of our current doc._* best in the
>> replicator status messages.
>> - doc._ replication_* would become doc._.replication.*
>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>> attachments.
>> - _design/doc would stay the same
>> - but the child endpoints would live under "_design/doc/_/*"
>> - _design/doc/_/view/by_date
>> - _design/doc/_/list/by_date/ul
>> - _design/doc/_/rewrite
>>
>> I realize these are extreme API shifts, and would need to wait for
>> CouchDB 2.0.
>>
>> The first steps this direction would be to put new reserved word keys
>> into a "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
>> duplicates of the existing keys (doc._id, doc._rev, especially) could also
>> live at their new underscore prefixed names (doc._.id, doc._.rev) which
>> would give devs a chance to migrate code and content.
>>
>> Doing this would:
>> 1. Give us "limitless" space to add content.
>> 2. Encourage a namespacing pattern for things like doc._.replication.* or
>> other logically grouped content.
>> 3. Free up CouchDB to accept a far broader range of content and remove
>> the "hey, you can't put that there! I was here first!" errors. :)
>>
>> Thanks for considering this,
>> Benjamin
>>
>> [1] http://stateless.co/hal_specification.html
>> [2] https://github.com/blongden/vnd.error
>>
>
> I don't see why couchdb should adapt itself to newer things that didn't
> take care of an older API when doing their stuff but that's probably
> another concern ;)
>
> I would find a "/_/" in the URL rather ugly and not needed in that case.
> Same for having a _ in a doc. also it doesn't have much sense. Why do you
> want to change the HTTP api at that level?
>
> Another way to do it and probably more restish woudl be moving all couchdb
> resources in their own namespace. Say `couchdb/` for example. so anything
> in the resource couchdb will be related to couchdb.
>
> Next is the the prefix "_" in the doc. It's actually reserved because
> sometimes, once day we will add other metadata which is fine. But raises
> the issue you have.
>
> If I summarise the discussion here amd precedent discussions there are
> different school there:
>
> - remove the metadata from the doc and put them in headers or aside. I
> quite like the first solution, though it may be a problem behind some
> proxies, or with the header length (especially for json values). Also
> headers are supposed to be in latin1 in a lot of clients...
> - put the metadata in their own namespace which is what you propose.
>
> I dislike the last solution. Mostly because it would force the clients to
> wait this namespace to read the metadata while parsing the JSON (which
> could be when streaming it). Instead I would prefer to keep them at the
> first level and due the reverse: put the data in their own namespace, say
> `_data`. This allows any clients to ignore this layer if needed while
> parsing the JSON and get it directly (without parsing then). The metadata
> should be the first citizem imo. Optionally we could add some new
> parameters to the doc api allowing someone to only fetch the metadata,
> etc.. Also couchdb could also parse the coming doc and stop to parse the
> json when seeing this property and store it directly. It is also following
> the logic of attachments somehow. Another things that could be done at the
> api level is having smth like `/db/docid/_data` which would allows you to
> only retrieve the data instead of using a show function.
>
> What do you think?
>
> - benoit
>
>
> s/due/do (exhausted)
Re: [PROPOSAL] new underscore namespacing
Posted by "Florian Westreicher Bakk.techn." <st...@meredrica.org>.
I would also not like meta data in the form of headers. AFAIK headers have a finite length and setting them is not as straight forward as putting some json into the request body.
Also you would have to carry over all the header information from the get request when you update a doc or its metadata, which is not easy in some situations.
That said, I like the idea of user writable metadata since I have quite some use cases for it. Right now I handle the metadata for my application in the document itself which is not the right place.
Benoit Chesneau <bc...@gmail.com> wrote:
>On Wed, Dec 18, 2013 at 5:39 PM, Volker Mische
><vo...@gmail.com>wrote:
>
>> On 12/03/2013 07:12 PM, Benoit Chesneau wrote:
>> > On Tue, Dec 3, 2013 at 3:01 PM, Benjamin Young
><byoung@bigbluehat.com
>> >wrote:
>> >
>> >> Hi all,
>> >>
>> >> Recently the "doc._*" reservation has been causing me trouble when
>> pulling
>> >> in "arbitrary" JSON from various sources that also use the
>underscore
>> >> prefixed names for things (HAL [1], vnd.error [2], other APIs).
>I've
>> also
>> >> hit the wall several times when trying to import filesystem
>contents
>> >> (Sphinx, ghpages, and the like) that use _* prefixing for their
>"special
>> >> folders."
>> >>
>> >> As such, I'd like to propose the following:
>> >> 1. Begin storing new reserved terms in doc._.* (rather than
>doc._*).
>> >> - this gives developers one object to look into for the meta-data
>> about a
>> >> doc
>> >> - you can see the scope creep of our current doc._* best in the
>> >> replicator status messages.
>> >> - doc._ replication_* would become doc._.replication.*
>> >> 2. Move "magic" API endpoints under "/_/" term as well (for the
>sake of
>> >> attachments.
>> >> - _design/doc would stay the same
>> >> - but the child endpoints would live under "_design/doc/_/*"
>> >> - _design/doc/_/view/by_date
>> >> - _design/doc/_/list/by_date/ul
>> >> - _design/doc/_/rewrite
>> >>
>> >> I realize these are extreme API shifts, and would need to wait for
>> CouchDB
>> >> 2.0.
>> >>
>> >> The first steps this direction would be to put new reserved word
>keys
>> into
>> >> a "doc._.*" namespace going forward. Closer to the "cut over" for
>2.0
>> >> duplicates of the existing keys (doc._id, doc._rev, especially)
>could
>> also
>> >> live at their new underscore prefixed names (doc._.id, doc._.rev)
>which
>> >> would give devs a chance to migrate code and content.
>> >>
>> >> Doing this would:
>> >> 1. Give us "limitless" space to add content.
>> >> 2. Encourage a namespacing pattern for things like
>doc._.replication.*
>> or
>> >> other logically grouped content.
>> >> 3. Free up CouchDB to accept a far broader range of content and
>remove
>> the
>> >> "hey, you can't put that there! I was here first!" errors. :)
>> >>
>> >> Thanks for considering this,
>> >> Benjamin
>> >>
>> >> [1] http://stateless.co/hal_specification.html
>> >> [2] https://github.com/blongden/vnd.error
>> >>
>> >
>> > I don't see why couchdb should adapt itself to newer things that
>didn't
>> > take care of an older API when doing their stuff but that's
>probably
>> > another concern ;)
>> >
>> > I would find a "/_/" in the URL rather ugly and not needed in that
>case.
>> > Same for having a _ in a doc. also it doesn't have much sense. Why
>do
>> you
>> > want to change the HTTP api at that level?
>> >
>> > Another way to do it and probably more restish woudl be moving all
>> couchdb
>> > resources in their own namespace. Say `couchdb/` for example. so
>anything
>> > in the resource couchdb will be related to couchdb.
>> >
>> > Next is the the prefix "_" in the doc. It's actually reserved
>because
>> > sometimes, once day we will add other metadata which is fine. But
>raises
>> > the issue you have.
>> >
>> > If I summarise the discussion here amd precedent discussions there
>are
>> > different school there:
>> >
>> > - remove the metadata from the doc and put them in headers or
>aside. I
>> > quite like the first solution, though it may be a problem behind
>some
>> > proxies, or with the header length (especially for json values).
>Also
>> > headers are supposed to be in latin1 in a lot of clients...
>> > - put the metadata in their own namespace which is what you
>propose.
>> >
>> > I dislike the last solution. Mostly because it would force the
>clients to
>> > wait this namespace to read the metadata while parsing the JSON
>(which
>> > could be when streaming it). Instead I would prefer to keep them at
>the
>> > first level and due the reverse: put the data in their own
>namespace, say
>> > `_data`. This allows any clients to ignore this layer if needed
>while
>> > parsing the JSON and get it directly (without parsing then). The
>> metadata
>> > should be the first citizem imo. Optionally we could add some new
>> > parameters to the doc api allowing someone to only fetch the
>metadata,
>> > etc.. Also couchdb could also parse the coming doc and stop to
>parse the
>> > json when seeing this property and store it directly. It is also
>> following
>> > the logic of attachments somehow. Another things that could be done
>at
>> the
>> > api level is having smth like `/db/docid/_data` which would allows
>you to
>> > only retrieve the data instead of using a show function.
>> >
>> > What do you think?
>> >
>> > - benoit
>>
>> Hi all,
>>
>> I've been talking with Benoit about this at the CouchHack. I think
>his
>> proposal makes a lot of sense. Let's take the separation of meta and
>the
>> document body (as I proposed) together with what Benoit said.
>>
>> When storing the actual data in a top-level property called "_data",
>you
>> could easily extract the meta information, without parsing the body
>at
>> all. You just need to parse all the top level properties (which you
>need
>> to do anyway as JSON doesn't have any distinct sorting).
>>
>> Having this could be a great first step towards making meta and
>document
>> body separation easier to implement.
>>
>> In a next step you could then e.g. provide an API where you just send
>> the document body, with the meta as headers.
>>
>> Cheers,
>> Volker
>>
>>
>
>I recently started a new project where having the metadata and the
>content
>separated would make a lot of sense. Here is a quick summary in vrac of
>my
>thinking about it.
>
>- With our current concurrency model, it makes sense to have the
>metadata
>coming with the document. Having them coming in a separate commit/doc
>would
>create a lot of problems in a distributed environment (what happen when
>a
>doc is edited on 2 places and the metadata updated apart). Our revision
>model is here to solve such things.
>
>- It would be interesting to let the user set its own metadata coming
>with
>a document. We could imagine someone adding timestamps, the other
>adding
>authentication infos, .. Some metadata could also be hidden to the user
>that replicate or fetch the doc. Metadata should be really thought a
>description of the doc and the way it will be shared/stored, nothing
>much.
>Ie. mainly used for internal purposes and some could be local to a
>node. It
>also answers to the original problem that raised this thread: we could
>design some entry points in the api that only return the body of the
>doc
>(without its metadata) so the clients would be happy with it. Or such
>thing.
>
>- I like attachments. Transforming couchdb in another object database
>(aka
>blob store) is not really that interesting neither innovative. At the
>end,
>most of the users of the blob storages are also using a database to
>index
>the objects. Where in an attachment model we are attaching a blob to
>its
>structured description in the doc. Such description can then be indexed
>using the views. I think i the future couchdb should consider
>attachments
>as links attached to a doc. Such link could be internal like it is now
>but
>also external. The remote link would be transparently handled for the
>one
>that replicate, but at the end we could eventually attach a blob from
>an
>external source. We could also link another doc.... (digression
>spotted)
>
>- About metadata sent outside the JSON or as an header, I have a
>preference
>for having them in the JSON sent to couchdb. Mainly because we could
>then
>support any other protocol than HTTP without having to support
>different
>ways to read the metadata coming with the document. Someone that want
>to
>just use TCP to pass the doc could then just handle the transport logic
>and
>give to couchdb the JSON which will be then indexed. Where in other
>cases
>the transport will also need to manage how it get the metadata.
>
>- If we have the metadata in a JSON, like VMX already told, it's quite
>more efficient to have the metadata at the first level and make the
>content
>available in a `_data` (or `_body`) property. We could then parse the
>JSON
>to fetch all the metadata and omit the `_data` member which will be
>then
>stored on disk. Doing the other way (Having metadata in a `_meta`
>property)
>wouldn't be efficient at all due to the nature of a JSON: there is no
>guaranty about the order of the properties. Also we will have generally
>a
>content bigger than the metadata. (most docs will only have the `_id`
>and
>`_rev`).
>
>After looking at the code , I don't think we need a lot of changes to
>support a system that use a JSON witch separate the metadata from the
>content of the doc. If we are OK with that I could provide quickly a
>patch
>which introduce that change. For the compatibility it could also parse
>the
>full doc when no `_data` (or `_body`) member is found and make it
>transparent for the end user by reading an api version that could come
>in
>the headers.
>
>Anyway this are just my 2 cents on that topic. I would be more than
>happy
>to discuss this topic further so we could introduce such changes
>rapidly in
>our API (even before any merge possibly).
>
>- benoit
--
Sent from Kaiten Mail. Please excuse my brevity.
Re: [PROPOSAL] new underscore namespacing
Posted by Benoit Chesneau <bc...@gmail.com>.
On Wed, Dec 18, 2013 at 5:39 PM, Volker Mische <vo...@gmail.com>wrote:
> On 12/03/2013 07:12 PM, Benoit Chesneau wrote:
> > On Tue, Dec 3, 2013 at 3:01 PM, Benjamin Young <byoung@bigbluehat.com
> >wrote:
> >
> >> Hi all,
> >>
> >> Recently the "doc._*" reservation has been causing me trouble when
> pulling
> >> in "arbitrary" JSON from various sources that also use the underscore
> >> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've
> also
> >> hit the wall several times when trying to import filesystem contents
> >> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
> >> folders."
> >>
> >> As such, I'd like to propose the following:
> >> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> >> - this gives developers one object to look into for the meta-data
> about a
> >> doc
> >> - you can see the scope creep of our current doc._* best in the
> >> replicator status messages.
> >> - doc._ replication_* would become doc._.replication.*
> >> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> >> attachments.
> >> - _design/doc would stay the same
> >> - but the child endpoints would live under "_design/doc/_/*"
> >> - _design/doc/_/view/by_date
> >> - _design/doc/_/list/by_date/ul
> >> - _design/doc/_/rewrite
> >>
> >> I realize these are extreme API shifts, and would need to wait for
> CouchDB
> >> 2.0.
> >>
> >> The first steps this direction would be to put new reserved word keys
> into
> >> a "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
> >> duplicates of the existing keys (doc._id, doc._rev, especially) could
> also
> >> live at their new underscore prefixed names (doc._.id, doc._.rev) which
> >> would give devs a chance to migrate code and content.
> >>
> >> Doing this would:
> >> 1. Give us "limitless" space to add content.
> >> 2. Encourage a namespacing pattern for things like doc._.replication.*
> or
> >> other logically grouped content.
> >> 3. Free up CouchDB to accept a far broader range of content and remove
> the
> >> "hey, you can't put that there! I was here first!" errors. :)
> >>
> >> Thanks for considering this,
> >> Benjamin
> >>
> >> [1] http://stateless.co/hal_specification.html
> >> [2] https://github.com/blongden/vnd.error
> >>
> >
> > I don't see why couchdb should adapt itself to newer things that didn't
> > take care of an older API when doing their stuff but that's probably
> > another concern ;)
> >
> > I would find a "/_/" in the URL rather ugly and not needed in that case.
> > Same for having a _ in a doc. also it doesn't have much sense. Why do
> you
> > want to change the HTTP api at that level?
> >
> > Another way to do it and probably more restish woudl be moving all
> couchdb
> > resources in their own namespace. Say `couchdb/` for example. so anything
> > in the resource couchdb will be related to couchdb.
> >
> > Next is the the prefix "_" in the doc. It's actually reserved because
> > sometimes, once day we will add other metadata which is fine. But raises
> > the issue you have.
> >
> > If I summarise the discussion here amd precedent discussions there are
> > different school there:
> >
> > - remove the metadata from the doc and put them in headers or aside. I
> > quite like the first solution, though it may be a problem behind some
> > proxies, or with the header length (especially for json values). Also
> > headers are supposed to be in latin1 in a lot of clients...
> > - put the metadata in their own namespace which is what you propose.
> >
> > I dislike the last solution. Mostly because it would force the clients to
> > wait this namespace to read the metadata while parsing the JSON (which
> > could be when streaming it). Instead I would prefer to keep them at the
> > first level and due the reverse: put the data in their own namespace, say
> > `_data`. This allows any clients to ignore this layer if needed while
> > parsing the JSON and get it directly (without parsing then). The
> metadata
> > should be the first citizem imo. Optionally we could add some new
> > parameters to the doc api allowing someone to only fetch the metadata,
> > etc.. Also couchdb could also parse the coming doc and stop to parse the
> > json when seeing this property and store it directly. It is also
> following
> > the logic of attachments somehow. Another things that could be done at
> the
> > api level is having smth like `/db/docid/_data` which would allows you to
> > only retrieve the data instead of using a show function.
> >
> > What do you think?
> >
> > - benoit
>
> Hi all,
>
> I've been talking with Benoit about this at the CouchHack. I think his
> proposal makes a lot of sense. Let's take the separation of meta and the
> document body (as I proposed) together with what Benoit said.
>
> When storing the actual data in a top-level property called "_data", you
> could easily extract the meta information, without parsing the body at
> all. You just need to parse all the top level properties (which you need
> to do anyway as JSON doesn't have any distinct sorting).
>
> Having this could be a great first step towards making meta and document
> body separation easier to implement.
>
> In a next step you could then e.g. provide an API where you just send
> the document body, with the meta as headers.
>
> Cheers,
> Volker
>
>
I recently started a new project where having the metadata and the content
separated would make a lot of sense. Here is a quick summary in vrac of my
thinking about it.
- With our current concurrency model, it makes sense to have the metadata
coming with the document. Having them coming in a separate commit/doc would
create a lot of problems in a distributed environment (what happen when a
doc is edited on 2 places and the metadata updated apart). Our revision
model is here to solve such things.
- It would be interesting to let the user set its own metadata coming with
a document. We could imagine someone adding timestamps, the other adding
authentication infos, .. Some metadata could also be hidden to the user
that replicate or fetch the doc. Metadata should be really thought a
description of the doc and the way it will be shared/stored, nothing much.
Ie. mainly used for internal purposes and some could be local to a node. It
also answers to the original problem that raised this thread: we could
design some entry points in the api that only return the body of the doc
(without its metadata) so the clients would be happy with it. Or such thing.
- I like attachments. Transforming couchdb in another object database (aka
blob store) is not really that interesting neither innovative. At the end,
most of the users of the blob storages are also using a database to index
the objects. Where in an attachment model we are attaching a blob to its
structured description in the doc. Such description can then be indexed
using the views. I think i the future couchdb should consider attachments
as links attached to a doc. Such link could be internal like it is now but
also external. The remote link would be transparently handled for the one
that replicate, but at the end we could eventually attach a blob from an
external source. We could also link another doc.... (digression spotted)
- About metadata sent outside the JSON or as an header, I have a preference
for having them in the JSON sent to couchdb. Mainly because we could then
support any other protocol than HTTP without having to support different
ways to read the metadata coming with the document. Someone that want to
just use TCP to pass the doc could then just handle the transport logic and
give to couchdb the JSON which will be then indexed. Where in other cases
the transport will also need to manage how it get the metadata.
- If we have the metadata in a JSON, like VMX already told, it's quite
more efficient to have the metadata at the first level and make the content
available in a `_data` (or `_body`) property. We could then parse the JSON
to fetch all the metadata and omit the `_data` member which will be then
stored on disk. Doing the other way (Having metadata in a `_meta` property)
wouldn't be efficient at all due to the nature of a JSON: there is no
guaranty about the order of the properties. Also we will have generally a
content bigger than the metadata. (most docs will only have the `_id` and
`_rev`).
After looking at the code , I don't think we need a lot of changes to
support a system that use a JSON witch separate the metadata from the
content of the doc. If we are OK with that I could provide quickly a patch
which introduce that change. For the compatibility it could also parse the
full doc when no `_data` (or `_body`) member is found and make it
transparent for the end user by reading an api version that could come in
the headers.
Anyway this are just my 2 cents on that topic. I would be more than happy
to discuss this topic further so we could introduce such changes rapidly in
our API (even before any merge possibly).
- benoit
Re: [PROPOSAL] new underscore namespacing
Posted by Volker Mische <vo...@gmail.com>.
On 12/03/2013 07:12 PM, Benoit Chesneau wrote:
> On Tue, Dec 3, 2013 at 3:01 PM, Benjamin Young <by...@bigbluehat.com>wrote:
>
>> Hi all,
>>
>> Recently the "doc._*" reservation has been causing me trouble when pulling
>> in "arbitrary" JSON from various sources that also use the underscore
>> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
>> hit the wall several times when trying to import filesystem contents
>> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
>> folders."
>>
>> As such, I'd like to propose the following:
>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>> - this gives developers one object to look into for the meta-data about a
>> doc
>> - you can see the scope creep of our current doc._* best in the
>> replicator status messages.
>> - doc._ replication_* would become doc._.replication.*
>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>> attachments.
>> - _design/doc would stay the same
>> - but the child endpoints would live under "_design/doc/_/*"
>> - _design/doc/_/view/by_date
>> - _design/doc/_/list/by_date/ul
>> - _design/doc/_/rewrite
>>
>> I realize these are extreme API shifts, and would need to wait for CouchDB
>> 2.0.
>>
>> The first steps this direction would be to put new reserved word keys into
>> a "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
>> duplicates of the existing keys (doc._id, doc._rev, especially) could also
>> live at their new underscore prefixed names (doc._.id, doc._.rev) which
>> would give devs a chance to migrate code and content.
>>
>> Doing this would:
>> 1. Give us "limitless" space to add content.
>> 2. Encourage a namespacing pattern for things like doc._.replication.* or
>> other logically grouped content.
>> 3. Free up CouchDB to accept a far broader range of content and remove the
>> "hey, you can't put that there! I was here first!" errors. :)
>>
>> Thanks for considering this,
>> Benjamin
>>
>> [1] http://stateless.co/hal_specification.html
>> [2] https://github.com/blongden/vnd.error
>>
>
> I don't see why couchdb should adapt itself to newer things that didn't
> take care of an older API when doing their stuff but that's probably
> another concern ;)
>
> I would find a "/_/" in the URL rather ugly and not needed in that case.
> Same for having a _ in a doc. also it doesn't have much sense. Why do you
> want to change the HTTP api at that level?
>
> Another way to do it and probably more restish woudl be moving all couchdb
> resources in their own namespace. Say `couchdb/` for example. so anything
> in the resource couchdb will be related to couchdb.
>
> Next is the the prefix "_" in the doc. It's actually reserved because
> sometimes, once day we will add other metadata which is fine. But raises
> the issue you have.
>
> If I summarise the discussion here amd precedent discussions there are
> different school there:
>
> - remove the metadata from the doc and put them in headers or aside. I
> quite like the first solution, though it may be a problem behind some
> proxies, or with the header length (especially for json values). Also
> headers are supposed to be in latin1 in a lot of clients...
> - put the metadata in their own namespace which is what you propose.
>
> I dislike the last solution. Mostly because it would force the clients to
> wait this namespace to read the metadata while parsing the JSON (which
> could be when streaming it). Instead I would prefer to keep them at the
> first level and due the reverse: put the data in their own namespace, say
> `_data`. This allows any clients to ignore this layer if needed while
> parsing the JSON and get it directly (without parsing then). The metadata
> should be the first citizem imo. Optionally we could add some new
> parameters to the doc api allowing someone to only fetch the metadata,
> etc.. Also couchdb could also parse the coming doc and stop to parse the
> json when seeing this property and store it directly. It is also following
> the logic of attachments somehow. Another things that could be done at the
> api level is having smth like `/db/docid/_data` which would allows you to
> only retrieve the data instead of using a show function.
>
> What do you think?
>
> - benoit
Hi all,
I've been talking with Benoit about this at the CouchHack. I think his
proposal makes a lot of sense. Let's take the separation of meta and the
document body (as I proposed) together with what Benoit said.
When storing the actual data in a top-level property called "_data", you
could easily extract the meta information, without parsing the body at
all. You just need to parse all the top level properties (which you need
to do anyway as JSON doesn't have any distinct sorting).
Having this could be a great first step towards making meta and document
body separation easier to implement.
In a next step you could then e.g. provide an API where you just send
the document body, with the meta as headers.
Cheers,
Volker
Re: [PROPOSAL] new underscore namespacing
Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Dec 3, 2013 at 3:01 PM, Benjamin Young <by...@bigbluehat.com>wrote:
> Hi all,
>
> Recently the "doc._*" reservation has been causing me trouble when pulling
> in "arbitrary" JSON from various sources that also use the underscore
> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
> hit the wall several times when trying to import filesystem contents
> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
> folders."
>
> As such, I'd like to propose the following:
> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> - this gives developers one object to look into for the meta-data about a
> doc
> - you can see the scope creep of our current doc._* best in the
> replicator status messages.
> - doc._ replication_* would become doc._.replication.*
> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> attachments.
> - _design/doc would stay the same
> - but the child endpoints would live under "_design/doc/_/*"
> - _design/doc/_/view/by_date
> - _design/doc/_/list/by_date/ul
> - _design/doc/_/rewrite
>
> I realize these are extreme API shifts, and would need to wait for CouchDB
> 2.0.
>
> The first steps this direction would be to put new reserved word keys into
> a "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
> duplicates of the existing keys (doc._id, doc._rev, especially) could also
> live at their new underscore prefixed names (doc._.id, doc._.rev) which
> would give devs a chance to migrate code and content.
>
> Doing this would:
> 1. Give us "limitless" space to add content.
> 2. Encourage a namespacing pattern for things like doc._.replication.* or
> other logically grouped content.
> 3. Free up CouchDB to accept a far broader range of content and remove the
> "hey, you can't put that there! I was here first!" errors. :)
>
> Thanks for considering this,
> Benjamin
>
> [1] http://stateless.co/hal_specification.html
> [2] https://github.com/blongden/vnd.error
>
I don't see why couchdb should adapt itself to newer things that didn't
take care of an older API when doing their stuff but that's probably
another concern ;)
I would find a "/_/" in the URL rather ugly and not needed in that case.
Same for having a _ in a doc. also it doesn't have much sense. Why do you
want to change the HTTP api at that level?
Another way to do it and probably more restish woudl be moving all couchdb
resources in their own namespace. Say `couchdb/` for example. so anything
in the resource couchdb will be related to couchdb.
Next is the the prefix "_" in the doc. It's actually reserved because
sometimes, once day we will add other metadata which is fine. But raises
the issue you have.
If I summarise the discussion here amd precedent discussions there are
different school there:
- remove the metadata from the doc and put them in headers or aside. I
quite like the first solution, though it may be a problem behind some
proxies, or with the header length (especially for json values). Also
headers are supposed to be in latin1 in a lot of clients...
- put the metadata in their own namespace which is what you propose.
I dislike the last solution. Mostly because it would force the clients to
wait this namespace to read the metadata while parsing the JSON (which
could be when streaming it). Instead I would prefer to keep them at the
first level and due the reverse: put the data in their own namespace, say
`_data`. This allows any clients to ignore this layer if needed while
parsing the JSON and get it directly (without parsing then). The metadata
should be the first citizem imo. Optionally we could add some new
parameters to the doc api allowing someone to only fetch the metadata,
etc.. Also couchdb could also parse the coming doc and stop to parse the
json when seeing this property and store it directly. It is also following
the logic of attachments somehow. Another things that could be done at the
api level is having smth like `/db/docid/_data` which would allows you to
only retrieve the data instead of using a show function.
What do you think?
- benoit
Re: [PROPOSAL] new underscore namespacing
Posted by Nathan Vander Wilt <na...@calftrail.com>.
On Dec 3, 2013, at 11:23 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Dec 3, 2013 at 8:20 PM, Alexander Shorin <kx...@gmail.com> wrote:
>
>> Sorry, miss the smile, but in every joke there is only a piece of joke (;
>> Anyway there will be collisions since it's old issue about split
>> predefined and custom resources in RESTful apps and prefix is quite
>> common way to solve it with less blood.
>> --
>> ,,,^..^,,,
>>
>>
> but what about prefixing all data in _data? Except if we want to store
> unstructured data in the doc it would work imo.
Relevant to the OP, simply putting document contents with arbitrary fields underneath one level e.g. "_id,_rev,data: {…}" should be safe in current versions of CouchDB, the old wiki at least seemed to be clear that only in "any top-level fields" are underscore-prefixed fields reserved: http://wiki.apache.org/couchdb/HTTP_Document_API#Special_Fields
So if one wants to store truly arbitrary JSON and/or more cleanly separate meta from data they could [at least according to the wiki] already do so without caveat today in 1.x. I've filed https://issues.apache.org/jira/browse/COUCHDB-1952 requesting clarification (preferably simply a reiteration) of this in the official documentation.
hth,
-nvw
Re: [PROPOSAL] new underscore namespacing
Posted by Volker Mische <vo...@gmail.com>.
On 12/03/2013 08:35 PM, Alexander Shorin wrote:
> On Tue, Dec 3, 2013 at 11:23 PM, Benoit Chesneau <bc...@gmail.com> wrote:
>> On Tue, Dec 3, 2013 at 8:20 PM, Alexander Shorin <kx...@gmail.com> wrote:
>>
>>> Sorry, miss the smile, but in every joke there is only a piece of joke (;
>>> Anyway there will be collisions since it's old issue about split
>>> predefined and custom resources in RESTful apps and prefix is quite
>>> common way to solve it with less blood.
>>> --
>>> ,,,^..^,,,
>>>
>>>
>> but what about prefixing all data in _data? Except if we want to store
>> unstructured data in the doc it would work imo.
>
> Except of naming (I feel _meta will be more verbose, friendly and
> self-explained) imho this is good idea. There I would like to ask
> Volker about how meta works in Couchbase: afaik there they have it as
> stand alone object, but still associated with related doc (or vice
> versa).
I think the easiest it to look at the commit that made the split between
the document and the meta information [1].
In case you want/need more information, feel free to ask.
[1]
https://github.com/couchbase/couchdb/commit/b935f38e2ee77b559cd4c13684140d3213c87ab9
Cheers,
Volker
Re: [PROPOSAL] new underscore namespacing
Posted by Alexander Shorin <kx...@gmail.com>.
On Tue, Dec 3, 2013 at 11:23 PM, Benoit Chesneau <bc...@gmail.com> wrote:
> On Tue, Dec 3, 2013 at 8:20 PM, Alexander Shorin <kx...@gmail.com> wrote:
>
>> Sorry, miss the smile, but in every joke there is only a piece of joke (;
>> Anyway there will be collisions since it's old issue about split
>> predefined and custom resources in RESTful apps and prefix is quite
>> common way to solve it with less blood.
>> --
>> ,,,^..^,,,
>>
>>
> but what about prefixing all data in _data? Except if we want to store
> unstructured data in the doc it would work imo.
Except of naming (I feel _meta will be more verbose, friendly and
self-explained) imho this is good idea. There I would like to ask
Volker about how meta works in Couchbase: afaik there they have it as
stand alone object, but still associated with related doc (or vice
versa).
--
,,,^..^,,,
Re: [PROPOSAL] new underscore namespacing
Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Dec 3, 2013 at 8:20 PM, Alexander Shorin <kx...@gmail.com> wrote:
> Sorry, miss the smile, but in every joke there is only a piece of joke (;
> Anyway there will be collisions since it's old issue about split
> predefined and custom resources in RESTful apps and prefix is quite
> common way to solve it with less blood.
> --
> ,,,^..^,,,
>
>
but what about prefixing all data in _data? Except if we want to store
unstructured data in the doc it would work imo.
- benoit
Re: [PROPOSAL] new underscore namespacing
Posted by Alexander Shorin <kx...@gmail.com>.
Sorry, miss the smile, but in every joke there is only a piece of joke (;
Anyway there will be collisions since it's old issue about split
predefined and custom resources in RESTful apps and prefix is quite
common way to solve it with less blood.
--
,,,^..^,,,
On Tue, Dec 3, 2013 at 10:40 PM, Robert Newson <rn...@apache.org> wrote:
> 'there could be used optimistic conflict model when couchdb will
> disallow atts with names that are already reserved by handlers'
>
> You should flag jokes for the avoidance of doubt.
>
> B.
>
>
> On 3 December 2013 18:37, Alexander Shorin <kx...@gmail.com> wrote:
>> Instead of /_/ there could be used optimistic conflict model when couchdb
>> will disallow atts with names that are already reserved by handlers. IT
>> would be like document conflict resolution, but more tricky.
>>
>> P.S. Sorry fir typos in both mails, wrote them from phone with frozen
>> fingers (-10 outside there)
>> On Dec 3, 2013 10:20 PM, "Benjamin Young" <by...@bigbluehat.com> wrote:
>>
>>>
>>> On 12/3/13, 1:11 PM, Alexander Shorin wrote:
>>>
>>>> +1 for meta. It's cool idea and every doc has some meta info like type
>>>> field
>>>>
>>>> -1 on /_/ url thing. It's ugly and not related to reserved namespace: you
>>>> may define any named handler in config file and having _ prefix saves you
>>>> from collision with atts (but it's still optiona)
>>>>
>>>
>>> So collision with attachments is exactly the situation this was proposed
>>> out of.
>>>
>>> Sphinx (for one...among many...), uses "_*" prefixed folders for it's
>>> styles, templates, etc. So does Github's ghpages.
>>>
>>> As such, you have to change how those things work in order to store their
>>> files in CouchDB.
>>>
>>> What I'm after is the ability to dump "whatever" into CouchDB and have it
>>> work. :) Without having to care about what the database chose to reserve.
>>>
>>> The point with "/_/" was to narrow the surface area of the API.
>>>
>>> The proposal's uncovered lots of other issues and ideas. Which is great! ;)
>>>
>>> On Dec 3, 2013 7:37 PM, "Volker Mische" <vo...@gmail.com> wrote:
>>>>
>>>> On 12/03/2013 03:01 PM, Benjamin Young wrote:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> Recently the "doc._*" reservation has been causing me trouble when
>>>>>> pulling in "arbitrary" JSON from various sources that also use the
>>>>>> underscore prefixed names for things (HAL [1], vnd.error [2], other
>>>>>> APIs). I've also hit the wall several times when trying to import
>>>>>> filesystem contents (Sphinx, ghpages, and the like) that use _*
>>>>>> prefixing for their "special folders."
>>>>>>
>>>>>> As such, I'd like to propose the following:
>>>>>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>>>>>> - this gives developers one object to look into for the meta-data
>>>>>> about
>>>>>> a doc
>>>>>> - you can see the scope creep of our current doc._* best in the
>>>>>> replicator status messages.
>>>>>> - doc._ replication_* would become doc._.replication.*
>>>>>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>>>>>> attachments.
>>>>>> - _design/doc would stay the same
>>>>>> - but the child endpoints would live under "_design/doc/_/*"
>>>>>> - _design/doc/_/view/by_date
>>>>>> - _design/doc/_/list/by_date/ul
>>>>>> - _design/doc/_/rewrite
>>>>>>
>>>>>> I realize these are extreme API shifts, and would need to wait for
>>>>>> CouchDB 2.0.
>>>>>>
>>>>>> The first steps this direction would be to put new reserved word keys
>>>>>> into a "doc._.*" namespace going forward. Closer to the "cut over" for
>>>>>> 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
>>>>>> could also live at their new underscore prefixed names (doc._.id,
>>>>>> doc._.rev) which would give devs a chance to migrate code and content.
>>>>>>
>>>>>> Doing this would:
>>>>>> 1. Give us "limitless" space to add content.
>>>>>> 2. Encourage a namespacing pattern for things like doc._.replication.*
>>>>>> or other logically grouped content.
>>>>>> 3. Free up CouchDB to accept a far broader range of content and remove
>>>>>> the "hey, you can't put that there! I was here first!" errors. :)
>>>>>>
>>>>>> Thanks for considering this,
>>>>>> Benjamin
>>>>>>
>>>>>> [1] http://stateless.co/hal_specification.html
>>>>>> [2] https://github.com/blongden/vnd.error
>>>>>>
>>>>> Hi,
>>>>>
>>>>> I personally would prefer to have the meta information completely
>>>>> separate from the document. I know there have been discussion in the
>>>>> past to even have them separate in the backend (but that's not the point
>>>>> of this proposal).
>>>>>
>>>>> So the API for the view function could change to `function(doc, meta)`.
>>>>> This way you could store in your document whatever you like.
>>>>>
>>>>> Cheers,
>>>>> Volker
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
Re: [PROPOSAL] new underscore namespacing
Posted by Robert Newson <rn...@apache.org>.
'there could be used optimistic conflict model when couchdb will
disallow atts with names that are already reserved by handlers'
You should flag jokes for the avoidance of doubt.
B.
On 3 December 2013 18:37, Alexander Shorin <kx...@gmail.com> wrote:
> Instead of /_/ there could be used optimistic conflict model when couchdb
> will disallow atts with names that are already reserved by handlers. IT
> would be like document conflict resolution, but more tricky.
>
> P.S. Sorry fir typos in both mails, wrote them from phone with frozen
> fingers (-10 outside there)
> On Dec 3, 2013 10:20 PM, "Benjamin Young" <by...@bigbluehat.com> wrote:
>
>>
>> On 12/3/13, 1:11 PM, Alexander Shorin wrote:
>>
>>> +1 for meta. It's cool idea and every doc has some meta info like type
>>> field
>>>
>>> -1 on /_/ url thing. It's ugly and not related to reserved namespace: you
>>> may define any named handler in config file and having _ prefix saves you
>>> from collision with atts (but it's still optiona)
>>>
>>
>> So collision with attachments is exactly the situation this was proposed
>> out of.
>>
>> Sphinx (for one...among many...), uses "_*" prefixed folders for it's
>> styles, templates, etc. So does Github's ghpages.
>>
>> As such, you have to change how those things work in order to store their
>> files in CouchDB.
>>
>> What I'm after is the ability to dump "whatever" into CouchDB and have it
>> work. :) Without having to care about what the database chose to reserve.
>>
>> The point with "/_/" was to narrow the surface area of the API.
>>
>> The proposal's uncovered lots of other issues and ideas. Which is great! ;)
>>
>> On Dec 3, 2013 7:37 PM, "Volker Mische" <vo...@gmail.com> wrote:
>>>
>>> On 12/03/2013 03:01 PM, Benjamin Young wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> Recently the "doc._*" reservation has been causing me trouble when
>>>>> pulling in "arbitrary" JSON from various sources that also use the
>>>>> underscore prefixed names for things (HAL [1], vnd.error [2], other
>>>>> APIs). I've also hit the wall several times when trying to import
>>>>> filesystem contents (Sphinx, ghpages, and the like) that use _*
>>>>> prefixing for their "special folders."
>>>>>
>>>>> As such, I'd like to propose the following:
>>>>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>>>>> - this gives developers one object to look into for the meta-data
>>>>> about
>>>>> a doc
>>>>> - you can see the scope creep of our current doc._* best in the
>>>>> replicator status messages.
>>>>> - doc._ replication_* would become doc._.replication.*
>>>>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>>>>> attachments.
>>>>> - _design/doc would stay the same
>>>>> - but the child endpoints would live under "_design/doc/_/*"
>>>>> - _design/doc/_/view/by_date
>>>>> - _design/doc/_/list/by_date/ul
>>>>> - _design/doc/_/rewrite
>>>>>
>>>>> I realize these are extreme API shifts, and would need to wait for
>>>>> CouchDB 2.0.
>>>>>
>>>>> The first steps this direction would be to put new reserved word keys
>>>>> into a "doc._.*" namespace going forward. Closer to the "cut over" for
>>>>> 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
>>>>> could also live at their new underscore prefixed names (doc._.id,
>>>>> doc._.rev) which would give devs a chance to migrate code and content.
>>>>>
>>>>> Doing this would:
>>>>> 1. Give us "limitless" space to add content.
>>>>> 2. Encourage a namespacing pattern for things like doc._.replication.*
>>>>> or other logically grouped content.
>>>>> 3. Free up CouchDB to accept a far broader range of content and remove
>>>>> the "hey, you can't put that there! I was here first!" errors. :)
>>>>>
>>>>> Thanks for considering this,
>>>>> Benjamin
>>>>>
>>>>> [1] http://stateless.co/hal_specification.html
>>>>> [2] https://github.com/blongden/vnd.error
>>>>>
>>>> Hi,
>>>>
>>>> I personally would prefer to have the meta information completely
>>>> separate from the document. I know there have been discussion in the
>>>> past to even have them separate in the backend (but that's not the point
>>>> of this proposal).
>>>>
>>>> So the API for the view function could change to `function(doc, meta)`.
>>>> This way you could store in your document whatever you like.
>>>>
>>>> Cheers,
>>>> Volker
>>>>
>>>>
>>>>
>>>>
>>>>
>>
Re: [PROPOSAL] new underscore namespacing
Posted by Alexander Shorin <kx...@gmail.com>.
Instead of /_/ there could be used optimistic conflict model when couchdb
will disallow atts with names that are already reserved by handlers. IT
would be like document conflict resolution, but more tricky.
P.S. Sorry fir typos in both mails, wrote them from phone with frozen
fingers (-10 outside there)
On Dec 3, 2013 10:20 PM, "Benjamin Young" <by...@bigbluehat.com> wrote:
>
> On 12/3/13, 1:11 PM, Alexander Shorin wrote:
>
>> +1 for meta. It's cool idea and every doc has some meta info like type
>> field
>>
>> -1 on /_/ url thing. It's ugly and not related to reserved namespace: you
>> may define any named handler in config file and having _ prefix saves you
>> from collision with atts (but it's still optiona)
>>
>
> So collision with attachments is exactly the situation this was proposed
> out of.
>
> Sphinx (for one...among many...), uses "_*" prefixed folders for it's
> styles, templates, etc. So does Github's ghpages.
>
> As such, you have to change how those things work in order to store their
> files in CouchDB.
>
> What I'm after is the ability to dump "whatever" into CouchDB and have it
> work. :) Without having to care about what the database chose to reserve.
>
> The point with "/_/" was to narrow the surface area of the API.
>
> The proposal's uncovered lots of other issues and ideas. Which is great! ;)
>
> On Dec 3, 2013 7:37 PM, "Volker Mische" <vo...@gmail.com> wrote:
>>
>> On 12/03/2013 03:01 PM, Benjamin Young wrote:
>>>
>>>> Hi all,
>>>>
>>>> Recently the "doc._*" reservation has been causing me trouble when
>>>> pulling in "arbitrary" JSON from various sources that also use the
>>>> underscore prefixed names for things (HAL [1], vnd.error [2], other
>>>> APIs). I've also hit the wall several times when trying to import
>>>> filesystem contents (Sphinx, ghpages, and the like) that use _*
>>>> prefixing for their "special folders."
>>>>
>>>> As such, I'd like to propose the following:
>>>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>>>> - this gives developers one object to look into for the meta-data
>>>> about
>>>> a doc
>>>> - you can see the scope creep of our current doc._* best in the
>>>> replicator status messages.
>>>> - doc._ replication_* would become doc._.replication.*
>>>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>>>> attachments.
>>>> - _design/doc would stay the same
>>>> - but the child endpoints would live under "_design/doc/_/*"
>>>> - _design/doc/_/view/by_date
>>>> - _design/doc/_/list/by_date/ul
>>>> - _design/doc/_/rewrite
>>>>
>>>> I realize these are extreme API shifts, and would need to wait for
>>>> CouchDB 2.0.
>>>>
>>>> The first steps this direction would be to put new reserved word keys
>>>> into a "doc._.*" namespace going forward. Closer to the "cut over" for
>>>> 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
>>>> could also live at their new underscore prefixed names (doc._.id,
>>>> doc._.rev) which would give devs a chance to migrate code and content.
>>>>
>>>> Doing this would:
>>>> 1. Give us "limitless" space to add content.
>>>> 2. Encourage a namespacing pattern for things like doc._.replication.*
>>>> or other logically grouped content.
>>>> 3. Free up CouchDB to accept a far broader range of content and remove
>>>> the "hey, you can't put that there! I was here first!" errors. :)
>>>>
>>>> Thanks for considering this,
>>>> Benjamin
>>>>
>>>> [1] http://stateless.co/hal_specification.html
>>>> [2] https://github.com/blongden/vnd.error
>>>>
>>> Hi,
>>>
>>> I personally would prefer to have the meta information completely
>>> separate from the document. I know there have been discussion in the
>>> past to even have them separate in the backend (but that's not the point
>>> of this proposal).
>>>
>>> So the API for the view function could change to `function(doc, meta)`.
>>> This way you could store in your document whatever you like.
>>>
>>> Cheers,
>>> Volker
>>>
>>>
>>>
>>>
>>>
>
Re: [PROPOSAL] new underscore namespacing
Posted by Filippo Fadda <fi...@programmazione.it>.
In the ElephantOnCouch every subclass of the superclass Doc is persistent. Inside the class Doc, there is an array called "meta" to store the document's metadata. Actually _id, _rev, etc. are also metadata, but I like the idea to separate the document properties (_id, _rev, _deleted, etc.) from the metadata stored by the application.
I agree with the ones have suggested to add "_meta" property containing all the metadata, so we can avoid conflicts in case an application stores metadata prefixed with an underscore, like for example _type or _class. ElephantOnCouch for example uses those metadata (without the _ prefix actually) to store the document type and its complete class name, used to recreate an instance of the stored object magically.
If a _meta property is introduced, is it possible, eventually to create an automatic procedure to migrate from 1.x to 2.0?
-Filippo
Re: [PROPOSAL] new underscore namespacing
Posted by "Eli Stevens (Gmail)" <wi...@gmail.com>.
On Tue, Dec 3, 2013 at 10:20 AM, Benjamin Young <by...@bigbluehat.com> wrote:
> Sphinx (for one...among many...), uses "_*" prefixed folders for it's
> styles, templates, etc. So does Github's ghpages.
...
> The point with "/_/" was to narrow the surface area of the API.
I'd like to point out that if the goal is to reduce API surface area
to reduce collisions, using "_couchdb" for metadata is much less
likely to collide than "_". It's also much more user friendly once
the data is outside of CouchDB proper ("where is this doc._.id coming
from?" etc.).
Cheers,
Eli
Re: [PROPOSAL] new underscore namespacing
Posted by Benjamin Young <by...@bigbluehat.com>.
On 12/3/13, 1:11 PM, Alexander Shorin wrote:
> +1 for meta. It's cool idea and every doc has some meta info like type field
>
> -1 on /_/ url thing. It's ugly and not related to reserved namespace: you
> may define any named handler in config file and having _ prefix saves you
> from collision with atts (but it's still optiona)
So collision with attachments is exactly the situation this was proposed
out of.
Sphinx (for one...among many...), uses "_*" prefixed folders for it's
styles, templates, etc. So does Github's ghpages.
As such, you have to change how those things work in order to store
their files in CouchDB.
What I'm after is the ability to dump "whatever" into CouchDB and have
it work. :) Without having to care about what the database chose to reserve.
The point with "/_/" was to narrow the surface area of the API.
The proposal's uncovered lots of other issues and ideas. Which is great! ;)
> On Dec 3, 2013 7:37 PM, "Volker Mische" <vo...@gmail.com> wrote:
>
>> On 12/03/2013 03:01 PM, Benjamin Young wrote:
>>> Hi all,
>>>
>>> Recently the "doc._*" reservation has been causing me trouble when
>>> pulling in "arbitrary" JSON from various sources that also use the
>>> underscore prefixed names for things (HAL [1], vnd.error [2], other
>>> APIs). I've also hit the wall several times when trying to import
>>> filesystem contents (Sphinx, ghpages, and the like) that use _*
>>> prefixing for their "special folders."
>>>
>>> As such, I'd like to propose the following:
>>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>>> - this gives developers one object to look into for the meta-data about
>>> a doc
>>> - you can see the scope creep of our current doc._* best in the
>>> replicator status messages.
>>> - doc._ replication_* would become doc._.replication.*
>>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>>> attachments.
>>> - _design/doc would stay the same
>>> - but the child endpoints would live under "_design/doc/_/*"
>>> - _design/doc/_/view/by_date
>>> - _design/doc/_/list/by_date/ul
>>> - _design/doc/_/rewrite
>>>
>>> I realize these are extreme API shifts, and would need to wait for
>>> CouchDB 2.0.
>>>
>>> The first steps this direction would be to put new reserved word keys
>>> into a "doc._.*" namespace going forward. Closer to the "cut over" for
>>> 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
>>> could also live at their new underscore prefixed names (doc._.id,
>>> doc._.rev) which would give devs a chance to migrate code and content.
>>>
>>> Doing this would:
>>> 1. Give us "limitless" space to add content.
>>> 2. Encourage a namespacing pattern for things like doc._.replication.*
>>> or other logically grouped content.
>>> 3. Free up CouchDB to accept a far broader range of content and remove
>>> the "hey, you can't put that there! I was here first!" errors. :)
>>>
>>> Thanks for considering this,
>>> Benjamin
>>>
>>> [1] http://stateless.co/hal_specification.html
>>> [2] https://github.com/blongden/vnd.error
>> Hi,
>>
>> I personally would prefer to have the meta information completely
>> separate from the document. I know there have been discussion in the
>> past to even have them separate in the backend (but that's not the point
>> of this proposal).
>>
>> So the API for the view function could change to `function(doc, meta)`.
>> This way you could store in your document whatever you like.
>>
>> Cheers,
>> Volker
>>
>>
>>
>>
Re: [PROPOSAL] new underscore namespacing
Posted by Alexander Shorin <kx...@gmail.com>.
+1 for meta. It's cool idea and every doc has some meta info like type field
-1 on /_/ url thing. It's ugly and not related to reserved namespace: you
may define any named handler in config file and having _ prefix saves you
from collision with atts (but it's still optiona)
On Dec 3, 2013 7:37 PM, "Volker Mische" <vo...@gmail.com> wrote:
> On 12/03/2013 03:01 PM, Benjamin Young wrote:
> > Hi all,
> >
> > Recently the "doc._*" reservation has been causing me trouble when
> > pulling in "arbitrary" JSON from various sources that also use the
> > underscore prefixed names for things (HAL [1], vnd.error [2], other
> > APIs). I've also hit the wall several times when trying to import
> > filesystem contents (Sphinx, ghpages, and the like) that use _*
> > prefixing for their "special folders."
> >
> > As such, I'd like to propose the following:
> > 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> > - this gives developers one object to look into for the meta-data about
> > a doc
> > - you can see the scope creep of our current doc._* best in the
> > replicator status messages.
> > - doc._ replication_* would become doc._.replication.*
> > 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> > attachments.
> > - _design/doc would stay the same
> > - but the child endpoints would live under "_design/doc/_/*"
> > - _design/doc/_/view/by_date
> > - _design/doc/_/list/by_date/ul
> > - _design/doc/_/rewrite
> >
> > I realize these are extreme API shifts, and would need to wait for
> > CouchDB 2.0.
> >
> > The first steps this direction would be to put new reserved word keys
> > into a "doc._.*" namespace going forward. Closer to the "cut over" for
> > 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
> > could also live at their new underscore prefixed names (doc._.id,
> > doc._.rev) which would give devs a chance to migrate code and content.
> >
> > Doing this would:
> > 1. Give us "limitless" space to add content.
> > 2. Encourage a namespacing pattern for things like doc._.replication.*
> > or other logically grouped content.
> > 3. Free up CouchDB to accept a far broader range of content and remove
> > the "hey, you can't put that there! I was here first!" errors. :)
> >
> > Thanks for considering this,
> > Benjamin
> >
> > [1] http://stateless.co/hal_specification.html
> > [2] https://github.com/blongden/vnd.error
>
> Hi,
>
> I personally would prefer to have the meta information completely
> separate from the document. I know there have been discussion in the
> past to even have them separate in the backend (but that's not the point
> of this proposal).
>
> So the API for the view function could change to `function(doc, meta)`.
> This way you could store in your document whatever you like.
>
> Cheers,
> Volker
>
>
>
>
Re: [PROPOSAL] new underscore namespacing
Posted by Russell Branca <ch...@apache.org>.
I'm +1 to the idea of ripping out the metadata fields from the doc bodies
entirely and adding them to the headers. I think this makes a much cleaner
separation of concerns. However, one thing that jumps out at me as a
potential gotcha, is grabbing a large list of conflicts, or some other
piece of metadata that can be much larger than allowable lengths in
headers. We'll need to come up with an approach there, although perhaps
it's a good opportunity to rethink how we bubble up conflicts to users, and
find some way to make it more obvious when there is a conflict.
-Russell
On Tue, Dec 3, 2013 at 9:25 AM, Brian Mitchell <br...@strmpnk.co> wrote:
> On Tue, Dec 3, 2013 at 10:35 AM, Volker Mische <vo...@gmail.com>
> wrote:
> > I personally would prefer to have the meta information completely
> > separate from the document. I know there have been discussion in the
> > past to even have them separate in the backend (but that's not the point
> > of this proposal).
> >
> > So the API for the view function could change to `function(doc, meta)`.
> > This way you could store in your document whatever you like.
>
> This is convenient in some cases but I really do like how CouchDB
> documents are self-contained and self-representing. Having to rely on
> an outside context to know things like identity and revision seems
> unfortunate.
>
> Most cases I've interacted with CouchDB would require at least that
> minimal _id and _rev. Separating them might seem okay if you just look
> at a map function with two arguments but it gets messier if you look
> at client code in the applications that use CouchDB. Many do things
> like:
>
> my_doc = db.get('doc')
> ...
> db.put(my_doc)
>
> Juggling this context separately will require extra work or at least
> force CouchDB clients to reinvent some way to wrap up and store
> metadata. My experience writing client code against Riak, which
> externalizes this metadata, was not nearly as clean as working with
> CouchDB since everything needed some sort of wrapper where CouchDB
> could many times get away with just a simple value.
>
> On the side of internals, there is certainly some work to be done to
> lift things in and out of this special field, but it could be done w/o
> forcing clients to live with their world split in two.
>
> Brian.
>
Re: [PROPOSAL] new underscore namespacing
Posted by Brian Mitchell <br...@strmpnk.co>.
On Tue, Dec 3, 2013 at 10:35 AM, Volker Mische <vo...@gmail.com> wrote:
> I personally would prefer to have the meta information completely
> separate from the document. I know there have been discussion in the
> past to even have them separate in the backend (but that's not the point
> of this proposal).
>
> So the API for the view function could change to `function(doc, meta)`.
> This way you could store in your document whatever you like.
This is convenient in some cases but I really do like how CouchDB
documents are self-contained and self-representing. Having to rely on
an outside context to know things like identity and revision seems
unfortunate.
Most cases I've interacted with CouchDB would require at least that
minimal _id and _rev. Separating them might seem okay if you just look
at a map function with two arguments but it gets messier if you look
at client code in the applications that use CouchDB. Many do things
like:
my_doc = db.get('doc')
...
db.put(my_doc)
Juggling this context separately will require extra work or at least
force CouchDB clients to reinvent some way to wrap up and store
metadata. My experience writing client code against Riak, which
externalizes this metadata, was not nearly as clean as working with
CouchDB since everything needed some sort of wrapper where CouchDB
could many times get away with just a simple value.
On the side of internals, there is certainly some work to be done to
lift things in and out of this special field, but it could be done w/o
forcing clients to live with their world split in two.
Brian.
Re: [PROPOSAL] new underscore namespacing
Posted by Volker Mische <vo...@gmail.com>.
On 12/03/2013 03:01 PM, Benjamin Young wrote:
> Hi all,
>
> Recently the "doc._*" reservation has been causing me trouble when
> pulling in "arbitrary" JSON from various sources that also use the
> underscore prefixed names for things (HAL [1], vnd.error [2], other
> APIs). I've also hit the wall several times when trying to import
> filesystem contents (Sphinx, ghpages, and the like) that use _*
> prefixing for their "special folders."
>
> As such, I'd like to propose the following:
> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> - this gives developers one object to look into for the meta-data about
> a doc
> - you can see the scope creep of our current doc._* best in the
> replicator status messages.
> - doc._ replication_* would become doc._.replication.*
> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> attachments.
> - _design/doc would stay the same
> - but the child endpoints would live under "_design/doc/_/*"
> - _design/doc/_/view/by_date
> - _design/doc/_/list/by_date/ul
> - _design/doc/_/rewrite
>
> I realize these are extreme API shifts, and would need to wait for
> CouchDB 2.0.
>
> The first steps this direction would be to put new reserved word keys
> into a "doc._.*" namespace going forward. Closer to the "cut over" for
> 2.0 duplicates of the existing keys (doc._id, doc._rev, especially)
> could also live at their new underscore prefixed names (doc._.id,
> doc._.rev) which would give devs a chance to migrate code and content.
>
> Doing this would:
> 1. Give us "limitless" space to add content.
> 2. Encourage a namespacing pattern for things like doc._.replication.*
> or other logically grouped content.
> 3. Free up CouchDB to accept a far broader range of content and remove
> the "hey, you can't put that there! I was here first!" errors. :)
>
> Thanks for considering this,
> Benjamin
>
> [1] http://stateless.co/hal_specification.html
> [2] https://github.com/blongden/vnd.error
Hi,
I personally would prefer to have the meta information completely
separate from the document. I know there have been discussion in the
past to even have them separate in the backend (but that's not the point
of this proposal).
So the API for the view function could change to `function(doc, meta)`.
This way you could store in your document whatever you like.
Cheers,
Volker
Re: [PROPOSAL] new underscore namespacing
Posted by Filippo Fadda <fi...@programmazione.it>.
I like this idea.
-Filippo
On Dec 3, 2013, at 3:16 PM, Robert Newson wrote:
> I like the idea, though I remember a suggestion to lift all of these
> things out of the bodies entirely (I'm thinking mostly of _id and
> _rev) and into request/response headers. This has other advantages (we
> wouldn't need to convert doc bodies to a mutable intermediate state to
> inject id and rev, we could send it more directly).
>
> As for "I realize these are extreme API shifts, and would need to wait
> for CouchDB 2.0.", this has it precisely backwards. There's no waiting
> for 2.0. If we change the API in incompatible ways, we bump the major
> version. To say it another way, making this change *creates* couchdb
> 2.0.
>
> As for migration, I think it would only be necessary for 2.0 to
> understand the old format. E.g, the replicator would look for
> doc._.replication_state first and fallback to doc._replication_state
> if it's missing. We could go further and add forward looking code in a
> minor release that does the reverse of that.
>
> Of course now I'm visually how the chttpd/couch_httpd url mapping code
> will look for the /_/ idea... :D
>
> B.
>
>
> On 3 December 2013 14:01, Benjamin Young <by...@bigbluehat.com> wrote:
>> Hi all,
>>
>> Recently the "doc._*" reservation has been causing me trouble when pulling
>> in "arbitrary" JSON from various sources that also use the underscore
>> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
>> hit the wall several times when trying to import filesystem contents
>> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
>> folders."
>>
>> As such, I'd like to propose the following:
>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>> - this gives developers one object to look into for the meta-data about a
>> doc
>> - you can see the scope creep of our current doc._* best in the replicator
>> status messages.
>> - doc._ replication_* would become doc._.replication.*
>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>> attachments.
>> - _design/doc would stay the same
>> - but the child endpoints would live under "_design/doc/_/*"
>> - _design/doc/_/view/by_date
>> - _design/doc/_/list/by_date/ul
>> - _design/doc/_/rewrite
>>
>> I realize these are extreme API shifts, and would need to wait for CouchDB
>> 2.0.
>>
>> The first steps this direction would be to put new reserved word keys into a
>> "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
>> duplicates of the existing keys (doc._id, doc._rev, especially) could also
>> live at their new underscore prefixed names (doc._.id, doc._.rev) which
>> would give devs a chance to migrate code and content.
>>
>> Doing this would:
>> 1. Give us "limitless" space to add content.
>> 2. Encourage a namespacing pattern for things like doc._.replication.* or
>> other logically grouped content.
>> 3. Free up CouchDB to accept a far broader range of content and remove the
>> "hey, you can't put that there! I was here first!" errors. :)
>>
>> Thanks for considering this,
>> Benjamin
>>
>> [1] http://stateless.co/hal_specification.html
>> [2] https://github.com/blongden/vnd.error
Re: [PROPOSAL] new underscore namespacing
Posted by Benjamin Young <by...@bigbluehat.com>.
Replies inline...
On 12/3/13, 9:16 AM, Robert Newson wrote:
> I like the idea, though I remember a suggestion to lift all of these
> things out of the bodies entirely (I'm thinking mostly of _id and
> _rev) and into request/response headers. This has other advantages (we
> wouldn't need to convert doc bodies to a mutable intermediate state to
> inject id and rev, we could send it more directly).
The end objective is to get CouchDB (and friends) to be more receptive.
The ideal would be to get all the meta-data out of the body/content
area, so we can avoid "opening the envelope" to do the routing.
This "doc._.*" proposal is mostly a hybrid, but I'd be more than happy
to see it only applied to "internal" docs like _users, _replicator, etc.
Docs we act on or produce ourselves, and then move content documents
into a doc + meta/headers combo (like you and now Volker just described).
> As for "I realize these are extreme API shifts, and would need to wait
> for CouchDB 2.0.", this has it precisely backwards. There's no waiting
> for 2.0. If we change the API in incompatible ways, we bump the major
> version. To say it another way, making this change *creates* couchdb
> 2.0.
Fabulously rephrased. Thank you! :)
> As for migration, I think it would only be necessary for 2.0 to
> understand the old format. E.g, the replicator would look for
> doc._.replication_state first and fallback to doc._replication_state
> if it's missing. We could go further and add forward looking code in a
> minor release that does the reverse of that.
Agreed.
>
> Of course now I'm visually how the chttpd/couch_httpd url mapping code
> will look for the /_/ idea... :D
Let the fun begin. ;)
Perhaps a good first step would be an exploratory plugin that handles
these proposed "/_/" routes for design document endpoints. Maybe?
>
> B.
>
>
> On 3 December 2013 14:01, Benjamin Young <by...@bigbluehat.com> wrote:
>> Hi all,
>>
>> Recently the "doc._*" reservation has been causing me trouble when pulling
>> in "arbitrary" JSON from various sources that also use the underscore
>> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
>> hit the wall several times when trying to import filesystem contents
>> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
>> folders."
>>
>> As such, I'd like to propose the following:
>> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
>> - this gives developers one object to look into for the meta-data about a
>> doc
>> - you can see the scope creep of our current doc._* best in the replicator
>> status messages.
>> - doc._ replication_* would become doc._.replication.*
>> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
>> attachments.
>> - _design/doc would stay the same
>> - but the child endpoints would live under "_design/doc/_/*"
>> - _design/doc/_/view/by_date
>> - _design/doc/_/list/by_date/ul
>> - _design/doc/_/rewrite
>>
>> I realize these are extreme API shifts, and would need to wait for CouchDB
>> 2.0.
>>
>> The first steps this direction would be to put new reserved word keys into a
>> "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
>> duplicates of the existing keys (doc._id, doc._rev, especially) could also
>> live at their new underscore prefixed names (doc._.id, doc._.rev) which
>> would give devs a chance to migrate code and content.
>>
>> Doing this would:
>> 1. Give us "limitless" space to add content.
>> 2. Encourage a namespacing pattern for things like doc._.replication.* or
>> other logically grouped content.
>> 3. Free up CouchDB to accept a far broader range of content and remove the
>> "hey, you can't put that there! I was here first!" errors. :)
>>
>> Thanks for considering this,
>> Benjamin
>>
>> [1] http://stateless.co/hal_specification.html
>> [2] https://github.com/blongden/vnd.error
Re: [PROPOSAL] new underscore namespacing
Posted by Robert Newson <rn...@apache.org>.
I like the idea, though I remember a suggestion to lift all of these
things out of the bodies entirely (I'm thinking mostly of _id and
_rev) and into request/response headers. This has other advantages (we
wouldn't need to convert doc bodies to a mutable intermediate state to
inject id and rev, we could send it more directly).
As for "I realize these are extreme API shifts, and would need to wait
for CouchDB 2.0.", this has it precisely backwards. There's no waiting
for 2.0. If we change the API in incompatible ways, we bump the major
version. To say it another way, making this change *creates* couchdb
2.0.
As for migration, I think it would only be necessary for 2.0 to
understand the old format. E.g, the replicator would look for
doc._.replication_state first and fallback to doc._replication_state
if it's missing. We could go further and add forward looking code in a
minor release that does the reverse of that.
Of course now I'm visually how the chttpd/couch_httpd url mapping code
will look for the /_/ idea... :D
B.
On 3 December 2013 14:01, Benjamin Young <by...@bigbluehat.com> wrote:
> Hi all,
>
> Recently the "doc._*" reservation has been causing me trouble when pulling
> in "arbitrary" JSON from various sources that also use the underscore
> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
> hit the wall several times when trying to import filesystem contents
> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
> folders."
>
> As such, I'd like to propose the following:
> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> - this gives developers one object to look into for the meta-data about a
> doc
> - you can see the scope creep of our current doc._* best in the replicator
> status messages.
> - doc._ replication_* would become doc._.replication.*
> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> attachments.
> - _design/doc would stay the same
> - but the child endpoints would live under "_design/doc/_/*"
> - _design/doc/_/view/by_date
> - _design/doc/_/list/by_date/ul
> - _design/doc/_/rewrite
>
> I realize these are extreme API shifts, and would need to wait for CouchDB
> 2.0.
>
> The first steps this direction would be to put new reserved word keys into a
> "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
> duplicates of the existing keys (doc._id, doc._rev, especially) could also
> live at their new underscore prefixed names (doc._.id, doc._.rev) which
> would give devs a chance to migrate code and content.
>
> Doing this would:
> 1. Give us "limitless" space to add content.
> 2. Encourage a namespacing pattern for things like doc._.replication.* or
> other logically grouped content.
> 3. Free up CouchDB to accept a far broader range of content and remove the
> "hey, you can't put that there! I was here first!" errors. :)
>
> Thanks for considering this,
> Benjamin
>
> [1] http://stateless.co/hal_specification.html
> [2] https://github.com/blongden/vnd.error
Re: [PROPOSAL] new underscore namespacing
Posted by Noah Slater <ns...@apache.org>.
Ah. We disagree on this one. Removing couch.jquery.js seems minor
enough that we'd hold off. But changing the way document meta data
works is a prime candidate for bumping our major point version.
Semver is meant to encourage and enable these sorts of changes, and we
should take full advantage of it.
If we agree on a change here, and it is ready to ship, we should ship
it. End of story. :) And yep, that will mean bumping to 2.0, and
that's fine. And we'll keep the 1.0 line around for 12 months and
backport things to it. (I believe that's the policy.)
On 4 December 2013 13:34, Alexander Shorin <kx...@gmail.com> wrote:
> On Wed, Dec 4, 2013 at 4:00 PM, Noah Slater <ns...@apache.org> wrote:
>> On 3 December 2013 15:01, Benjamin Young <by...@bigbluehat.com> wrote:
>>> I realize these are extreme API shifts, and would need to wait for CouchDB
>>> 2.0.
>>
>> No need to wait for anything. We could land this as soon as it is
>> ready, and then the next release becomes 2.0. That's the flexibility
>> our new release process gives us.
>
> I think Benjamin is about "to not produce too much releases with
> broken backward compatibility" - that will be hard to support and only
> confuse users regardless how flexible is our release process (:
>
> --
> ,,,^..^,,,
--
Noah Slater
https://twitter.com/nslater
Re: [PROPOSAL] new underscore namespacing
Posted by Alexander Shorin <kx...@gmail.com>.
On Wed, Dec 4, 2013 at 4:00 PM, Noah Slater <ns...@apache.org> wrote:
> On 3 December 2013 15:01, Benjamin Young <by...@bigbluehat.com> wrote:
>> I realize these are extreme API shifts, and would need to wait for CouchDB
>> 2.0.
>
> No need to wait for anything. We could land this as soon as it is
> ready, and then the next release becomes 2.0. That's the flexibility
> our new release process gives us.
I think Benjamin is about "to not produce too much releases with
broken backward compatibility" - that will be hard to support and only
confuse users regardless how flexible is our release process (:
--
,,,^..^,,,
Re: [PROPOSAL] new underscore namespacing
Posted by Noah Slater <ns...@apache.org>.
(Sorry for repeating Bob's point. That'll teach me to read the whole
thread before replying...)
On 4 December 2013 13:00, Noah Slater <ns...@apache.org> wrote:
> On 3 December 2013 15:01, Benjamin Young <by...@bigbluehat.com> wrote:
>> I realize these are extreme API shifts, and would need to wait for CouchDB
>> 2.0.
>
> No need to wait for anything. We could land this as soon as it is
> ready, and then the next release becomes 2.0. That's the flexibility
> our new release process gives us.
>
>
> --
> Noah Slater
> https://twitter.com/nslater
--
Noah Slater
https://twitter.com/nslater
Re: [PROPOSAL] new underscore namespacing
Posted by Noah Slater <ns...@apache.org>.
On 3 December 2013 15:01, Benjamin Young <by...@bigbluehat.com> wrote:
> I realize these are extreme API shifts, and would need to wait for CouchDB
> 2.0.
No need to wait for anything. We could land this as soon as it is
ready, and then the next release becomes 2.0. That's the flexibility
our new release process gives us.
--
Noah Slater
https://twitter.com/nslater
Re: [PROPOSAL] new underscore namespacing
Posted by Brian Mitchell <br...@strmpnk.co>.
On Tue, Dec 3, 2013 at 9:01 AM, Benjamin Young <by...@bigbluehat.com> wrote:
> Hi all,
>
> Recently the "doc._*" reservation has been causing me trouble when pulling
> in "arbitrary" JSON from various sources that also use the underscore
> prefixed names for things (HAL [1], vnd.error [2], other APIs). I've also
> hit the wall several times when trying to import filesystem contents
> (Sphinx, ghpages, and the like) that use _* prefixing for their "special
> folders."
I've usually stored such data inside nested objects. Our top-level
namespace is getting muddy which not only affects our use of other
formats but other systems that would want to integrate CouchDB data in
them as well. I can imagine the sort of metadata that needs to be
stored will only grow with plugins.
> As such, I'd like to propose the following:
> 1. Begin storing new reserved terms in doc._.* (rather than doc._*).
> - this gives developers one object to look into for the meta-data about a
> doc
> - you can see the scope creep of our current doc._* best in the replicator
> status messages.
> - doc._ replication_* would become doc._.replication.*
Very nice. It makes a clear separation between system-controlled and
user-controlled name spaces. Avoiding the topic of whether or not
metadata should be embedded or not, this seems like an improvement.
> 2. Move "magic" API endpoints under "/_/" term as well (for the sake of
> attachments.
> - _design/doc would stay the same
> - but the child endpoints would live under "_design/doc/_/*"
> - _design/doc/_/view/by_date
> - _design/doc/_/list/by_date/ul
> - _design/doc/_/rewrite
We do have many other places where we use special names like _changes,
_all_dbs, _uuids &c. While this does mirror the document's special _
namespace, it makes it less consistent with everything else we put in
the URL. I'm not sure what else we are really buying here outside of
attachments with odd names.
> I realize these are extreme API shifts, and would need to wait for CouchDB
> 2.0.
All the more reason to find a way to get plugins working well so there
can be a playground for ideas before such a serious version jump is
made. Some of these are trickier since we don't really expose proper
APIs for manipulating some of these but it's probably worth looking at
still.
> The first steps this direction would be to put new reserved word keys into a
> "doc._.*" namespace going forward. Closer to the "cut over" for 2.0
> duplicates of the existing keys (doc._id, doc._rev, especially) could also
> live at their new underscore prefixed names (doc._.id, doc._.rev) which
> would give devs a chance to migrate code and content.
I wonder if the API could be versioned using HTTP headers. The CouchDB
host could set a default version and clients could request specific
versions. I've played with versioned vendor media types but those get
complicated and confuse far too many HTTP agents. A simple header like
Couch-API-Version: 2 might be a place to start.
> Thanks for considering this,
> Benjamin
Thank you for sharing.