【发布时间】:2017-07-07 22:15:11
【问题描述】:
所以,我有一个函数应该在 if 条件为真的情况下执行。我根本不知道如何在方法中实现它。我有以下代码:
Meteor.methods({
'popItems': function () {
var date = new Date().getTime();
if ( "check if this.userId && any item in the array 'itemIds' is $gt date" ) {
userManagement.update({
'_id': this.userId
}, {
$pop: {'itemIds': -1}
}
}
);
};
}
});
因此,如果 if 条件为真,则应执行 $pop 函数。如果是假的,它不应该。我为 if 子句写了这个,但它不起作用:
if (this.userId && userManagement.find({
'itemIds': {$gt: date}})) {...$pop function...}
【问题讨论】:
标签: arrays mongodb meteor mongodb-query