I’m using node js to query to the collection which is generated materialized view by aggregation.
Interestingly, the query only works when server starts up.
So, If I query with next code
// inside of event listener callback.
async () => {
const result = await dbCli.db('form').collection('materializedView').find().toArray()
console.log({ result })
return result
}
Only first time query has result.
Next query dose not have the correct result but empty array.
Other query to normal collection works just fine. I can keep querying with correct result that case.
Also if I query from api call from outside of server works fine.
It only behave like so when I use the code in callback. I’m properly await the find call.