Skip to content

Views not removing the old data #4752

Answered by rnewson
k0rmo0 asked this question in Q&A
Sep 8, 2023 · 2 comments · 2 replies
Discussion options

You must be logged in to vote
function(doc) {
    var docDay = new Date(doc.timestamp * 1000).setHours(0, 0, 0, 0);
    emit(docDay);
}

is all you need, you can then get the count of documents for any given day with ?reduce=true&key=1694127600000 for example.

You first build an index of your document contents and then query the range you want.

In your original formulation CouchDB would need to reindex every document every time you queried, and we didn't design it that way for hopefully obvious reasons. :)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@k0rmo0
Comment options

Comment options

You must be logged in to vote
1 reply
@k0rmo0
Comment options

Answer selected by k0rmo0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants