在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ node.js無法寫入hbase數據庫

node.js無法寫入hbase數據庫

我現在在寫一個寫入hbase的操作系統(tǒng)。前端是vue.js,后端是node.js,數據庫RT,是hbase。我目前前端可以發(fā)送數據到后端接收,但是在寫入的時候,總是報錯。

Users/user/Desktop/web/node_modules/hbase/lib/row.js:169
    return args[0].apply(this, [null, cells]);

TypeError: Cannot read property 'apply' of undefined

    at client.connection.get (/Users/user/Desktop/web/node_modules/hbase/lib/row.js:169:20)
    at IncomingMessage.res.on (/Users/user/Desktop/web/node_modules/hbase/lib/connection.js:142:16)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1091:14)
    at process._tickCallback (internal/process/next_tick.js:174:19)
    

node.js:可以寫入數據庫,但會停止程序并報出上邊的錯誤。

router.post('/uploadHbase', function(req, res){
  var form = new formidable.IncomingForm();
  form.parse(req, function (err, fields, files) {

    console.log(fields);//這里就是post的XXX 的數據
    client.table('test2')
      .create('col_family', function(err, success){
        this
          .row('rowkey1')
          .put('col_family:model_contents', 'testContent', function(err, success) {
            this.get(fields.colFamilyPut, function (err, cells) {
              this.exists(function (err, exists) {
                assert.ok(exists);
              });
            });
          });
      });


  });

  res.json({
    status:'0',
    msg:'',
  });


});

這個是在同一個路由下可以運行的,提交的是不同路由

router.post('/upload', function(req, res){

  var form = new formidable.IncomingForm();
  form.uploadDir = path.join(__dirname, '/upload');

  form.parse(req, function (err, fields, files) {

    console.log(fields);//這里就是post的XXX 的數據

    fs.readFile(files.file.path, 'utf8', (err, data) => {
    if (err) {
        console.log(err);
      }

      var obj = JSON.parse(data);
     console.log(obj);

      //Put to hbase
      client.table(‘test’)
        .create('col_family', function(err, success){
         this
           .row('rowkey')
            .put('col_family:model_contents', JSON.stringify(obj), function(err, success) {
              this.get(fields.colFamilyPut, function (err, cells) {
                this.exists(function (err, exists) {
                  assert.ok(exists);
                  console.log(success);
                });
              });
           });
        });
    });

同在一個路由下的另一個post就完全沒有問題,可以寫入hbase數據庫,完全不知道啥原因。

回答
編輯回答
爛人

ok。這個問題的報錯點在于斷言測試(assert).

2018年9月7日 17:20
編輯回答
假灑脫

哪個post可以 能不能拿出對比來 老哥

2017年8月9日 19:41