Skip to content
Paul Mietz Egli edited this page Aug 26, 2014 · 10 revisions

How do I install the module?

Download the latest module builds from the Releases section of the project, then follow the instructions on the Home page of the wiki.

Doesn't Couchbase already provide a Titanium module?

Yes, that module can be found here. The two projects are completely independent, though they share a common goal of making it easy to use Couchbase Mobile in Titanium apps.

Why don't I see any results when I use descending: true and startKey/endKey in my query options?

When you use descending: true in combination with start and end keys, you need to flip the values of the startKey and endKey query options.

Oh noes! SystemExit: 65 when I try to build my project!

The "SystemExit: 65" error means that your Titanium project ran into a problem when trying to run the xcodebuild command. The actual build problem can be found near the end of the build/iphone/build/build.log file under your project home directory. In the current version of the module, the most common problem is one or more linker errors that reference "armv6". If you get that error, verify that you changed your Titanium SDK project templates like it said to do on the usage instructions?

"Module not found: com.obscure.titouchdb"

If you installed the module properly and still get this error, clean and rebuild your project.

Apple rejected my app because I'm storing too much data in iCloud.

The TiTouchDB module uses the default location for the Couchbase Mobile database file and attachments, which is <Application Home>/Library/Application Support/CouchbaseLite. According to Apple's Performance Tuning documentation, files located under the Library/Application Support directory will be backed up to iCloud unless the app specifically tells the OS to not to include them in the backup. If you don't need iCloud backup of your TiTouchDB database, you can set the excludedFromBackup property on the DatabaseManager object to false.

How do I bundle a preloaded database with my app?

First, you need to generate the database in Couchbase Mobile format. The Couchbase docs describe how this can be done. Place the .cblite file and the attachments directory (if you are using attachments) in the assets folder of your Titanium project and use the DatabaseManager.replaceDatabase() function to install the preloaded copy. For example, here's how to install a database named "elements" that is stored in assets/CouchbaseLite:

var basedir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'assets', 'CouchbaseLite').path;
var dbfile = [basedir, 'elements.cblite'].join(Ti.Filesystem.separator);
var attdir = [basedir, 'elements attachments'].join(Ti.Filesystem.separator);
if (manager.replaceDatabase('elements', dbfile, attdir)) {
  return manager.getExistingDatabase('elements');
}

How to I provide authentication credentials when replicating to and from a CouchDB server?

Push and pull replication objects contain an authenticator property that controls server authentication. The module object provides three methods for generating authenticator objects:

  • createBasicAuthenticator
  • createFacebookAuthenticator
  • createPersonaAuthenticator

Example:

var titouchdb = require('com.obscure.titouchdb')
var push = db.createPushReplication("http://example.com/mydb");
push.authenticator = titouchdb.createBasicAuthenticator("scott", "tiger");

Need secure storage for the username and password? Consider using my keychain module.

The following answer is deprecated as of version 1.0.3

Starting with version 1.0, use the setCredentials() method of the replication as follows:

var pull = db.createPullReplication('myfunkycouchdb.iriscouch.com/music');
pull.setCredentials({ user: 'scott', pass: 'tiger' });

HTTP Basic authentication is also supported by adding the username and password to the replication URL:

var pullReplication = db.pullFromURL('http://scott:[email protected]/music');

For security reasons, you should use HTTPS for authenticated replication if you server supports it.