cratedb nodejs 试用

安装cratedb

docker run -d -p 4200:4200 crate

nodejs 项目初始化

  • yarn
yarn init -y
  • 添加依赖
yarn add   node-crate
  • 基本代码
app.js
var crate = require('node-crate');
crate.connect('localhost', 4200);
crate.execute("select * from appdemofirst", []).then((res) => {
    console.log('Success', res.json, res.duration, res.rowcount, res.cols, res.rows)
})
  • package.json
{
  "name": "node-project",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "node-crate": "^2.0.6"
  },
  "scripts": {
    "s":"node app"
  }
}
  • 项目结构
├── README.md
├── app.js
├── package.json
└── yarn.lock

运行

yarn s

参考资料

https://www.npmjs.com/package/node-crate
https://github.com/rongfengliang/cratedb-nodejs-demo

 
 
 
 
 
 
·