codeswarm / sails-couchdb-orm

CouchDB Adapter for the Sails.js ORM Framework, Waterline
36 stars 20 forks source link

Documentation does not include an example of what to put in `config/adapters.js` to get this working. #4

Closed chr15m closed 9 years ago

hoffmannmatheus commented 10 years ago

Using Sails.js version 0.10.0 here. In "config/connections.js" (since you have config/adapters, you are using a different version?), specify the adapter "couch":

  // CouchDB Adapter                                                             
  couch: {                                                                       
    adapter: 'sails-couchdb-orm',
    host: 'localhost',
    port: 5984,
    username: 'myuser',
    password: 'mypassword'                                 
  }

And in "models/MyModel.js", put the adapter to be used:

module.exports = {
  adapter: 'couch',
  migrate: 'safe',
  id: {
    primaryKey: true,
    type: 'string'
  },
  attributes: {
    name: 'string',
    //...
 }
}

Or, you could leave "couch" as the default adapter for all your models, inside "config/models.js", like:

module.exports.models = {
  connection: 'couch'
};
mikehostetler commented 10 years ago

Thanks, great idea.

I'll see what I can do to get this into the README