Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 69 lines (62 sloc) 1.828 kb
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
1 # Using MongoLab with `pkgcloud`
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
2
0d9c11d @indexzero [doc] Final pass on documentation
indexzero authored
3 The MongoLab API has a slightly different approach for managing databases: they have implemented accounts, and each account can provision databases. **To create a database with MongoLab you will need first create an account and then use the created account as "owner" of the database.**
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
4
5 ``` js
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
6 //
7 // First lets set up the client
8 //
9 var client = pkgcloud.database.createClient({
10 provider: 'mongolab',
11 username: 'bob',
12 password: '1234'
13 });
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
14 ```
15
16 ``` js
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
17 //
18 // Now lets create an account
19 // name and email are required fields.
20 //
21 client.createAccount({
22 name:'daniel',
23 email:'daniel@nodejitsu.com',
24 //
25 // If you want, you can set your own password
26 // (Password must contain at least one numeric character.)
27 // if not mongolab will create a password for you.
28 //
29 password:'mys3cur3p4ssw0rd'
30 }, function (err, user) {
31 //
32 // Now you can provision databases under this user account
33 //
34 console.log(user);
35 });
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
36 ```
37
38 ``` js
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
39 //
40 // Now lets create a database
41 // name and owner are required fields
42 //
43 client.create({
44 name:'myDatabase',
45 //
46 // You need to put the exact name account returned in the account creation.
47 //
48 owner: user.account.username
49 }, function (err, database) {
50 //
51 // That is all
52 //
53 console.log(database);
54 });
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
55 ```
56
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
57 The `client` instance returned by `pkgcloud.database.createClient` has the following methods for MongoLab:
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
58
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
59 ## Accounts
60 * `client.createAccount(options, callback)`
61 * `client.getAccounts(callback)`
62 * `client.getAccount(name, callback)`
63 * `client.deleteAccount(name, callback)`
ac3cb04 @indexzero [refactor doc] Begin to break-apart README.md into more digestable conte...
indexzero authored
64
81166cb @indexzero [doc] Mostly formatting updates to documentation
indexzero authored
65 ## Databases
66 * `client.create(options, callback)`
67 * `client.getDatabases(owner, callback)`
68 * `client.getDatabase(options, callback)`
69 * `client.remove(options, callback)`
Something went wrong with that request. Please try again.