// Watch the schema for changes
const changeStream = betSchema.watch();
changeStream.on('change', async (change) => {
console.log("Change is ", change);
console.log("Changes occurred")
if (change.operationType === 'insert') {
const updated = await betSchema.findOne({ _id: change.documentKey._id });
// console.log("Updated is ", updated)
const data = await getBetsForTimeCategorized();
getBetForParticularBetIdUsingStreams.emit("bet-found", {
status: true,
message: "Bet Updated",
"data": data,
});
}
});
this one is working when i am using free cluster of mongo but when i am using the mongo from serverless instance its not working
i was trying to watch on the schema but not working when i am using serverless