For now the database browser is unfinished, but feel free to use the snippets that are implemented.
To install the VSIX file do the following:
-
Download the latest VSIX file, under the assets section, at our releases page. Note: We are currently in pre release mode so there may be some bugs
-
Open Visual Studio Code.
-
On the left side of the screen you will see a menu bar with an option to open the extensions menu, click this button.
-
You should now see the extensions menu. At the top right of this menu you should see an ellipsis menu icon, click this and select "Install from VSIX".
-
This should open a file explorer, locate the VSIX that you downloaded earlier and install it.
-
Congratulations, you have now installed the Couchbase Visual Studio Code Extension.
This tutorial assumes that you have a couchbase cluster set up with the travel-sample
bucket present.vWe will use a get operation and run a query on this cluster.
We will use the Couchbase Node.js SDK for this example, but if you are unfamiliar with it then feel free to use any of our other supported SDKs. The snippet shortcuts will be the same, but file extensions and code will be different from what is displayed.
This should create the following code
const couchbase = require('couchbase')
async function main() {
const cluster = await couchbase.connect('connection-string', {
username: 'Administrator',
password: 'password',
})
// get a reference to our bucket
const bucket = cluster.bucket('bucket-name')
// get a reference to a collection
const collection = bucket.scope('scope-name').collection('collection-name')
}
You should be able to tab through the values for cluster
,connection-string
, the username, the password, bucket
, bucket-name
, collection
, scope-name
, collection-name
.
Set connection-string
, the username, and password, to the appropriate values for your cluster.
Leave cluster
, bucket
, and collection
as the defaults.
Set bucket-name
to 'travel-sample'.
Set scope-name
, and collection-name
to '_default'.
This should create the following code:
try {
const result = await collection.get(key, { timeout: 1000 });
document = result.value;
} catch (e) {
if (e instanceof couchbase.DocumentNotFoundError) {
console.log('Document not found...')
} else {
throw e
}
}
You should be able to tab through the values for collection
,key
, and the timeout.
Leave collection
and the values for timeout the same.
Set key
to 'airline_10'
Add the following code to the bottom of our main function:
console.log(document);
Add the following code to the bottom of our document:
main();
In the command line, navigate to this directory and run:
node server.js
This should create the following output:
{
id: 10,
type: 'airline',
name: '40-Mile Air',
iata: 'Q5',
icao: 'MLA',
callsign: 'MILE-AIR',
country: 'United States'
}