CouchDB Views: created_at greater than passed value

I am trying to write a couchdb view that takes the created_at timestamp in sorted format (2009/05/07 21:40:17 +0000) and returns all documents with a large created_at value.

I specifically use couch_foo, but if I can figure out how to write a presentation, I can create it in futon or in the couch_foo model instead of letting couch_foo do it for me.

I searched all around and cannot determine the map / reduce to do this, if possible.

+3
source share
3 answers

This is the problem I ran into before I fully understood how views work.

, () . , , , . , - , , .

? , , couchdb .

"map" : "function(doc) { emit(doc.created_at, doc); }"

:

http://localhost:5984/db/_design/ddoc/_view/view?startkey=%222009/05/07%2021:40:17 +0000%22

uriEncoding URL-, .

+4

, , startkey.

, :

"map" : "function(doc) { emit(doc.timestamp_field, doc) }"

URL- :

http://mysever/database/_design/mydoc/_view/myview?startkey="2009/05/07 21:40:17 +0000"

HTTP view API Wiki . .

+3

Note that couchdb only works on json values. If the time zone, if the document stored in couchdb, is different from the time zone of your start key, the request will most likely fail.

+1
source

Source: https://habr.com/ru/post/1707919/


All Articles