如何在解析中获取云代码中的行数
How to get rows count in Cloud Code in Parse
我试过这个代码:我一直在获得成功/错误没有被调用。
Parse.Cloud.beforeSave("Offer", function(request, response) {
var duplicationQuery = new Parse.Query("Offer");
console.log(duplicationQuery.count);
});
然后我尝试了这个:
Parse.Cloud.beforeSave("Offer", function(request, response) {
var duplicationQuery = new Parse.Query("Offer");
duplicationQuery.count()
{
success: function(httpResponse) {
console.log(httpResponse.text);
response.success(httpResponse.text);
console.log("Row count: "+duplicationQuery.count);
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
response.error('Request failed with response code ' + httpResponse.status);
}
}
});
我想我被不恰当的语法卡住了。有人能帮我吗?
我会说远离计数查询,因为它们效率低下。只需执行find
查询并使用结果的length
属性获取计数。
var duplicationQuery = new Parse.Query("Offer");
duplicationQuery.limit(1000); // max limit
duplicationQuery.find().then( function(results) {
console.log(results.length);
});
还要记住,在任何查询中可以获得的最大记录数都限制为1000。
相关文章:
- 如何从JavaScript到C#代码中获取特定值
- 获取PHP代码中日期选择器的值
- 如何将JavaScript自动POST的状态代码获取到另一个域
- 从页面上的谷歌分析跟踪代码获取帐户ID
- 从服务器端代码获取会话信息到客户端代码
- Android:从HTML代码获取链接(没有标签/ID)
- 如何使用 C# 代码获取 confirm() 值
- 如何使用一行代码获取字符串数组的最后一个元素
- 使用 java 代码获取完整的网页
- 地理位置代码获取附近的城市
- 保存后分析云代码获取保存的对象
- 需要帮助将此代码获取到控制台应用程序
- 在laravel 5.1上使用此代码获取内部服务器错误500
- 从前端JavaScript代码获取Spotify API访问令牌
- Javascript日期对象原生代码获取月份名称
- 如何在同一个JSP页面中从javascript代码获取值到JSP scriptlet
- 解析云代码-获取pfffile的URL
- Phonegap代码获取要在html中发布的文件的完整路径
- jQuery代码获取复选框长度,而使用jQuery数据表
- 如何从机场代码获取纬度和经度