You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Filippo Fadda <fi...@programmazione.it> on 2016/10/02 12:29:30 UTC

Re: CouchDB Next

Well, that's not what I meant. What I want is a query parameter to get only the specified document’s fields on a simple GET /{db}/{docid}. CouchDB should parse the JSON and returns only the required fields, because in a real scenario there are times you don’t need the entire document, but just some fields. Lazy Loading is a well known pattern and it’s really effective.

> On 30 Sep 2016, at 20:23, Nick Vatamaniuc <va...@gmail.com> wrote:
> 
> Hi Filippo,
> 
>> Lazy Loading
>> ——————
>> I don’t know if CouchDB 2.0 comes with such a feature, but I would like to have a mechanism to get just some document’s fields. Sometime I just need the title or whatever, but I have to get the entire document. I would like to request just a set of fields when I retrieve a document from the database.
> 
> There is  pr to do something like this with _change feeds and mango
> selectors. It adds an additional fields parameters to return only some
> fields from the doc. So if the doc is 10MB and you just want to return
> 1 field:
> 
> https://github.com/apache/couchdb-couch/pull/177
> 
> Cheers,
> -Nick


Re: CouchDB Next

Posted by Olafur Arason <ol...@olafura.com>.
Hi it's been awhile since I did anything with CouchDB, though I've done a
lot of projects in the past, here are the open source ones:
https://github.com/olafura/sundaytasks-py
https://github.com/olafura/sundaydata
https://github.com/olafura/PouchFlux

I'm mostly doing Elixir development now but I got started with Erlang
because of CouchDB. But I have to say that Elixir is much nicer. After I
started using Elixir I even had some ideas about translating the the http
interface into Elixir and did a project that could do that:
https://github.com/olafura/beam_to_ex_ast
https://github.com/olafura/beam_to_ex

So I'm really excited if you do end up using Elixir since it will help with
tests, ease of getting into the project and make it hopefully less painful
to refactor some parts and have docs for functions. But I don't know how
much time I can spend since my last project that relied on CouchDB had a
lot of issues with syncing to the browser with PouchDB and people's
unfamiliarity with map reduce instead of SQL. Plus the delayed schedule of
2.0. Now I'm working with Absinthe for a Relay backend and it seems to
function well. I'm doing financial calculations with some interesting ways
of processing it hopefully open sourced in the near future, the processing
part.

About the diffing I wouldn't go with json diff spec it's way too verbose. I
have a library that does json diffing in Elixir and uses a very good format
from a JavaScript library I had used before:
https://github.com/olafura/json_diff_ex

I hope the next time I can do a project in CouchDB it will be a Elixir Plug
maybe with Relay syncing, or maybe websocket or both ;)

Regards,
Olaf

On Tue, Oct 4, 2016, 10:07 Jan Lehnardt <ja...@apache.org> wrote:

> No worries Filippo, hence my “;)” *wink* — My mail was long, and I don’t
> expect everyone to catch every nuance :)
>
> I just wanted to make sure you see that what you’d like to see is already
> on the drawing board.
>
> Best
> Jan
> --
>
> > On 04 Oct 2016, at 16:03, Filippo Fadda <fi...@programmazione.it>
> wrote:
> >
> > My bad Jan, I didn’t read this paragraph "GET/DELETE accordingly”, so I
> have thought it was just for updates.
> >
> > -Filippo
>
> --
> Professional Support for Apache CouchDB:
> https://neighbourhood.ie/couchdb-support/
>
>

Re: CouchDB Next

Posted by Jan Lehnardt <ja...@apache.org>.
No worries Filippo, hence my “;)” *wink* — My mail was long, and I don’t expect everyone to catch every nuance :)

I just wanted to make sure you see that what you’d like to see is already on the drawing board.

Best
Jan
--

> On 04 Oct 2016, at 16:03, Filippo Fadda <fi...@programmazione.it> wrote:
> 
> My bad Jan, I didn’t read this paragraph "GET/DELETE accordingly”, so I have thought it was just for updates.
> 
> -Filippo

-- 
Professional Support for Apache CouchDB:
https://neighbourhood.ie/couchdb-support/


Re: CouchDB Next

Posted by Filippo Fadda <fi...@programmazione.it>.
My bad Jan, I didn’t read this paragraph "GET/DELETE accordingly”, so I have thought it was just for updates.

-Filippo

Re: CouchDB Next

Posted by Jan Lehnardt <ja...@apache.org>.
> On 02 Oct 2016, at 14:29, Filippo Fadda <fi...@programmazione.it> wrote:
> 
> Well, that's not what I meant. What I want is a query parameter to get only the specified document’s fields on a simple GET /{db}/{docid}. CouchDB should parse the JSON and returns only the required fields, because in a real scenario there are times you don’t need the entire document, but just some fields. Lazy Loading is a well known pattern and it’s really effective.

Re-post from my original email ;)

## Sub-Document Operations

Currently a doc update needs the whole doc body sent to the server. There are some obvious performance improvements possible. For the longest time, I wanted to see if we can model sub-document operations via JSON Pointers[2]. These would roughly allow pointing to a JSON value via a URL.

For example in this doc:

{
 "_id": "123abc",
 "_rev": "zyx987",
 "contact": {
   "name": "",
   "address": {
     "street": "Long Street",
     "nr": 123
     "zip": "12345"
   }
}

An update to the zip code could look like this:

curl -X POST $SERVER/db/123abc/_jsonpointer/contact/address/zip?rev=zyx987 -d '54321'

GET/DELETE accordingly. We could shortcut the `_jsonpointer` to just `_` if we like the short magic.

JSONPointer can deal with nested objects and lists and works fairly well for this type of stuff, and it is rather simple to implement (even I could do it: https://github.com/janl/erl-jsonpointer/blob/master/src/jsonpointer.erl — This idea is literally 5 years old, it looks like, no need to use my code if there is anything better).

This is just a raw idea, and I’m happy to solve this any other way, if somebody has a good approach.

[2] https://tools.ietf.org/html/rfc6901

Best
Jan
--

>> On 30 Sep 2016, at 20:23, Nick Vatamaniuc <va...@gmail.com> wrote:
>> 
>> Hi Filippo,
>> 
>>> Lazy Loading
>>> ——————
>>> I don’t know if CouchDB 2.0 comes with such a feature, but I would like to have a mechanism to get just some document’s fields. Sometime I just need the title or whatever, but I have to get the entire document. I would like to request just a set of fields when I retrieve a document from the database.
>> 
>> There is  pr to do something like this with _change feeds and mango
>> selectors. It adds an additional fields parameters to return only some
>> fields from the doc. So if the doc is 10MB and you just want to return
>> 1 field:
>> 
>> https://github.com/apache/couchdb-couch/pull/177
>> 
>> Cheers,
>> -Nick
> 

-- 
Professional Support for Apache CouchDB:
https://neighbourhood.ie/couchdb-support/