replace
operation without couchbase transactions.
some sample code below...
cOpts := gocb.ClusterOptions{
Authenticator: gocb.PasswordAuthenticator{
Username: "user",
Password: "pw",
},
}
cluster, err := gocb.Connect("couchbase://my.dev.server.net/", cOpts)
if err != nil {
panic(err)
}
qOpts := gocb.QueryOptions{}
// create query
queryStr := "SELECT * FROM myBucket WHERE id = '123456789'"
rows, err := cluster.Query(queryStr, &qOpts)
if err != nil {
panic(err)
}
fmt.Printf("rows: %v\n", rows)
for rows.Next() {
var intfc interface{}
err = rows.Row(&intfc)
if err != nil {
panic(err)
}
fmt.Printf("interface result: %v\n", intfc)
}
The couchbase server is on 5.1.
I am either getting...
panic: ambiguous timeout | {"statement":"SELECT * FROM myBucketName WHERE id = '123456789'","client_context_id":"cdd52a06-c7a5-4d3d-8r26-99fg806d559e"}
...when I run the above code.
OR
If I put in the following lines after the gocb.Connect(...
I get the error that is after that.
err = cluster.WaitUntilReady(25*time.Second, &gocb.WaitUntilReadyOptions{DesiredState: gocb.ClusterStateOnline})
if err != nil {
panic(err)
}
...error...
panic: unambiguous timeout | {"InnerError":{"InnerError":{"InnerError":{},"Message":"unambiguous timeout"}},"OperationID":"WaitUntilReady","Opaque":"","TimeObserved":25000263891,"RetryReasons":["NOT_READY"],"RetryAttempts":105,"LastDispatchedTo":"","LastDispatchedFrom":"","LastConnectionID":""}
NOTE: I changed the Username
, Password
, Server/connStr
, bucket
, and the id
just for example purposes here.
What am I missing here?
I was able to figure out my issue...
I guess I needed to add the bucket in the code, though it would not be used...so just after the error check I would have to do this...
_ = cluster.Bucket("myBucket")
I also found out that this server has horrible resources so queries take a while and I had to up the timeouts on things. Additionally, the query I was using was not taking advantage of the indexes at all, so I had to do that as well, I just assumed that ID was indexed, but I come from a relational db background and this was my first foray into Couchbase. I later found out there is another method for getting data based on the document id as well. So there is that.
Hi, I am trying to deploy Couchbase Operator with the official Helm Chart in my EKS but I am getting this error:
Error: UPGRADE FAILED: template: couchbase-operator/templates/couchbase-tls.yaml:2:22: executing "couchbase-operator/templates/couchbase-tls.yaml" at <include "couchbase-cluster.tls" .>: error calling include: template: couchbase-operator/templates/_helpers.tpl:432:59: executing "couchbase-cluster.tls" at <include "couchbase-cluster.tls.ca-secret" .>: error calling include: template: couchbase-operator/templates/_helpers.tpl:401:4: executing "couchbase-cluster.tls.ca-secret" at <first .Values.cluster.networking.tls.rootCAs>: error calling first: runtime error: invalid memory address or nil pointer dereference
The certs for the server and CA are autogenerated and I a put this in the networking side in the values.conf:
networking:
tls:
secretSource:
clientSecretName: couchbase-operator-tls
#serverSecretName: couchbase-server-tls
clientCertificatePolicy: mandatory
clientCertificatePaths:
- path: subject.cn
- path: san.email
delimiter: "@"
Anyone had this error?
Hi, I finally found the libLiteCoreJNI.so after compiling the couchbase-lite-java-ce-root/ce/java project. But I get errors when trying to run a basic test:
java.lang.NoSuchMethodError: Lcom/couchbase/lite/internal/fleece/FLSliceResult;.<init>(JJ)V
Could it be a versioning problem, have I compiled a version of couchbase-lite-java-ce-root/ce/java incompatible with version cbl-core?
Thank you very much for your help, it is a whole new world for me to compile C project.
transaction operation failed | unknown xattr macro | {\"status_code\":208,\"document_key\":\"6261445628862305918\",\"bucket\":\"test\",\"scope\":\"_default\",\"collection\":\"_default\",\"error_name\":\"SUBDOC_XATTR_UNKNOWN_MACRO\",\"error_description\":\"Subdoc: The server don't know about the specified macro\",\"opaque\":29,\"last_dispatched_to\":\"cb6.6-node-1-integration.xxxx.com:11210\",\"last_dispatched_from\":\"192.168.1.6:53822\",\"last_connection_id\":\"c85e9106efd1e39d/6e60ad824e08e5dd\"}\n"}
Hello 👋
I would like to ask a few questions about CRUD using cluster queries and key value pair requests. Using K/V operations, I successfully managed to:
get a document by id;
delete a document by id;
update a document by id;
create a document using general base URL;
When I am making a K/V create operation, as a key, I am using “nanoId” library to generate a random string that will be the key; So I can post the new document into a base URL without a query string with params;
Furthermore, my document has its own Id which is a numeric value different from the key.
So when I am trying to get all documents by using K/V, I am not sure how to do it.
export async function getBooks() {
try {
const cluster = await couchbaseConnect();
const bucket = cluster.bucket("BookStore");
const scope = bucket.scope("books")
const collection = scope.collection("books");
const result = await collection.get(id)
//id would be undefined here and I want to get all documents
console.log("I am the result from models", result)
return result.content;
} catch (error) {
console.log(error);
}
}
router.get("/", async function (req, res) {
const result = await getBooks();
return res.json({ success: true, payload: result });
});
I can’t get my head around what to put inside const result = await collection.get as I want to get all documents?
Can I do it using K/V pairs or shall I use cluster.query?
when I am trying to use cluster.query, to get documents by a certain query parameter, it seems that there are some errors in the syntax that I can’t resolve…
SELECT id, title, info
FROM \
BookStore`.books.books
WHERE title = ${title}`;
My bucket is called BookStore, with the scope called “books” and the collection called “books”
key "KQKk6pqbk3TSH" from nanoid
{"id":7,"title":"Book","info":[{"description":12002223,"price":123,"cover":"https://m.media-amazon.com/images/I/61NP3Oa+TSL.jpg"}]}
Also, this is my document structure, if info has nested object in an array, do I need to reflect it in SELECT id, title, info [{something something?}]
Thanks! 😊