简体   繁体   中英

Azure mobile service table filter

I am trying to get users that are present in array onlineUsers, but it is giving me following error. Can someone please give me work around if this doesn't work

CODE:

exports.post = function(request, response) {
    var onlineUsers    = ["6990"];    
    // Tables
    var userTable    = request.service.tables.getTable('Users');
    userTable.where(
        function(ou) {
            return ou.search(this.id) != -1;
        },onlineUsers).read({
            success : function(users){
                response.send(statusCodes.OK, { message : users });
            }            
    });
};

ERROR:

Error in script '/api/test_find.js'. Error: The expression 'ou.search(this.id)'' is not supported.

Try the following:

userTable.where(function(ou) {
    return this.id in ou;
}, onlineUsers)

Keep in mind that the SQL generated contains a separate where clause for each element of onlineUsers , so it can become quite inefficient if the array contains many elements. We're looking at improving the query API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM