How can you rotate banner ads using CouchApp & CouchDB?

In context: this is an HTML application with little or no JavaScript interface. I cannot easily change this, so you need to do this on the server.

CouchDB is designed to have no side effects. This is true. But there seems to be no method that I can present using views, views, lists to change what is shown to the user with subsequent queries or based on user objects, without writing data.

And can I get a request for a document as a result of creating a new record? I guess this is not a side effect.

But if you can, you can simply create a magazine, and then have a presentation that displays the ad firm a set of documents describing advertisements that are affected by a change in the magazine when the previous ad was shown.

I’m not going to show ads on my site, I’ll get tips, summary of articles and secondary functions that range from page loading to page loading.

Any suggestions appreciated.

I wrapped my head around how to work with the grain for the rest of the functionality I need, but this bit seems contrary to how couchdb works.

+4
source share
2 answers

I think you will need a list function that gets a set of documents from a view and then selects only one to return, randomly or in some other way. However, since you are in the list function, you get access to the details of the user's request, including cookies (which you can also set, by the way.) This is similar to what you want.

In addition, you can specify different views for the list function that will be used during the request. This means that you can, say, show only random articles on the main page, but any type of content is displayed on everyone else.

Note. You cannot access the request in the map / reduce function, and you will run into problems if you execute something like Math.random () inside the map function.

So the list function is the way to go.

http://guide.couchdb.org/draft/transforming.html

+1
source

Look at the various methods for selecting a random document from a view. This should allow you to select a random document (presumably representing an ad, tooltip, etc.) to display.

0
source

All Articles