Hi Karl,
regarding your question to update a specific part of a document you
might want to read
http://wiki.apache.org/couchdb/Document_Update_Handlers
g jo
Am Montag, den 24.10.2011, 14:28 +0800 schrieb Karl Seguin:
> Hi,
> I'm just starting to learn CouchDB and I've accumulated four questions.
>
> First, I only found some vague references, but are views only updated on
> read request? (assuming there's something to update). There's no built-in
> mechanism to have views updated in the background say for every X
> changed/new documents or X seconds?
>
> Secondly, it seems like if you want to update a document, you need to send
> the complete document over. I understand that, given CouchDB's versioning,
> this makes sense. In theory, would it be possible for CouchDB to expose an
> API to allow updates to specific fields, then on the backend, it would clone
> the document and overwrite the field. Again, I know that isn't possible
> with the current API, I'm just wondering if there's anything that would stop
> that from working. You'd essentially send over the doc_id, rev, the field
> name and the new value.
>
> Third, any bulk update or delete needs to be done in code by loop through
> the result of a view? Say, I want to delete all the posts older than 1 year.
> I create view keyed by the post date, I query the view with my specific
> filter, and then I loop through it deleting each document? It's pretty much
> the same story for updates, but I can use the bulk update api. There's no
> direct analog to delete from posts where date < ?, it's more of a select id
> from posts where date < ? then delete those ids. Right?
>
> Forth, and I'm sorry for asking this, I realize it's asked a lot, but I
> couldnt' figure it out despite that...I'm trying to retrieve all of the
> posts with a specific tag, sorted by date. My view looks like:
>
> function(doc) {
> if (doc.doc_type != 'post') { return; }
> for(var tag in doc.tags) {
> emit([doc.dated, doc.tags[tag]], null);
> }
> }
>
> I was hoping that a query like this might work:
>
> for row in db.view('application/post_by_tags', key='[{}, "blah"]'):
> print row
>
> But it doesn't.
>
> Thanks for the help,
> Karl