commit
cc8809a230
|
@ -13,3 +13,6 @@
|
|||
node_modules
|
||||
checkstyle.xml
|
||||
loopback-connector-*.tgz
|
||||
!intl/
|
||||
intl/*
|
||||
!intl/en/
|
3
index.js
3
index.js
|
@ -3,6 +3,9 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var SG = require('strong-globalize');
|
||||
SG.SetRootDir(__dirname);
|
||||
|
||||
exports.Connector = require('./lib/connector');
|
||||
// Set up SqlConnector as an alias to SQLConnector
|
||||
exports.SQLConnector = exports.SqlConnector = require('./lib/sql');
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"8dc8fd7cc38a39896c03663cca38aad5": "execute() must be implemented by the connector",
|
||||
"06c539e08213828e62e7f5339fb255ec": "{{getPlaceholderForValue()}} must be implemented by the connector",
|
||||
"2b051e39b1efd1f2106b155495087b0f": "id value is required",
|
||||
"30a4fa7fc115109b8cd096d895e9869e": "{{getPlaceholderForIdentifier()}} must be implemented by the connector",
|
||||
"4cbf9bb7e7347b86c1dba4e54163c4ea": "{{getCountForAffectedRows()}} must be implemented by the connector",
|
||||
"871b10e82a2dc1d0659571c5dee8fa95": "{{executeSQL()}} must be implemented by the connector",
|
||||
"956ede286087599213bc112b5a76408b": "{{applyPagination()}} must be implemented by the connector",
|
||||
"bca74e4fbb2859c22381fb531a0f896d": "{{getInsertedId()}} must be implemented by the connector",
|
||||
"c491cd5577a54bf265d407ddaa20ffcb": "{{escapeValue()}} must be implemented by the connector",
|
||||
"e54d944c2a2c85a23caa86027ae307cf": "Cannot migrate models not attached to this datasource: {0}",
|
||||
"f3e021460b7a6f5991fca890b786a11b": "{{escapeName()}} must be implemented by the connector",
|
||||
"fe1c27354af9f4c88bf9c1d246e41230": "{{toColumnValue()}} must be implemented by the connector",
|
||||
"fe914555563f5f566adfc0c5db8445db": "{{fromColumnValue()}} must be implemented by the connector"
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var SG = require('strong-globalize');
|
||||
var g = SG();
|
||||
var debug = require('debug')('loopback:connector');
|
||||
|
||||
module.exports = Connector;
|
||||
|
@ -80,7 +82,7 @@ Connector.prototype.getMetadata = function() {
|
|||
* @param {Function} [callback] The callback function
|
||||
*/
|
||||
Connector.prototype.execute = function(command, params, options, callback) {
|
||||
throw new Error('execute() must be implemented by the connector');
|
||||
throw new Error(g.f('execute() must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
32
lib/sql.js
32
lib/sql.js
|
@ -3,6 +3,9 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var SG = require('strong-globalize');
|
||||
var g = SG();
|
||||
|
||||
var util = require('util');
|
||||
var async = require('async');
|
||||
var assert = require('assert');
|
||||
|
@ -1229,7 +1232,7 @@ Connector.defineAliases(SQLConnector.prototype, 'all', ['findAll']);
|
|||
SQLConnector.prototype.find = function(model, id, options, cb) {
|
||||
if (id == null) {
|
||||
process.nextTick(function() {
|
||||
var err = new Error('id value is required');
|
||||
var err = new Error(g.f('id value is required'));
|
||||
if (cb) {
|
||||
cb(err);
|
||||
}
|
||||
|
@ -1329,8 +1332,8 @@ SQLConnector.prototype.automigrate = function(models, cb) {
|
|||
});
|
||||
if (invalidModels.length) {
|
||||
return process.nextTick(function() {
|
||||
cb(new Error('Cannot migrate models not attached to this datasource: ' +
|
||||
invalidModels.join(' ')));
|
||||
cb(new Error(g.f('Cannot migrate models not attached to this datasource: %s',
|
||||
invalidModels.join(' '))));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1401,7 @@ SQLConnector.prototype.escapeObject = function(obj) {
|
|||
*
|
||||
*/
|
||||
SQLConnector.prototype.toColumnValue = function(propertyDef, value) {
|
||||
throw new Error('toColumnValue() must be implemented by the connector');
|
||||
throw new Error(g.f('{{toColumnValue()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1408,7 +1411,7 @@ SQLConnector.prototype.toColumnValue = function(propertyDef, value) {
|
|||
* @returns {*} Model property value
|
||||
*/
|
||||
SQLConnector.prototype.fromColumnValue = function(propertyDef, value) {
|
||||
throw new Error('fromColumnValue() must be implemented by the connector');
|
||||
throw new Error(g.f('{{fromColumnValue()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1417,7 +1420,7 @@ SQLConnector.prototype.fromColumnValue = function(propertyDef, value) {
|
|||
* @returns {String} An escaped name for SQL
|
||||
*/
|
||||
SQLConnector.prototype.escapeName = function(name) {
|
||||
throw new Error('escapeName() must be implemented by the connector');
|
||||
throw new Error(g.f('{{escapeName()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1426,7 +1429,7 @@ SQLConnector.prototype.escapeName = function(name) {
|
|||
* @returns {*} An escaped value for SQL
|
||||
*/
|
||||
SQLConnector.prototype.escapeValue = function(value) {
|
||||
throw new Error('escapeValue() must be implemented by the connector');
|
||||
throw new Error(g.f('{{escapeValue()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1435,7 +1438,8 @@ SQLConnector.prototype.escapeValue = function(value) {
|
|||
* @returns {String} The place holder
|
||||
*/
|
||||
SQLConnector.prototype.getPlaceholderForIdentifier = function(key) {
|
||||
throw new Error('getPlaceholderForIdentifier() must be implemented by the connector');
|
||||
throw new Error(g.f('{{getPlaceholderForIdentifier()}} must be implemented by ' +
|
||||
'the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1444,7 +1448,8 @@ SQLConnector.prototype.getPlaceholderForIdentifier = function(key) {
|
|||
* @returns {String} The place holder
|
||||
*/
|
||||
SQLConnector.prototype.getPlaceholderForValue = function(key) {
|
||||
throw new Error('getPlaceholderForValue() must be implemented by the connector');
|
||||
throw new Error(g.f('{{getPlaceholderForValue()}} must be implemented by ' +
|
||||
'the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1454,7 +1459,7 @@ SQLConnector.prototype.getPlaceholderForValue = function(key) {
|
|||
* @param {Object} filter The filter object from the query
|
||||
*/
|
||||
SQLConnector.prototype.applyPagination = function(model, stmt, filter) {
|
||||
throw new Error('applyPagination() must be implemented by the connector');
|
||||
throw new Error(g.f('{{applyPagination()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1465,7 +1470,8 @@ SQLConnector.prototype.applyPagination = function(model, stmt, filter) {
|
|||
* @returns {Number} Number of rows affected
|
||||
*/
|
||||
SQLConnector.prototype.getCountForAffectedRows = function(model, info) {
|
||||
throw new Error('getCountForAffectedRows() must be implemented by the connector');
|
||||
throw new Error(g.f('{{getCountForAffectedRows()}} must be implemented by ' +
|
||||
'the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1475,7 +1481,7 @@ SQLConnector.prototype.getCountForAffectedRows = function(model, info) {
|
|||
* @returns {*} The inserted id value
|
||||
*/
|
||||
SQLConnector.prototype.getInsertedId = function(model, info) {
|
||||
throw new Error('getInsertedId() must be implemented by the connector');
|
||||
throw new Error(g.f('{{getInsertedId()}} must be implemented by the connector'));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1486,5 +1492,5 @@ SQLConnector.prototype.getInsertedId = function(model, info) {
|
|||
* @param {Function} [callback] The callback function
|
||||
*/
|
||||
SQLConnector.prototype.executeSQL = function(sql, params, options, callback) {
|
||||
throw new Error('executeSQL() must be implemented by the connector');
|
||||
throw new Error(g.f('{{executeSQL()}} must be implemented by the connector'));
|
||||
};
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"async": "^1.0.0",
|
||||
"debug": "^2.2.0"
|
||||
"debug": "^2.2.0",
|
||||
"strong-globalize": "^2.5.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~2.3.0",
|
||||
|
|
Loading…
Reference in New Issue