Update column type info
This commit is contained in:
parent
6255da2ae0
commit
d9998d8294
|
@ -563,6 +563,24 @@ DataSource.prototype.columnName = function (modelName, propertyName) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return column metadata for specified modelName and propertyName
|
||||
* @param modelName
|
||||
* @param propertyName
|
||||
* @returns {Object} column metadata
|
||||
*/
|
||||
DataSource.prototype.columnMetadata = function (modelName, propertyName) {
|
||||
if(!propertyName) {
|
||||
return propertyName;
|
||||
}
|
||||
var property = this.definitions[modelName].properties[propertyName];
|
||||
if(property && property[this.adapter.name]) {
|
||||
return property[this.adapter.name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return column names for specified modelName
|
||||
* @param modelName
|
||||
|
|
24
lib/jutil.js
24
lib/jutil.js
|
@ -1,15 +1,25 @@
|
|||
var util = require('util');
|
||||
/**
|
||||
*
|
||||
* @param newClass
|
||||
* @param baseClass
|
||||
*/
|
||||
exports.inherits = function (newClass, baseClass) {
|
||||
Object.keys(baseClass).forEach(function (classProp) {
|
||||
newClass[classProp] = baseClass[classProp];
|
||||
});
|
||||
Object.keys(baseClass.prototype).forEach(function (instanceProp) {
|
||||
newClass.prototype[instanceProp] = baseClass.prototype[instanceProp];
|
||||
});
|
||||
exports.inherits = function (newClass, baseClass, options) {
|
||||
util.inherits(newClass, baseClass);
|
||||
|
||||
options = options || {
|
||||
staticProperties: true,
|
||||
override: false
|
||||
};
|
||||
|
||||
if (options.staticProperties) {
|
||||
Object.keys(baseClass).forEach(function (classProp) {
|
||||
if (classProp !== 'super_' && (!newClass.hasOwnProperty(classProp) || options.override)) {
|
||||
var pd = Object.getOwnPropertyDescriptor(baseClass, classProp);
|
||||
Object.defineProperty(newClass, classProp, pd);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
10
lib/sql.js
10
lib/sql.js
|
@ -63,6 +63,16 @@ BaseSQL.prototype.column = function (model, property) {
|
|||
return name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the column name for given model property
|
||||
* @param model The model name
|
||||
* @param property The property name
|
||||
* @returns {Object} The column metadata
|
||||
*/
|
||||
BaseSQL.prototype.columnMetadata = function (model, property) {
|
||||
return this.dataSource(model).columnMetadata(model, property);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the corresponding property name for a given column name
|
||||
* @param model The model name
|
||||
|
|
Loading…
Reference in New Issue