You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "Kropp, Henning" <hk...@microlution.de> on 2010/05/18 11:36:20 UTC

Executing script after insert (Trigger)

Hi,

I read about the possibility to "trigger" index updates after an amount
of inserts. I would like to execute a script after every insert to
update some logic, for example to update the count of blog posts in the
db (I believe this example would not make much sense, but still ..)

Is it generally possible to execute a script/view after every an insert
in couchdb, besides using validation which I suppose could be used as a
workaround?

And/Or is it possible to find out which are new entries after the last
execution of a view, so one could execute a scheduled script which only
executes on the new entries? Sticking to the example of counting blog
posts and suppose I would have hundreds of categories and would only
like to update the count of the new categories not having to go through
the rest.

I am new to couchdb, its concept and erlangen.
Kind regards

Re: Executing script after insert (Trigger)

Posted by Sebastian Cohnen <se...@googlemail.com>.
the best way to "trigger" such stuff, is to write a tiny application, that listens to the _changes-stream (see http://wiki.apache.org/couchdb/HTTP_database_API#Changes)

On 18.05.2010, at 11:36, Kropp, Henning wrote:

> Hi,
> 
> I read about the possibility to "trigger" index updates after an amount
> of inserts. I would like to execute a script after every insert to
> update some logic, for example to update the count of blog posts in the
> db (I believe this example would not make much sense, but still ..)
> 
> Is it generally possible to execute a script/view after every an insert
> in couchdb, besides using validation which I suppose could be used as a
> workaround?
> 
> And/Or is it possible to find out which are new entries after the last
> execution of a view, so one could execute a scheduled script which only
> executes on the new entries? Sticking to the example of counting blog
> posts and suppose I would have hundreds of categories and would only
> like to update the count of the new categories not having to go through
> the rest.
> 
> I am new to couchdb, its concept and erlangen.
> Kind regards


Re: Executing script after insert (Trigger)

Posted by Markus Jelsma <ma...@buyways.nl>.
I was a bit too quick, there actually is some information on it [1], but it 
doesn't show up in search results when looking for update notifications.

[1]: http://wiki.apache.org/couchdb/ExternalProcesses


On Tuesday 18 May 2010 11:45:45 Markus Jelsma wrote:
> Hi,
> 
> 
> There is little info on the wiki about update notifications but that's what
> you'll need. There is an example on the wiki which does some thing on
>  update [1] and there's a blog post [2] on the topic.
> 
> 
> [1]: http://wiki.apache.org/couchdb/Regenerating_views_on_update
> 
> [2]: http://blog.fupps.com/2010/05/10/update-notifications-in-couchdb-
> tweeting-urgent-documents/
> 
> 
> Cheers,
> 
> On Tuesday 18 May 2010 11:36:20 Kropp, Henning wrote:
> > Hi,
> >
> > I read about the possibility to "trigger" index updates after an amount
> > of inserts. I would like to execute a script after every insert to
> > update some logic, for example to update the count of blog posts in the
> > db (I believe this example would not make much sense, but still ..)
> >
> > Is it generally possible to execute a script/view after every an insert
> > in couchdb, besides using validation which I suppose could be used as a
> > workaround?
> >
> > And/Or is it possible to find out which are new entries after the last
> > execution of a view, so one could execute a scheduled script which only
> > executes on the new entries? Sticking to the example of counting blog
> > posts and suppose I would have hundreds of categories and would only
> > like to update the count of the new categories not having to go through
> > the rest.
> >
> > I am new to couchdb, its concept and erlangen.
> > Kind regards
> 
> Markus Jelsma - Technisch Architect - Buyways BV
> http://www.linkedin.com/in/markus17
> 050-8536620 / 06-50258350
> 

Markus Jelsma - Technisch Architect - Buyways BV
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350


Re: Executing script after insert (Trigger)

Posted by "Kropp, Henning" <hk...@microlution.de>.
Thank you both. I will look into it.

Am 18.05.2010 11:45, schrieb Markus Jelsma:
> Hi,
>
>
> There is little info on the wiki about update notifications but that's what 
> you'll need. There is an example on the wiki which does some thing on update 
> [1] and there's a blog post [2] on the topic. 
>
>
> [1]: http://wiki.apache.org/couchdb/Regenerating_views_on_update
>
> [2]: http://blog.fupps.com/2010/05/10/update-notifications-in-couchdb-
> tweeting-urgent-documents/
>
>
> Cheers,
>
> On Tuesday 18 May 2010 11:36:20 Kropp, Henning wrote:
>   
>> Hi,
>>
>> I read about the possibility to "trigger" index updates after an amount
>> of inserts. I would like to execute a script after every insert to
>> update some logic, for example to update the count of blog posts in the
>> db (I believe this example would not make much sense, but still ..)
>>
>> Is it generally possible to execute a script/view after every an insert
>> in couchdb, besides using validation which I suppose could be used as a
>> workaround?
>>
>> And/Or is it possible to find out which are new entries after the last
>> execution of a view, so one could execute a scheduled script which only
>> executes on the new entries? Sticking to the example of counting blog
>> posts and suppose I would have hundreds of categories and would only
>> like to update the count of the new categories not having to go through
>> the rest.
>>
>> I am new to couchdb, its concept and erlangen.
>> Kind regards
>>
>>     
> Markus Jelsma - Technisch Architect - Buyways BV
> http://www.linkedin.com/in/markus17
> 050-8536620 / 06-50258350
>
>   


Re: Executing script after insert (Trigger)

Posted by Markus Jelsma <ma...@buyways.nl>.
Hi,


There is little info on the wiki about update notifications but that's what 
you'll need. There is an example on the wiki which does some thing on update 
[1] and there's a blog post [2] on the topic. 


[1]: http://wiki.apache.org/couchdb/Regenerating_views_on_update

[2]: http://blog.fupps.com/2010/05/10/update-notifications-in-couchdb-
tweeting-urgent-documents/


Cheers,

On Tuesday 18 May 2010 11:36:20 Kropp, Henning wrote:
> Hi,
> 
> I read about the possibility to "trigger" index updates after an amount
> of inserts. I would like to execute a script after every insert to
> update some logic, for example to update the count of blog posts in the
> db (I believe this example would not make much sense, but still ..)
> 
> Is it generally possible to execute a script/view after every an insert
> in couchdb, besides using validation which I suppose could be used as a
> workaround?
> 
> And/Or is it possible to find out which are new entries after the last
> execution of a view, so one could execute a scheduled script which only
> executes on the new entries? Sticking to the example of counting blog
> posts and suppose I would have hundreds of categories and would only
> like to update the count of the new categories not having to go through
> the rest.
> 
> I am new to couchdb, its concept and erlangen.
> Kind regards
> 

Markus Jelsma - Technisch Architect - Buyways BV
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350