For SDK v 3.1.0, doing:
import * as couchbase from "couchbase"
gives me access to the non-exported types (I only need Cluster
and Bucket
for now, but other types including SearchQuery
are accessible via the import without Error)
Here’s a working query example (after setting this.cluster
(above)):
async performQuery() {
const res = await this.cluster!.query("SELECT bucket.* FROM bucket WHERE meta().id = 'mydocument'")
//Loop thru rows, each is an object
res.rows.forEach((row: Object) => {
//cast the the row to my expected type
const myobject = <MyClass>row
console.log(`doing something with cluster: ${myobject.prop1}`)
})
}
My tsconfig.json
file looks like:
{
"compilerOptions": {
/* Basic Options */
"target": "ES6",
"module": "commonjs",
/* skip corresponding '.d.ts' file. */
"declaration": false,
/* Redirect output structure to the directory. */
"outDir": "dist",
/* Enable all strict type-checking options. */
"strict": true,
/* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"allowSyntheticDefaultImports": true,
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"esModuleInterop": true,
//allow Javascript imports in TypeScript
"allowJs": true
}
}
Hope this helps