I am having problems trying to filter blog posts by date.
To give a simple example:
async function getStories ( ) {
let results = await wixData . query ( “Blog/Posts” )
. include ( “categories” )
. limit ( 100 )
. descending ( “publishedDate” )
. find ();
let items = results . items ;
while ( results . hasNext ()) {
results = await results . next ();
items = items . concat ( results . items );
}
console . log ( items . length );
}
the above code logs 658 (the number of posts in my blog)
but if I add a date filter:
async function getStories ( ) {
var Today = new Date ();
let results = await wixData . query ( “Blog/Posts” )
. include ( “categories” )
. limit ( 100 )
. descending ( “publishedDate” )
.l t ( “publishedDate” , Today )
. find ();
let items = results . items ;
**while** ( results . hasNext ()) {
results = **await** results . next ();
items = items . concat ( results . items );
}
console . log ( items . length );
}
it returns 0. If I replace the .lt with .gt it still returns 0.
Is there a solution to this problem?
Thank you.