incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: drill into a doc with a GET?
Date Thu, 08 Jan 2009 02:24:57 GMT
Robert,

The function you're describing doesn't exist, but the end result does.
This would be done using a view to get only parts of a document that
are interesting to the calling code. Its not automatic by any means,
but you could write a view that would give you something similar:

function(doc)
{
    for(var field in doc)
   {
       emit([field, doc._id], doc[field]);
   }
}

Then to access a specific property:

http://127.0.0.1:5984/db_name/_view/view_name/by_property?key=["foo", "docid1"]

HTH,
Paul Davis

On Wed, Jan 7, 2009 at 4:18 PM, Robert Koberg <rob@koberg.com> wrote:
> Hi,
>
> first, couchdb is just beautiful! :) (using 0.8.1-incubating from MacPorts)
>
> I am very new, and have read the available docs and several blog posts.
>
> Can you drill into a doc with a simple GET?
>
> Say I have a doc like:
>
> {"_id": "a", "_rev": "123", "foo":{"bar": 1}, "big-ass-prop": "huge amount
> of stuff"}
>
> Ideally I would like to be able to call something like:
>
> http://127.0.0.1:5984/mydb/a/foo
>
> to return {"bar":1} and avoid downloading "big-ass-prop"
>
> Is this or something like it possible?
>
> (I realize "foo" is a 'sibling' of the _id in the document, but it is
> probably treated more like a parent in the DB?)
>
> If not possible, is it possible to create some kind of default
> action/filter/? that does something like the above? That is, reads the
> request uri, recognizes it is a document and that there is extra path info
> which should be used to resolve a property.
>
> thanks,
> -Rob
>

Mime
View raw message