I have the following document in Couchbase:
{
"id": "ee::brown",
"type": "ee",
"firstName": "John",
"lastName": "Brown",
"email": "[email protected]"
}
The code below tries to get the lastName field for id="ee::brown"
ops := []gocb.LookupInSpec{
gocb.GetSpec("lastName", &gocb.GetSpecOptions{}),
}
getResult, err := collection.LookupIn("ee::brown", ops, &gocb.LookupInOptions{})
if err != nil {
panic(err)
}
var lastName string
err = getResult.ContentAt(0, &lastName)
if err != nil {
panic(err)
}
fmt.Println(lastName)
Running this code generates the following message:
Not Found (KEY_ENOENT)
Running following query in Query workbench retrieves the full document:
select * from mybucket where id="ee::brown"
Also tried setting IsXttra field to true as follows but it did not work either:
ops := []gocb.LookupInSpec{
gocb.GetSpec("lastName", &gocb.GetSpecOptions{IsXattr: true}),
}
Also could not find definition of IsXattr for GetSpecOption. What is it for? Help please!
Environment: macOS Catalina version 10.15.3; go-sdk : import "github.com/couchbase/gocb/v2" ; Couchbase: Enterprise Edition 6.5.0 build 4960