Couchbase Lite now has an exciting new developer tool to announce. Developers need good tools, just like any other profession. The quality of the tools directly impacts the efficiency and quality of development work. Many have come and gone over the years, but there is one tool currently standing out in the field: Visual Studio Code

“VSCode” extends the universal text editor and syntax highlighting with customized working environments crafted to your needs. As with all things customizable, plugins have begun to emerge, showcasing that this humble text editor has far more power than merely editing text. Graphics can be previewed, network connections can be made, and even binary files can be opened and examined.

For this reason, it is my pleasure to announce that Couchbase has released a plugin for Visual Studio Code that allows users to inspect Couchbase Lite databases.

Download the VSCode Plugin for Couchbase Lite from the Visual Studio Code Extensions marketplace and read on to learn more.

VSCode extension for Couchbase Lite databases

This is so exciting because it is the first time that this examination is possible in such a rich, graphical, cross-platform setting. If you are curious about the contents of the database, this is now the easiest way to explore it. While currently using a prerelease number, the plugin is based on and uses a stable tested build of the Couchbase Lite library underneath to provide functionality. Let’s have a look at some of the things it can do.

Open a Couchbase Lite database in Visual Studio Code

Of course, it can clearly list all the documents contained within a given database. This will probably be the first thing noticed when opening a database:

Open a Couchbase Lite database in VSCodeBrowse objects in a Couchbase Lite database with VSCode extension

Beyond that, if you are wondering about the things that are possible with the tool, then it is best summarized as CRUD operations. 

As with the Couchbase Lite SDK, if you open a database with the Visual Studio Code plugin, your database will be automatically upgraded to the latest format and will no longer open in previous SDK versions. If this will cause issues, then make a copy of the database folder before opening it with the plugin.

CRUD operations on Couchbase Lite documents

For example, you can read the contents of a document as JSON:

Read documents in a Couchbase Lite database in VSCode

If needed, you can edit the document you just opened and save it back:

Edit documents using VSCode and Couchbase Lite

Querying a Couchbase Mobile database

If you want to run some queries on your database, that is also possible. Right click on a database and select the option to create a new query and then once you have written the query to your liking, use the command palette (or shortcut Ctrl + Shift + Q) to run it:

Execute Couchbase Lite database queries in VSCode

Summary

These are simple actions but provide a lot of power to the user! This plugin is still new and has a chance to expand in new directions, but I believe this is an excellent introduction to Couchbase Lite databases outside of the context of Couchbase Lite itself. 

The plugin is open source and can be found on GitHub. It is written in Typescript and leverages the Couchbase Lite C SDK, launched with Couchbase Mobile 3. The build instructions require downloading the C library but other than that, they are very straightforward. Inside the repo there is the plugin itself, along with the TypeScript bindings used to call into the C library. 

More Resources

  • Check out the video session that previews the SQL++ query API support in Couchbase Lite and demonstrates its usage with the plugin.
  • Download and try Couchbase Lite for free.
  • Reach out via dev forums with further questions or post requests on the repo itself.

Happy database exploring!

 

Author

Posted by Jim Borden, Principal Software Engineer, Couchbase

Principal Software Engineer @ Couchbase working on Couchbase Lite.

Leave a reply