0

我似乎无法从我的 taffyDB 获取数据。它必须是错误的语法,但我不知道在哪里。我的 Javascript 看起来像这样:

// init db
var procTech = TAFFY();

//..... other code in the middle

procTech().remove(); 
var x = 0;
$(".sxRow select[id^='KRCtech_']").each(function() {
    var techName = $(this).val();       
    x++;
    var xStr = x.toString();
    clog(xStr + " " + techName);
    procTech.insert({"count":xStr,"tech":techName });   
});

var ret = eval(procTech().select("count","tech"));   
clog(ret.length);
for (j = 0; j <= ret.length - 1; j++) {   
    clog("read back: " + [j][0] + "," + [j][1]);
}   

// wrapper for console.log
function clog(s) {
    window.console && console.log(s);
    return; 
}

控制台 说:

 1 tonya
 2 shawn
 2
 read back: 0,undefined
 read back: 1,undefined

所以我知道

  1. 我的初始值很好;即它们有价值
  2. Taffy 看到 2 条记录,这是正确的

只是当我尝试检索它们时,它们是垃圾。

我究竟做错了什么?

4

1 回答 1

1
procTech.insert({"count":1,"tech":'techName' });
procTech.insert({"count":2,"tech":'techName1' });
procTech.insert({"count":3,"tech":'techName2' });
procTech.insert({"count":3,"tech":'techName2' });
procTech.insert({"count":3,"tech":'techName2' });
procTech.insert({"count":4,"tech":'techName3' });

var query = procTech.select("count","tech"); // 3 rows

for ( var x=0; x<query.length-1; x++ ) {
    console.log(query[x][0], query[x][1]);
}
于 2014-12-22T23:44:30.390 回答