g*********e 发帖数: 14401 | 1
比如
[testname:abc, time:123]
[testname:abc, time:222]
[testname:def, time:333]
group by testname以后 中间那个就没有了 |
|
g*********e 发帖数: 14401 | 2 比如我有类似
for (i =0; i
connection(select... where testname=testnames[i]) function(rows, )...
...
}
最后我想把这些rows都Push到一个array里,然后用json得形式返回response。
但node里query 似乎是non blocking的?这种一般怎么解决? |
|
g*********e 发帖数: 14401 | 3 i have an array, each of them is a string of a testname.
then a need to do a sql query "select ... where TESTNAME=testname ... " for
each tests, then collect each query result back and form the eventual
response.
[{test1: test1_query_result},
{test2: test2_query_result},
...
]
that's what i want. can anyone share usable code? Thx. |
|
n****j 发帖数: 1708 | 4 SQL 没法给你这样的结果,只能是 table,select * from table where testname in
(n1,n2, ...) order by testname,然后在 node 里 foreach row , result[testname
].push({func,time}) |
|
s*****a 发帖数: 2006 | 5 【 以下文字转载自 Joke 讨论区 】
发信人: csboy2007 (宇宙无敌包子控), 信区: Joke
标 题: 看看你前世有几个子女 (转载)
发信站: BBS 未名空间站 (Fri Oct 1 16:58:46 2010, 美东)
发信人: zhanqixiong (詹其雄), 信区: WaterWorld
标 题: 看看你前世有几个子女
发信站: BBS 未名空间站 (Fri Oct 1 15:12:53 2010, 美东)
http://cn.testname.cc/testname/cn/history/ |
|
|
V*****8 发帖数: 33122 | 7 【 以下文字转载自 Joke 讨论区 】
发信人: csboy2007 (宇宙无敌包子控), 信区: Joke
标 题: 看看你前世有几个子女 (转载)
发信站: BBS 未名空间站 (Fri Oct 1 16:58:46 2010, 美东)
发信人: zhanqixiong (詹其雄), 信区: WaterWorld
标 题: 看看你前世有几个子女
发信站: BBS 未名空间站 (Fri Oct 1 15:12:53 2010, 美东)
http://cn.testname.cc/testname/cn/history/ |
|
|
|
|
|
|
d****n 发帖数: 1637 | 13 var async = require('async')
async.map(testNames,
function processOneName(tname, cb){
connectionToEachDb(tname,
function (rows, err){
if (err){
return cb(err);
}
return cb( null, rows);
}
);
},
function allDone(err, results){
if (err) return console.log("A error:", err);
return results ; // results are in the order of your testNames if all
successed
}
);
//use async.mapLimit([], limits, function procEach(){}, functi... 阅读全帖 |
|
|
|
|
u*****o 发帖数: 1224 | 17 你还年轻啊,来日方长,肯定有报答他们的一天啊。。
LZ我想问一句,你说的test case怎么写,是指怎么写syntax:
比如说写test function的interface
void test(const* testname, int input1, int input2, int expected){}
还是说有什么case需要cover,比如input是负,是0,out of range。。
我一直很关心test engineer和sde有什么不同,正好你来讲这个问题。。你rp太好了啊 |
|
|
|
b********n 发帖数: 673 | 20 ☆─────────────────────────────────────☆
Mars (火星) 于 (Mon Jul 14 18:14:21 2008) 提到:
http://cn.testname.cc/history/
我竟然是蜀国祸国殃民盗墓贼。。。。
☆─────────────────────────────────────☆
itanium (itanium) 于 (Mon Jul 14 18:15:01 2008) 提到:
哈哈哈哈哈哈哈
☆─────────────────────────────────────☆
itanium (itanium) 于 (Mon Jul 14 18:15:48 2008) 提到:
前世: 唐朝谨小慎微铁匠
魅力: 8
名气: 4
子女: 2个儿子, 6个女儿
宠物: 一只喜欢抓老鼠的狗
........................
☆─────────────────────────────────────☆
buckeyefan (小背心) 于 (Mon Jul 1 |
|
|
|
n*****t 发帖数: 22014 | 23 select where testname in (...)
或者 async.foreach |
|
n*****t 发帖数: 22014 | 24 楼上二位 。。。技术讨论吧 。。。
async 是显然的,lock 我不认为是问题,单线程的。楼主的例子,testname 可能在两
次 query 中被 update,导致同一条记录被 push 几次,再考虑效率,select in 我觉
得是最好的办法。
初学者,表喷我。。。。。。 |
|
p*****2 发帖数: 21240 | 25
testname 可能在两
次 query 中被 update,导致同一条记录被 push 几次,
这个是什么意思? |
|
p*****2 发帖数: 21240 | 26 为什么你assume别人会改db呢?
也许immutable的 至少testname我不感觉会被改来改去 |
|
|
g*********e 发帖数: 14401 | 28
my table schema is like this:
[testname, function, time]
is it possible for sql to do nested results in single select?
desired result:
{testname1 {function11, time11;
function12, time12;
...}
testname2 {function21, time21;
function22, time22;
...}
testname3 {...}
} |
|
|