Skip to content

couchapp plus backbone-boilerplate and Syncpoint-created db support

Notifications You must be signed in to change notification settings

chrisekelley/couchabb

Repository files navigation

Couchabb

Couchabb is a demonstration Couchapp used in Andromeda, which demonstrates how to manage the user registration and management process using TouchDB-Android and Syncpoint-Android.

Couchabb is a demonstration of the TodoMVC backbone-require app, which has been modified to work as a Backbone boilerplate project. The TodoMVC project serves as a demonstration of popular javascript MV* frameworks. I am using TodoMVC as a generic project called couchabb to help assess TouchDB-Android performance. Couchabb also uses backbone boilerplate.

Supports two Couch databases.

Couchabb is designed to work initially with the original bootstrap db - the db that was initially installed. (It may have been named couchabb.) When the user registers an e-mail address, the Syncpoint library creates a new local db that has a unique name. In main.js, the app checks if the Syncpoint control database has been create and queries it (/sp_control/_design/control/_view/by_type?key=%22installation%22) for the new local db name. That name becomes the Backbone.couch_connector.config.db_name and is used by the app instead of the original db.

Generated by CouchApp

CouchApps are web applications which can be served directly from CouchDB. This gives them the nice property of replicating just like any other data stored in CouchDB. They are also simple to write as they can use the built-in jQuery libraries and plugins that ship with CouchDB.

More info about CouchApps here.

Deploying this app

Assuming you just cloned this app from git, and you have changed into the app directory in your terminal, you want to push it to your CouchDB with the CouchApp command line tool, like this:

couchapp push . http:https://name:password@hostname:5984/mydatabase

If you don't have a password on your CouchDB (admin party) you can do it like this (but it's a bad, idea, set a password):

couchapp push . http:https://hostname:5984/mydatabase

If you get sick of typing the URL, you should setup a .couchapprc file in the root of your directory. Remember not to check this into version control as it will have passwords in it.

The .couchapprc file should have contents like this:

{
  "env" : {
    "public" : {
      "db" : "http:https://name:[email protected]/mydatabase"
    },
    "default" : {
      "db" : "http:https://name:pass@localhost:5984/mydatabase"
    }
  }
}

Now that you have the .couchapprc file set up, you can push your app to the CouchDB as simply as:

couchapp push

This pushes to the default as specified. To push to the public you'd run:

couchapp push public

Of course you can continue to add more deployment targets as you see fit, and give them whatever names you like.

Other useful info

It's a pain to run 'couchapp push' everytime you make a change. Mike wrote a little watchr script that watches for changes to any relevant files and then automatically pushes them into your couch. To get it you need to install rubygems and watchr:

apt-get install rubygems
gem install watchr

To run it, just

watchr file.watchr    

About

couchapp plus backbone-boilerplate and Syncpoint-created db support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published