     
     del = ->
         (Q.async ->
-            db = yield Q.nfcall(database.getDb)
             utils.log 'Deleting main database.'
-            result = yield db.dropDatabase()
+            db = yield Q.nfcall database.getDb
+            result = yield Q.ninvoke(db, "dropDatabase")
             utils.log 'Everything is gone now.')()
 
     create = -> 

        req.write(data)

    req.end()        

init()



    if '--delete' in process.argv        
        (Q.async ->
            yield del()
            process.exit())()

    else if '--create' in process.argv
        (Q.async ->
            yield create()
            process.exit())()

    else if '--recreate' in process.argv
        (Q.async ->
            yield del()
            yield create()
            process.exit())()
    else
        utils.log 'Invalid option.'
        process.exit()  
