Return a Q promise from all async DB methods

With send() removed from Q, we can yield Q promises within
executeTransaction() instead of Mozilla promises.
This commit is contained in:
Dan Stillman 2013-03-28 19:20:34 -04:00
parent 957b649fa8
commit a2816a10ca

View file

@ -796,10 +796,10 @@ Zotero.DBConnection.prototype.getNextName = function (table, field, name)
//
// // Optional, but necessary to pass 'rows' on to the next handler
// Zotero.DB.asyncResult(rows);
// )
// then(function (rows) {
// })
// .then(function (rows) {
// // rows == same as above
// )
// })
// .done();
//
/**
@ -809,12 +809,10 @@ Zotero.DBConnection.prototype.getNextName = function (table, field, name)
* pass a result by calling asyncResult(val) at the end
*/
Zotero.DBConnection.prototype.executeTransaction = function (func) {
return Q(
this._getConnectionAsync()
return this._getConnectionAsync()
.then(function (conn) {
return conn.executeTransaction(func);
})
);
});
};
@ -952,7 +950,7 @@ Zotero.DBConnection.prototype.asyncResult = function (val) {
*/
Zotero.DBConnection.prototype._getConnectionAsync = function () {
if (this._connectionAsync) {
return this.Promise.resolve(this._connectionAsync);
return Q(this._connectionAsync);
}
var db = this._getDBConnection();
@ -961,11 +959,11 @@ Zotero.DBConnection.prototype._getConnectionAsync = function () {
};
var self = this;
Zotero.debug("Asynchronously opening DB connection");
return this.Sqlite.openConnection(options)
return Q(this.Sqlite.openConnection(options)
.then(function(conn) {
self._connectionAsync = conn;
return conn;
});
}));
};