couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Genoud <st...@spotme.com>
Subject Re: Update function introl
Date Mon, 15 Dec 2014 07:38:41 GMT
Hei Sam,

Your use case would probably be better with a view (
http://docs.couchdb.org/en/latest/couchapp/views/intro.html).
You should add every tweet as an individual document and create a map
function such that which emits the hashtag as key. You can then easily
retrieve all tweets by hashtag. Moreover, every update of the db will take
the same time, you will be able to paginate the tweets of a popular hash
tag when you retrieve them and be safe from conflicts (if you start some
replications).
Note that this is a typical example of when you use CouchDB you need to
changes the way you are thinking about your db. The core of your attention
should be on how to query your data (i.e. how to create your views) more
than on how you structure your data.

Update functions are a completely different beast, they are here for
authorisation reasons (i.e. if you want to let users edit some documents).

Welcome in the couch community.

Best,
Steve

On Sun, Dec 14, 2014 at 2:22 AM, Sam Raker <sam.raker@gmail.com> wrote:
>
> I've got an application that pulls tweets from twitter and organizes them
> by hashtag, so
>
> {"_id": "#whatever", "tweets": [{tweet 1}, {tweet 2},...]}.
>
> I'm noticing a performance hit with popular hashtags--my app pulls down the
> whole document, appends the tweet to the array, and then puts the updated
> doc back in the db.
>
> I *think* this would be a good job for update functions, but I've had a
> devil of a time learning much about them. I might just be a little dense,
> but after reading through
> https://wiki.apache.org/couchdb/Document_Update_Handlers and
> http://docs.couchdb.org/en/latest/couchapp/ddocs.html#update-functions a
> few times each, I'm still a bit lost. Can anyone recommend some good
> resource for learning about update functions?
>
>
> Thanks,
> -sam

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message