如何解决:使用 MongoDB Atlas 时出现“MongoError: $where is not allowed in this atlas tier”的问题?
这是我的代码:
async function getEventsTakingPlace(){
const getEventsTakingPlace = await event.find({$where: function() {
return ((this.eventTime < new Date()) && (new Date(this.eventTime).getTime()+ 100*60000 > new Date().getTime() ) ) }},
function(err, events){
if(err){
return err;
}else {
return events;
}
});
return getEventsTakingPlace
};
Run Code Online (Sandbox Code Playgroud)
当我使用本地 mongoDB 实例时,它可以工作,但是一旦我开始使用 mongoAtlas,我就会收到错误消息:此地图集层中不允许使用 $where。我该如何解决这个问题?