Skip to main content
Product Updates

Kashoo Gives Back By Releasing Open-Source Tool For Sync

By July 19, 2016December 1st, 2023No Comments

This post is a bit of a departure from the usual fare on our blog, but if you are interested in some of the more technical aspects of what goes into building the software at Kashoo, then read on!

Kashoo-Cloud-Accounting-Synctos800.jpeg

Giving Back to the Community

Like many other successful software organizations, we at Kashoo use a lot of open source software to do what we do. It can be found in much of the code that we write, and in many of the tools that we use on a daily basis. At its core, open source is all about sharing ideas to make everyone’s life a little bit better. As a result, we feel a certain amount of obligation to give something back to the community to even the score a little.

One of the open source technology stacks that has seen increasing use here is the NoSQL database Couchbase Server and its client-side companion Couchbase Mobile. A critical component in that stack is Sync Gateway, which allows clients on iOS, Android, and other platforms to synchronize data with the server. Sync Gateway requires the definition of a sync function that controls what data can be stored and who has access to it. Now, after more than a year of working with these stellar products, we have refined our process for writing sync functions to the point that it can be distributed as a free and open source (MIT licensed) utility called Synctos.

So What Is Synctos?

Synctos is a commandline tool, distributed via npm that makes it possible to define a Sync Gateway database’s documents in a straightforward declarative JavaScript format. It drastically reduces the amount of (and in many cases, eliminates altogether) boilerplate code needed to comprehensively validate a document’s contents and permissions. If a document ever fails validation for some reason, the error messages that are returned to the client are full of details that make it easy to find the problem. It also includes a test helper module that can be used when writing test cases for document definitions to ensure document contents are validated correctly.

For instance, you will no longer have to write pages and pages of logic to validate each of the properties for each of the documents that exist in a Sync Gateway database. Instead, you can create a document definitions object that declares its constraints; please see the following example:

{
notificationTransportProcessingSummary: {
channels: {
write: ‘SERVICE’
},
typeFilter: function(doc, oldDoc) {
return doc.type === ‘notificationTransportProcessingSummary’;                   },
propertyValidators: {
processedBy: {
type: ‘string’,
immutable: true
},
processedAt: {
type: ‘datetime’,
required: true,
immutable: true
},
sentAt: {
type: ‘datetime’
},
type: {
type: ‘string’,
required: true,
mustNotBeEmpty: true,
immutable: true
}
}
}
}

Looking for more info? You can find plenty of documentation and the source code for the project on GitHub and npm.

Close Menu