尝试将 Q Promise 库与 couchDB 和 Nano 一起使用。我有以下代码,消息显示在控制台中,但未创建数据库。
var nano = require('nano')('http://localhost:5984');
var Q = require('q');
var deleteDB = function(database) {
console.log('deleteDB');
var deferred = Q.defer();
nano.db.destroy('alice', deferred.resolve);
return deferred.promise;
};
var createDB = function(database) {
console.log('createDB');
var deferred = Q.defer();
nano.db.create('alice', deferred.resolve);
return deferred.promise;
}
deleteDB('promises').then(createDB('promises'));
有谁知道为什么这不起作用?