简体   繁体   English

尝试设置query.limit(varname)并收到错误消息,指出“ limit”只能设置为数字

[英]trying to set query.limit(varname) and getting error saying that the 'limit' can only be set to a numeric

I have been working with Parse for some time now with great success. 我已经与Parse合作了一段时间,并取得了巨大的成功。 Recently, I had an issue that pushed me to move to the latest cdn-based javascript API. 最近,我遇到一个问题,迫使我转向最新的基于cdn的javascript API。 Immediately after changing my parse API version (via cdn), I started getting this error, having to do with a simple query.limit(n) setting I have in my code. 更改解析API版本(通过CDN)后,我立即开始收到此错误,这与我在代码中具有的简单query.limit(n)设置有关。

Here is the error I am getting: 这是我得到的错误:

Uncaught Error: You can only set the limit to a numeric value
at ParseQuery.limit (parse-latest.js:6704)
at ParseTable.render (ParseTable.js:199)
at ParseTable (ParseTable.js:52)
at HTMLDocument.<anonymous> (players.php:137)
at l (jquery-1.8.3.min.js:2)
at Object.fireWith [as resolveWith] (jquery-1.8.3.min.js:2)
at Function.ready (jquery-1.8.3.min.js:2)
at HTMLDocument.A (jquery-1.8.3.min.js:2)

See ParseTable.js:199 below - Again, this line has worked for months and only went berzerk after the API swapout. 参见下面的ParseTable.js:199-同样,该行已经工作了几个月,并且在API换出之后才出现问题。

},
            render: function(){
                this.spin(true);
                if(!this.DOM){
                    this.init(); // ONE TIME CALL
                }

                this.query.startsWith(this.opts.searchColumn, input)
                this.query.equalTo(this.opts.primaryKeyCloudColumn, this.opts.username)
                alert(this.pageSize);             <--- this returns 10  -----------
                this.query.limit(this.pageSize)   <--- this is line 199 ----

                if(this.page>1)
                    this.query.skip((this.pageSize*this.page)-this.pageSize)
                else 
                    this.query.skip(0) // unsetting skip

                if(this.sortBy)
                    if(this.sortOrder==='ascending')
                        this.query.ascending(this.sortBy)
                    else 
                        this.query.descending(this.sortBy)

                this.query.find({

                    success: function(results) {

                        if(!results.length){

Any ideas appreciated! 任何想法表示赞赏!

I found that, for some reason, my query.limit(n) value was being received by the called API function as a character string. 我发现由于某种原因,被调用的API函数将我的query.limit(n)值作为字符串接收。

I fixed it by using the following - 我使用以下方法修复了它-

    this.query.limit(Number(this.pageSize));

Working fine again. 再次正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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