Add discover methods for model names and properties
This commit is contained in:
parent
ad1b2ad7e9
commit
5620be1d57
|
@ -10,3 +10,4 @@ analyse.r
|
|||
docs/html
|
||||
docs/man
|
||||
npm-debug.log
|
||||
.project
|
||||
|
|
|
@ -360,6 +360,43 @@ Schema.prototype.autoupdate = function (cb) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Discover existing database tables.
|
||||
* This method returns an array of model objects, including {type, name, onwer}
|
||||
*
|
||||
* @param options An object that contains the following settings:
|
||||
* all: true - Discovering all models, false - Discovering the models owned by the current user
|
||||
* views: true - Including views, false - only tables
|
||||
* limit: The page size
|
||||
* offset: The starting index
|
||||
*/
|
||||
Schema.prototype.discoverModels = function (options, cb) {
|
||||
this.freeze();
|
||||
if (this.adapter.discoverModels) {
|
||||
this.adapter.discoverModels(options, cb);
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Discover properties for a given model.
|
||||
* @param options An object that contains the following settings:
|
||||
* model: The model name
|
||||
* limit: The page size
|
||||
* offset: The starting index
|
||||
* The method return an array of properties, including {owner, tableName, columnName, dataType, dataLength, nullable}
|
||||
*/
|
||||
Schema.prototype.discoverModelProperties = function (options, cb) {
|
||||
this.freeze();
|
||||
if (this.adapter.discoverModelProperties) {
|
||||
this.adapter.discoverModelProperties(options, cb);
|
||||
} else if (cb) {
|
||||
cb();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Check whether migrations needed
|
||||
* This method make sense only for sql adapters.
|
||||
|
|
Loading…
Reference in New Issue