gpt4 book ai didi

javascript - 太妃糖数据库对我的多列进行排序

转载 作者:搜寻专家 更新时间:2023-10-30 23:47:46 25 4
gpt4 key购买 nike

因此,我尝试在多列上对 Taffy 数据库进行排序,但得到了意想不到的结果。这个例子:

<script src="./taffy/taffy.js"></script>
<script>

var myTaffyDB = TAFFY([
{"foo":"bar","letter":"A","number_01":48,"number_02":6},
{"foo":"bar","letter":"S","number_01":49,"number_02":2},
{"foo":"bar","letter":"Q","number_01":49,"number_02":3},
{"foo":"bar","letter":"W","number_01":49,"number_02":4},
{"foo":"bar","letter":"P","number_01":49,"number_02":5},
{"foo":"bar","letter":"T","number_01":49,"number_02":6},
{"foo":"bar","letter":"W","number_01":49,"number_02":7},
{"foo":"bar","letter":"Q","number_01":49,"number_02":8},
{"foo":"bar","letter":"A","number_01":49,"number_02":9},
{"foo":"bar","letter":"C","number_01":49,"number_02":10},
{"foo":"bar","letter":"B","number_01":50,"number_02":1}
]);
var tempResultsArray = myTaffyDB({"foo":"bar"})
.order("letter","number_01","number_02")
.select( "letter", "number_01", "number_02")
;
console.log( 'tempResultsArray: ' + tempResultsArray );

</script>

产生以下内容:

A,48,6,A,49,9,B,50,1,C,49,10,P,49,5,Q,49,8,Q,49,3,S,49,2,T,49,6,W,49,4,W,49,7

请注意,Q 结果按 49,8 然后 49,3 的顺序排序,尽管顺序调用说按字母分组,然后是 number_01,然后是 number_02。

我是不是在构建这个的过程中遗漏了一些东西,或者 Taffy 订购结果的方式是否存在一些限制?

最佳答案

试试 .order("letter, number_01, number_02")
源代码说://* 目的:接受诸如“[col]、[col2]”或“[col] desc”之类的过滤器,并对这些列进行排序
它对我有用。

关于javascript - 太妃糖数据库对我的多列进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26066373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com