how we can create External UDF to execute N1QL?

73 Views Asked by At

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

1

There are 1 best solutions below

1
On

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