@@ -38,22 +38,30 @@ exports.createDatabase = function createDatabase (options, callback) {
3838 options [ 'plan' ] = 'free' ;
3939 }
4040
41+ // We have to setup the correct prefix for database name
42+ // for the moment we use the 'owner' field because we expect the correct prefix there.
43+ var databaseName = [ options [ 'owner' ] , options [ 'name' ] ] . join ( '_' ) ;
44+
4145 // Setup the account name according mongolab API.
42- var account = [ this . config . username , options [ 'owner' ] ] . join ( '_' ) ;
46+ // @todo We need a helper function for add the prefix if its necesary
47+ //var account = [this.config.username, options['owner']].join('_');
48+ var account = options [ 'owner' ] // at the moment we need provide the username with the prefix (partner name)
4349
4450 var createOptions = {
4551 method : 'POST' ,
4652 path : 'accounts/' + account + '/databases' ,
4753 body : {
48- name : options [ 'name' ] ,
54+ name : databaseName ,
4955 plan : options [ 'plan' ] ,
50- username : options [ 'owner' ]
56+ username : options [ 'owner' ] ,
57+ // In future we will have to change this for support multiples clouds and user-selected cloud.
58+ cloud : this . config . cloud
5159 }
5260 }
5361
5462 this . request ( createOptions , callback , function ( body , response ) {
55- // Work in progress here .
56- // We need create the owner account before create any database.
63+ // @todo : We need to parse the response instantiating a Database class, and pass it to callback .
64+ return callback ( null , body ) ;
5765 } ) ;
5866} ;
5967
0 commit comments