Javascript Azure mobile services Node.js上where子句的筛选函数

Javascript Azure mobile services Node.js上where子句的筛选函数,javascript,node.js,azure,azure-mobile-services,Javascript,Node.js,Azure,Azure Mobile Services,我试图在之前的链接中描述的where子句中使用一个过滤器函数,但是我找不到关于如何编写它的任何参考 exports.post = function(request, response) { var currentdate = (new Date()).getTime(); takenOffersTable.where(function(request,currentdate){ return (this.user_id == request.

我试图在之前的链接中描述的where子句中使用一个过滤器函数,但是我找不到关于如何编写它的任何参考

     exports.post = function(request, response) {
       var currentdate = (new Date()).getTime();
       takenOffersTable.where(function(request,currentdate){
       return (this.user_id ==  request.user.userId && this.offer_id == request.body.offer_id && this.__updatedAt < currentdate)
       }).read({ success: function(result) { ...
我得到
ReferenceError:未定义请求

如何将request和currentdate参数提供给filter函数,或者如何编写? 也没有帮助。

当使用的
where(function)
时,我们应该在
where
闭包中的
function(){}
构造之后添加参数值

按如下格式生成:

var variable1,variable2;
...
tableObject.where(function(parameter1,parameter2,...){},variable1,variable2,...)
...
而且,如果在
where
函数中直接设置
request
对象,似乎会引发
TypeError:将循环结构转换为JSON
问题

因此,根据您的代码,您可以尝试将其修改为以下代码段:

exports.post = function(request, response) {
       var currentdate = (new Date()).getTime();
       takenOffersTable.where(function(user,body,currentdate){
       return (this.user_id ==  user.userId && this.offer_id == body.offer_id && this.__updatedAt < currentdate)
       },request.user,request.body,currentdate).read({ success: function(result) { ...
exports.post=函数(请求、响应){
var currentdate=(新日期()).getTime();
takenOffersTable.where(函数(用户、正文、当前日期){
返回(this.user\u id==user.userId&&this.offer\u id==body.offer\u id&&this.\u updatedAt
当使用的
where(function)
时,我们应该在
where
闭包中的
function(){}
构造之后添加参数值

按如下格式生成:

var variable1,variable2;
...
tableObject.where(function(parameter1,parameter2,...){},variable1,variable2,...)
...
而且,如果在
where
函数中直接设置
request
对象,似乎会引发
TypeError:将循环结构转换为JSON
问题

因此,根据您的代码,您可以尝试将其修改为以下代码段:

exports.post = function(request, response) {
       var currentdate = (new Date()).getTime();
       takenOffersTable.where(function(user,body,currentdate){
       return (this.user_id ==  user.userId && this.offer_id == body.offer_id && this.__updatedAt < currentdate)
       },request.user,request.body,currentdate).read({ success: function(result) { ...
exports.post=函数(请求、响应){
var currentdate=(新日期()).getTime();
takenOffersTable.where(函数(用户、正文、当前日期){
返回(this.user\u id==user.userId&&this.offer\u id==body.offer\u id&&this.\u updatedAt
我可以传递一些函数作为参数吗?我可以传递一些函数作为参数吗?