2017-10-31 23:09:36 -04:00
|
|
|
const Database = AbstractClass( 'Database',
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
2017-10-31 23:09:36 -04:00
|
|
|
'public connect'( user, pass )
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
if ( !( this.authenticate( user, pass ) ) )
|
|
|
|
{
|
|
|
|
throw Error( "Authentication failed." );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// abstract methods define arguments as an array of strings
|
|
|
|
'abstract protected authenticate': [ 'user', 'pass' ],
|
|
|
|
} );
|
|
|
|
|
2017-10-31 23:09:36 -04:00
|
|
|
const MongoDatabase = Class( 'MongoDatabase' )
|
2012-05-05 14:09:27 -04:00
|
|
|
.extend( Database,
|
|
|
|
{
|
|
|
|
// must implement each argument for Database.authenticate()
|
2017-10-31 23:09:36 -04:00
|
|
|
'protected authenticate'( user, pass )
|
2012-05-05 14:09:27 -04:00
|
|
|
{
|
|
|
|
// ...
|
|
|
|
},
|
|
|
|
} );
|