Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it ever ok to use Date() in a CouchDB view to filter results based on the current date? I'm thinking it will only update the view if the record is changed?

If that's the case, is there a way of telling a view to reindex every 24 hours?

I realise I could pull all the data out in the view, and then use code to filter, but I'm wondering if there's a way of doing it all in the view.

question from:https://stackoverflow.com/questions/65942168/using-date-in-views

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

Is it ever ok to use Date() in a CouchDB view to filter results based on the current date?

The Date() will be computed only during view rebuild so you can not use it to get a query result based on the query time.

I'm thinking it will only update the view if the record is changed?

The view is updated incrementally when docs are changed and it is completely rebuilt when its definition changes.

If that's the case, is there a way of telling a view to reindex every 24 hours?

No

I realise I could pull all the data out in the view, and then use code to filter, but I'm wondering if there's a way of doing it all in the view.

As an alternative you may use filter functions to filter the change feed. These filters are evaluated at query time so you may achieve your purpose with this functionality. Also, selectors may help on this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...