无法读取未定义的 属性 'omitFormat'
Cannot read property 'omitFormat' of undefined
我在 clickhouse
中创建了一个 table,如下所示:
let clickhouse = new ClickHouse (sails.config.clickhouse);
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`
我尝试 运行 上面的查询:
return new Promise((resolve, reject) => {
clickhouse.query (query, function (err, result) {
if (err) {
console.log(err);
}
resolve('success');
});
});
let test = await createTable();
但后来我得到了这个错误:
Cannot read property 'omitFormat' of undefined
这个错误有什么解决办法吗?谢谢
P.S:我已经尝试 运行 Clickhouse
客户端中的查询并且有效。
你传的没有初始化sails.config.clickhouse-param.
传递未定义的 options to ClickHouse-constructor leads to the error in this line。
查看控制台可以看到相关警告:
> You must provide at least host name to query ClickHouse // <---- !!!
>
> Error: TypeError: Cannot read property 'omitFormat' of undefined
> at ClickHouse.query (/home/runner/node_modules/@apla/clickhouse/src/clickhouse.js:257:60)
> at Promise (evalmachine.<anonymous>:8:26)
> at new Promise (<anonymous>)
> at createTable (evalmachine.<anonymous>:7:10)
> at evalmachine.<anonymous>:17:1
> at Script.runInContext (vm.js:133:20)
> at Object.runInContext (vm.js:311:6)
> at evaluate (/run_dir/repl.js:133:14)
> at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
> at ReadStream.emit (events.js:198:13)
重现此错误的代码(参见 https://repl.it/repls/FakePortlyExponent):
const ClickHouse = require('@apla/clickhouse')
let clickhouse = new ClickHouse (/*sails.config.clickhouse*/null); // <----- !!!
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`;
async function createTable() {
return new Promise((resolve, reject) => {
clickhouse.query (query, function (err, result) {
if (err) {
console.log(err);
}
resolve('success');
});
});
}
createTable()
.then(() => {
console.info('Success.');
})
.catch(err => {
console.error('Error:', err);
});
我在 clickhouse
中创建了一个 table,如下所示:
let clickhouse = new ClickHouse (sails.config.clickhouse);
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`
我尝试 运行 上面的查询:
return new Promise((resolve, reject) => {
clickhouse.query (query, function (err, result) {
if (err) {
console.log(err);
}
resolve('success');
});
});
let test = await createTable();
但后来我得到了这个错误:
Cannot read property 'omitFormat' of undefined
这个错误有什么解决办法吗?谢谢
P.S:我已经尝试 运行 Clickhouse
客户端中的查询并且有效。
你传的没有初始化sails.config.clickhouse-param.
传递未定义的 options to ClickHouse-constructor leads to the error in this line。
查看控制台可以看到相关警告:
> You must provide at least host name to query ClickHouse // <---- !!!
>
> Error: TypeError: Cannot read property 'omitFormat' of undefined
> at ClickHouse.query (/home/runner/node_modules/@apla/clickhouse/src/clickhouse.js:257:60)
> at Promise (evalmachine.<anonymous>:8:26)
> at new Promise (<anonymous>)
> at createTable (evalmachine.<anonymous>:7:10)
> at evalmachine.<anonymous>:17:1
> at Script.runInContext (vm.js:133:20)
> at Object.runInContext (vm.js:311:6)
> at evaluate (/run_dir/repl.js:133:14)
> at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
> at ReadStream.emit (events.js:198:13)
重现此错误的代码(参见 https://repl.it/repls/FakePortlyExponent):
const ClickHouse = require('@apla/clickhouse')
let clickhouse = new ClickHouse (/*sails.config.clickhouse*/null); // <----- !!!
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`;
async function createTable() {
return new Promise((resolve, reject) => {
clickhouse.query (query, function (err, result) {
if (err) {
console.log(err);
}
resolve('success');
});
});
}
createTable()
.then(() => {
console.info('Success.');
})
.catch(err => {
console.error('Error:', err);
});