Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
8da73b3b
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8da73b3b
编写于
7月 31, 2020
作者:
L
liu0x54
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1001] fix node js connector
上级
2b84d450
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
26 deletion
+32
-26
src/connector/nodejs/nodetaos/cursor.js
src/connector/nodejs/nodetaos/cursor.js
+9
-7
src/connector/nodejs/test/test.js
src/connector/nodejs/test/test.js
+23
-19
未找到文件。
src/connector/nodejs/nodetaos/cursor.js
浏览文件 @
8da73b3b
...
...
@@ -265,13 +265,15 @@ TDengineCursor.prototype.execute_a = function execute_a (operation, options, cal
}
if
(
resCode
>=
0
)
{
let
fieldCount
=
cr
.
_chandle
.
numFields
(
res2
);
if
(
fieldCount
==
0
)
{
cr
.
_chandle
.
freeResult
(
res2
);
}
else
{
return
res2
;
}
// let fieldCount = cr._chandle.numFields(res2);
// if (fieldCount == 0) {
// //cr._chandle.freeResult(res2);
// return res2;
// }
// else {
// return res2;
// }
return
res2
;
}
else
{
...
...
src/connector/nodejs/test/test.js
浏览文件 @
8da73b3b
...
...
@@ -28,7 +28,7 @@ c1.execute('create table if not exists stabletest (ts timestamp, v1 int, v2 int,
// Shell Test : The following uses the cursor to imitate the taos shell
// Insert
for
(
let
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
let
i
=
0
;
i
<
1000
0
;
i
++
)
{
let
insertData
=
[
"
now+
"
+
i
+
"
s
"
,
// Timestamp
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// Int
parseInt
(
R
(
-
Math
.
pow
(
2
,
31
)
+
1
,
Math
.
pow
(
2
,
31
)
-
1
)
),
// BigInt
...
...
@@ -40,7 +40,7 @@ for (let i = 0; i < 1000; i++) {
randomBool
(),
"
\"
Nchars
\"
"
];
// Bool
c1
.
execute
(
'
insert into td_connector_test.all_types values(
'
+
insertData
.
join
(
'
,
'
)
+
'
);
'
,
{
quiet
:
true
});
if
(
i
%
100
==
0
)
{
if
(
i
%
100
0
==
0
)
{
console
.
log
(
"
Insert #
"
,
i
);
}
}
...
...
@@ -61,9 +61,9 @@ console.log(d);
// Immediate Execution like the Shell
//
c1.query('select count(*), stddev(_double), min(_tinyint) from all_types where _tinyint > 50 and _int < 0;', true).then(function(result){
//
result.pretty();
//
})
c1
.
query
(
'
select count(*), stddev(_double), min(_tinyint) from all_types where _tinyint > 50 and _int < 0;
'
,
true
).
then
(
function
(
result
){
result
.
pretty
();
})
c1
.
query
(
'
select _tinyint, _bool from all_types where _tinyint > 50 and _int < 0 limit 50;
'
,
true
).
then
(
function
(
result
){
result
.
pretty
();
...
...
@@ -87,54 +87,58 @@ q.execute().then(function(r) {
// Raw Async Testing (Callbacks, not promises)
function
cb2
(
param
,
result
,
rowCount
,
rd
)
{
console
.
log
(
'
CB2 Callbacked!
'
);
console
.
log
(
"
RES *
"
,
result
);
console
.
log
(
"
Async fetched
"
,
rowCount
,
"
rows
"
);
console
.
log
(
"
Async fetched
"
,
rowCount
,
"
rows
"
);
console
.
log
(
"
Passed Param:
"
,
param
);
console
.
log
(
"
Fields
"
,
rd
.
fields
);
console
.
log
(
"
Data
"
,
rd
.
data
);
console
.
log
(
"
Fields
"
,
rd
.
fields
);
console
.
log
(
"
Data
"
,
rd
.
data
);
}
function
cb1
(
param
,
result
,
code
)
{
console
.
log
(
'
Callbacked!
'
);
console
.
log
(
"
RES *
"
,
result
);
console
.
log
(
'
C
B1 C
allbacked!
'
);
console
.
log
(
"
RES *
"
,
result
);
console
.
log
(
"
Status:
"
,
code
);
console
.
log
(
"
Passed Param
"
,
param
);
c1
.
fetchall_a
(
result
,
cb2
,
param
)
console
.
log
(
"
Passed Param
"
,
param
);
c1
.
fetchall_a
(
result
,
cb2
,
param
)
;
}
c1
.
execute_a
(
"
describe td_connector_test.all_types;
"
,
cb1
,
{
myparam
:
3.141
});
function
cb4
(
param
,
result
,
rowCount
,
rd
)
{
console
.
log
(
'
CB4 Callbacked!
'
);
console
.
log
(
"
RES *
"
,
result
);
console
.
log
(
"
Async fetched
"
,
rowCount
,
"
rows
"
);
console
.
log
(
"
Passed Param:
"
,
param
);
console
.
log
(
"
Fields
"
,
rd
.
fields
);
console
.
log
(
"
Data
"
,
rd
.
data
);
}
// Without directly calling fetchall_a
var
thisRes
;
function
cb3
(
param
,
result
,
code
)
{
console
.
log
(
'
Callbacked!
'
);
console
.
log
(
'
C
B3 C
allbacked!
'
);
console
.
log
(
"
RES *
"
,
result
);
console
.
log
(
"
Status:
"
,
code
);
console
.
log
(
"
Status:
"
,
code
);
console
.
log
(
"
Passed Param
"
,
param
);
thisRes
=
result
;
}
//Test calling execute and fetchall seperately and not through callbacks
var
param
=
c1
.
execute_a
(
"
describe td_connector_test.all_types;
"
,
cb3
,
{
e
:
2.718
});
console
.
log
(
"
Passed Param outside of callback:
"
,
param
);
console
.
log
(
param
);
setTimeout
(
function
(){
c1
.
fetchall_a
(
thisRes
,
cb4
,
param
);
},
100
);
// Async through promises
var
aq
=
c1
.
query
(
'
select count(*) from td_connector_test.all_types;
'
)
var
aq
=
c1
.
query
(
'
select count(*) from td_connector_test.all_types;
'
,
false
);
aq
.
execute_a
().
then
(
function
(
data
)
{
data
.
pretty
();
})
})
;
c1
.
query
(
'
describe td_connector_test.stabletest;
'
).
execute_a
().
then
(
r
=>
r
.
pretty
());
setTimeout
(
function
(){
c1
.
query
(
'
drop database td_connector_test;
'
);
},
200
);
setTimeout
(
function
(){
conn
.
close
();
},
2000
);
conn
.
close
();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录