0

i had created External UDF to execute N1QL but when we execute function then get error

function that i created

function myFunction() {
     var N1qlQuery = couchbase.N1qlQuery;
     query = N1qlQuery.fromString('select * from test.`101`.cust1  where Meta().id=\"101::13::CUST1::1::000a4aed-5b51-45e7-8294-ac4e320d2291\"');
     retrun bucket.query(query).toString()
  }

2nd way that i had tried

function myFunction() {
 var cluster = Cluster.connect(\"127.0.0.1\", \"Administrator\", \"password\");
 var bucket = cluster.bucket(\"test\");
 var scope =bucket.scope(\"101\");
 var collections  =scope.collection(\"cust1\");
 var N1qlQuery = couchbase.N1qlQuery;

 query = N1qlQuery.fromString('select * from test.`101`.cust1  where Meta().id=\"101::13::CUST1::1::000a4aed-5b51-45e7-8294-ac4e320d2291\"'); 
 retrun bucket.query(query).toString()
 }

"

error that i get

enter image description here

enter image description here

Avinash Kumar
  • 85
  • 1
  • 6

1 Answers1

0

I am sorry to say that at this moment in time javascript UDFs cannot execute N1QL statements, which explains why your UDFs fail.

  • I am using couchbase 7.0 beta, As per docs we can exeute query in inline user defined function.. And external user defined function only support javascript. Just I am trying to figure out can we execute query in external user defined function.? If yes then how? If no then why? Is in couchbase 7.0 beta support query in external user defined function? – Avinash Kumar Nov 25 '20 at 20:15