Hi @Marco_Greco, Please find the below code snippets and console responses for Local Dev and AWS.
Snippet Code for Named Parameters:
readCostAlertDoc: async (inputData, cb) => {
try{
console.log(âInputData >>â, inputData);
const { companyID, upc, type } = inputData;
// const q = SELECT ba.*,meta(ba).id from \
${bucket}` ba WHERE companyID=â${companyID}â AND type=â${type}â AND upc=â${upc}â`;
const q = âSELECT ba.*, meta(ba).id from costalerts ba WHERE companyID=$companyID AND type=$type AND upc=$upcâ;
console.log(âPlain Query String >>â, q);
let cluster = new couchbase.Cluster(âcouchbase://ipaddress:8091/â);
cluster.authenticate(âuserâ, âpasswordâ);
let bucketCluster = cluster.openBucket(âcostalertsâ);
let query = couchbase.N1qlQuery.fromString(q);
console.log(âN1qlQuery String >>â, query);
bucketCluster.query(query, inputData, function(err, rows) {
if(err){
console.log(âQuery Error >>â, err.toString());
return cb(err.toString(), null);
}
console.log(âQuery Success >>â, rows);
cb(null, rows);
});
}catch(e){
cb(e.toString(), null);
}
}
AWS Console:
Local Dev Console:
Snippet Code for Positional Parameters:
readCostAlertDoc: async (inputData, cb) => {
try{
console.log(âInputData >>â, inputData);
const { companyID, upc, type } = inputData;
// const q = SELECT ba.*,meta(ba).id from \
${bucket}` ba WHERE companyID=â${companyID}â AND type=â${type}â AND upc=â${upc}â`;
const q = âSELECT ba.*, meta(ba).id from costalerts ba WHERE companyID=$1 AND type=$2 AND upc=$3â;
console.log(âPlain Query String >>â, q);
let cluster = new couchbase.Cluster(âcouchbase://ipaddress:8091/â);
cluster.authenticate(âuserâ, âpasswordâ);
let bucketCluster = cluster.openBucket(âcostalertsâ);
let query = couchbase.N1qlQuery.fromString(q);
console.log(âN1qlQuery String >>â, query);
bucketCluster.query(query, [companyID, type, upc], function(err, rows) {
if(err){
console.log(âQuery Error >>â, err.toString());
return cb(err.toString(), null);
}
console.log(âQuery Success >>â, rows);
cb(null, rows);
});
}catch(e){
cb(e.toString(), null);
}
}
AWS Console:
Local Dev Console:
We are getting success from the Local Dev machine but same code not working in the AWS Server. Please let us know if there any additional information require to closure ?