2

I had tried to connect CouchDB with Backbone in HTML but could not able to connect.

Can any one please provide me some samples on how to connect CouchDB with Backbone in HTML

Valentin Despa
  • 40,712
  • 18
  • 80
  • 106
Chinna
  • 71
  • 1
  • 4
  • You should be a bit more specific. Namely, from what host is your app being served? There are a couple of options: (a) an app that is served by the CouchDB server itself, and (b) an app that is served from some other httpd host. The best answer for you depends on your circumstances. – CSSian Nov 02 '13 at 05:57

2 Answers2

1

Have you taken a look at backbone.couch? Here's some examples from their documentation:

var Backbone = require('backbone');

// Create a new backbone-couch handler for a database 'documents'.
var couch = require('backbone-couch')({
    host: '127.0.0.1',
    port: '5984',
    name: 'documents'
});

// Create database, push default design documents to it and
// assign sync method to Backbone.
couch.install(function(err) {
    Backbone.sync = couch.sync;
});

// Backbone.sync will now load and save models from a 'documents' couch db.
garbados
  • 885
  • 5
  • 21
1

You 'connect' to couchDb through couchdb's REST api[1]. You would put the RESTful URLs in the Backbone model's URL and call them by overriding the sync method. This SO answer gives more detail on how this would work.[2]

[1] http://wiki.apache.org/couchdb/HTTP_Document_API

[2] How do I specify various URLs in a backbone app?

Community
  • 1
  • 1
John Moses
  • 1,283
  • 1
  • 12
  • 18