不要怂,就是干,撸起袖子干!

Commit 1743ffb1 by Willyham

Rename to useMaster

1 parent c1a38ec4
...@@ -121,9 +121,9 @@ ConnectionManager.prototype.initPools = function () { ...@@ -121,9 +121,9 @@ ConnectionManager.prototype.initPools = function () {
return self.pool.write.release(client); return self.pool.write.release(client);
} }
}, },
acquire: function(callback, priority, queryType, forceWrite) { acquire: function(callback, priority, queryType, useMaster) {
forceWrite = _.isUndefined(forceWrite) ? false : forceWrite; useMaster = _.isUndefined(useMaster) ? false : useMaster;
if (queryType === 'SELECT' && !forceWrite) { if (queryType === 'SELECT' && !useMaster) {
self.pool.read.acquire(callback, priority); self.pool.read.acquire(callback, priority);
} else { } else {
self.pool.write.acquire(callback, priority); self.pool.write.acquire(callback, priority);
...@@ -188,7 +188,7 @@ ConnectionManager.prototype.getConnection = function(options) { ...@@ -188,7 +188,7 @@ ConnectionManager.prototype.getConnection = function(options) {
self.pool.acquire(function(err, connection) { self.pool.acquire(function(err, connection) {
if (err) return reject(err); if (err) return reject(err);
resolve(connection); resolve(connection);
}, options.priority, options.type, options.forceWrite); }, options.priority, options.type, options.useMaster);
}); });
}; };
ConnectionManager.prototype.releaseConnection = function(connection) { ConnectionManager.prototype.releaseConnection = function(connection) {
......
...@@ -654,7 +654,7 @@ module.exports = (function() { ...@@ -654,7 +654,7 @@ module.exports = (function() {
* @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified * @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified
* @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row * @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row
* @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL. * @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL.
* @param {Boolean} [options.forceWrite=false] Force the query to use the write pool, regardless of the query type. * @param {Boolean} [options.useMaster=false] Force the query to use the write pool, regardless of the query type.
* *
* @return {Promise} * @return {Promise}
* *
......
...@@ -89,7 +89,7 @@ describe('Connction Manager', function() { ...@@ -89,7 +89,7 @@ describe('Connction Manager', function() {
var queryOptions = { var queryOptions = {
priority: 0, priority: 0,
type: 'SELECT', type: 'SELECT',
forceWrite: false useMaster: false
}; };
var _getConnection = _.bind(connectionManager.getConnection, connectionManager, queryOptions); var _getConnection = _.bind(connectionManager.getConnection, connectionManager, queryOptions);
...@@ -131,7 +131,7 @@ describe('Connction Manager', function() { ...@@ -131,7 +131,7 @@ describe('Connction Manager', function() {
var queryOptions = { var queryOptions = {
priority: 0, priority: 0,
type: 'SELECT', type: 'SELECT',
forceWrite: true useMaster: true
}; };
return connectionManager.getConnection(queryOptions) return connectionManager.getConnection(queryOptions)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!