如何根据数字列从 Parse 中对数据数组进行排序
How do I order an array of data from a Parse, based on a number column
在我的网站上,我调用我的解析数据库,它从一个类中获取数据并将其放入数组中。
直到几天前,它还对数据进行了排序,我认为这是按"createdAt"时间戳排序的。但是现在它似乎在数组中随机向上/向下移动几列,我不知道为什么。
我在类中还有另一列标题为"num",仅用于对每一行进行编号。
目前,调用数据库以获取数据的代码如下所示:
// Query the content class for rows where the image exists
var content = Parse.Object.extend("content");
var query = new Parse.Query(content);
query.exists("image");
query.find({
success: function(results) {
// If the query is successful, store each image URL in an array of image URL's
var grid = $("#grid"), slider = $("#slider"), mainContent = $("#main_content"), initialImages, moreImages, totalLoadedImg = 0, remainingImages = results.length;
。
有没有办法在调用数据库时,它会根据数据库中的"num"列按顺序将数据存储在数组中?
这是网站的链接:http://colorperday.com
每种颜色都有自己的列,该列也有自己的数字"num"。我正在尝试做的是将颜色从最高的"num"(顶部(到最低的"num"(底部(排序。
感谢任何能够提供帮助的人!
来自 Parse.com JavaScript 指南:
// Sorts the results in ascending order by the score field
query.ascending("score");
// Sorts the results in descending order by the score field
query.descending("score");
在您的情况下,将"分数"替换为"数字">
相关文章:
- 使用数据数组创建多个类似组件
- WebAudio API数据数组大小
- Jquery 循环一次或在数据数组中显示一次数据
- Cakephp 访问不在模型数据数组上的输入
- 使用来自 Ajax 响应的 JSON 数据数组
- Angular JS(离子)数据数组到$scope元素
- handontable:在不更改数据数组/对象的情况下隐藏某些列
- 如何使用for循环语句通过Ajax发送大数据数组
- 压缩 JS 中的数据数组
- 传递的参数D3提示回调是完整的数据数组
- 如何在数据数组的每次迭代中创建一个内容为“i+1”的新 HTML 元素
- 在 laravel 4 上使用循环将数据数组存储到单个数组中
- 为什么它说输入数据数组的格式不正确 jqchart.
- Javascript - 使用变量 RegExp 匹配数据数组中的多个关键字
- 尝试将数据数组设置为从视图调用函数后$scope
- 如何在 PHP 中创建 jqplot 数据数组
- 如何使用该数据数组从左向右移动画布
- 如何根据数字列从 Parse 中对数据数组进行排序
- 为什么 php json 响应不会将数据数组发送回 ajax jquery 请求
- 如何将内容添加到 JQuery Flot 图表数据数组工具提示