From 6d5745f8b6f381762c40a0c9c6d4556eabd870ac Mon Sep 17 00:00:00 2001 From: Tetsuo Seto Date: Thu, 6 Apr 2017 11:44:49 -0700 Subject: [PATCH] Add generateUniqueId prototype --- lib/connector.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/connector.js b/lib/connector.js index 66177f9..00020cb 100644 --- a/lib/connector.js +++ b/lib/connector.js @@ -54,6 +54,20 @@ Connector.prototype.getDefaultIdType = function(prop) { return String; }; +/** + * Generate random id. Each data source model must override this method. + * @param {String} modelName Model name + * @returns {} Data type varies from model to model, + */ + +Connector.prototype.generateUniqueId = function(modelName) { + var idType = this.getDefaultIdType && this.getDefaultIdType(); + var isTypeFunction = (typeof idType === 'function'); + var id = this.generateValueByColumnType ? this.generateValueByColumnType(idType) : + (typeof idType === 'function' ? idType() : null); + return id; +}; + /** * Get the metadata for the connector * @returns {Object} The metadata object