我正在尝试通过node.js sdk将ubuntu 16.04的couchbase服务器社区版用于我的项目。
但是在尝试访问我的网址时。我一次又一次地收到这个错误。
我的app.js
文件内容为
var express = require('express');
var couchbase = require('couchbase');
var bodyParser = require('body-parser');
var cluster = new couchbase.Cluster("couchbase://127.0.0.1");
var bucket = cluster.openBucket("travel-sample");
bucket.operationTimeout = 120 * 1000; //increase timeout to resolve the issue of cannot perform operations on a shutdown bucket
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.get("/person/:id", function (req, res) {
bucket.get(req.params.id, function (error, result) {
if (error) {
return res.status(400).send(error);
}
return res.status(200).send(result);
});
});
app.get("/person/:id", function (req, res) {
var person = {
firstName: req.body.firstName,
lastName: req.body.lastName,
};
bucket.post(req.params.id, person, function (error, result) {
if (error) {
return res.status(400).send(error);
}
return res.status(200).send(result);
});
});
app.listen(3000, function(){
console.log("Express server is running on port 3000");
});
尝试通过邮递员http://localhost:3000/person/pulkitarun
点击此网址时它给出了错误 -
Error: cannot perform operations on a shutdown bucket
at Bucket._maybeInvoke (/var/www/html/couchserver/node/node_modules/couchbase/lib/bucket.js:1216:11)
at Bucket.get (/var/www/html/couchserver/node/node_modules/couchbase/lib/bucket.js:1360:8)
at /var/www/html/couchserver/node/app.js:18:12
at Layer.handle [as handle_request] (/var/www/html/couchserver/node/node_modules/express/lib/router/layer.js:95:5)
at next (/var/www/html/couchserver/node/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/var/www/html/couchserver/node/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/var/www/html/couchserver/node/node_modules/express/lib/router/layer.js:95:5)
at /var/www/html/couchserver/node/node_modules/express/lib/router/index.js:281:22
at param (/var/www/html/couchserver/node/node_modules/express/lib/router/index.js:354:14)
at param (/var/www/html/couchserver/node/node_modules/express/lib/router/index.js:365:14)
请帮忙。