Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added adapter configuration info to guide. #536

Merged
merged 1 commit into from

2 participants

@flyswatter

No description provided.

@flyswatter

Addresses #535 incompletely (mySQL and others' configuration not displayed because I don't know them).

@flyswatter flyswatter closed this
@flyswatter flyswatter reopened this
@mde mde merged commit d1d2dbe into from
@mde
Owner
mde commented

This is awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 5, 2014
  1. Added adapter configuration info to guide.

    Dan Finlay authored
This page is out of date. Refresh to see the latest.
Showing with 68 additions and 0 deletions.
  1. +68 −0 docs/guide/models.md
View
68 docs/guide/models.md
@@ -723,6 +723,74 @@ if (!someTeam.players) {
}
```
+#### Adapters
+
+You can specify a different adapter for each model or apply the same adapter to all models.
+
+An adapter is added to a specific model like this:
+
+```javascript
+var adapter = model.createAdapter('postgres', {
+ host: 'localhost',
+ username: 'user',
+ password: 'password',
+ dbname: 'mydb'
+});
+
+model.User.adapter = adapter;
+model.Zerb.adapter = adapter;
+```
+
+You can also define a defaultAdapter which will be used by default.
+Then you can override it on individual models.
+
+```javascript
+model.defaultAdapter = model.createAdapter('memory');
+
+var postgresAdapter = model.createAdapter('postgres', {
+ host: 'localhost',
+ username: 'user',
+ password: 'password',
+ dbname: 'mydb'
+});
+
+// User model gets the defaultAdapter
+model.Zerb.adapter = postgresAdapter;
+```
+
+If using Geddy, the default adapter can be configured by environment in the `/config` folder. For example, to use the filesystem for development, in `/config/development.js` you might write:
+
+```
+var config = {
+ appName: 'Geddy App (development)'
+, model: {
+ defaultAdapter: 'filesystem'
+ }
+};
+module.exports = config;
+```
+On the other hand, if you wanted to use postgres in production, you might edit `config/production.js` to say:
+```
+var config = {
+ appName: 'Geddy App (development)'
+, model: {
+ defaultAdapter: 'postgres'
+ }
+, db: {
+ postgresql: {
+ port:5432,
+ password:'yourPasswordHere',
+ database:'databaseName',
+ host:'localhost',
+ user:'yourUserName'
+ }
+}
+};
+
+module.exports = config;
+```
+(I've left out non-related configuration fields).
+
#### Migrations (SQL adapters only)
Migrations are a convenient way to make changes to your SQL database schema over
Something went wrong with that request. Please try again.