2016-05-03 23:52:03 +00:00
|
|
|
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback-connector-mysql
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-08-10 18:41:03 +00:00
|
|
|
'use strict';
|
2013-07-30 21:21:10 +00:00
|
|
|
var DataSource = require('loopback-datasource-juggler').DataSource;
|
2013-07-21 17:36:26 +00:00
|
|
|
|
2013-08-23 21:31:43 +00:00
|
|
|
var config = require('rc')('loopback', {dev: {mysql: {}}}).dev.mysql;
|
2013-08-22 04:53:48 +00:00
|
|
|
|
|
|
|
var ds = new DataSource(require('../'), config);
|
2013-07-21 17:36:26 +00:00
|
|
|
|
|
|
|
function show(err, models) {
|
2014-02-13 00:57:06 +00:00
|
|
|
if (err) {
|
|
|
|
console.error(err);
|
|
|
|
} else {
|
|
|
|
console.log(models);
|
|
|
|
if (models) {
|
2016-08-10 18:41:03 +00:00
|
|
|
models.forEach(function(m) {
|
2014-02-13 00:57:06 +00:00
|
|
|
console.dir(m);
|
|
|
|
});
|
2013-07-21 17:36:26 +00:00
|
|
|
}
|
2014-02-13 00:57:06 +00:00
|
|
|
}
|
2013-07-21 17:36:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ds.discoverModelDefinitions({views: true, limit: 20}, show);
|
|
|
|
|
2013-10-08 20:44:37 +00:00
|
|
|
ds.discoverModelProperties('customer', show);
|
2013-07-21 17:36:26 +00:00
|
|
|
|
2013-10-08 20:44:37 +00:00
|
|
|
ds.discoverModelProperties('location', {owner: 'strongloop'}, show);
|
2013-07-21 17:36:26 +00:00
|
|
|
|
2013-10-08 20:44:37 +00:00
|
|
|
ds.discoverPrimaryKeys('customer', show);
|
2014-02-13 00:57:06 +00:00
|
|
|
ds.discoverForeignKeys('inventory', show);
|
2013-07-21 17:36:26 +00:00
|
|
|
|
2014-02-13 00:57:06 +00:00
|
|
|
ds.discoverExportedForeignKeys('location', show);
|
2013-07-21 17:36:26 +00:00
|
|
|
|
2016-08-10 18:41:03 +00:00
|
|
|
ds.discoverAndBuildModels('weapon', {owner: 'strongloop', visited: {}, associations: true}, function(err, models) {
|
2014-02-13 00:57:06 +00:00
|
|
|
for (var m in models) {
|
|
|
|
models[m].all(show);
|
|
|
|
}
|
2013-07-21 17:36:26 +00:00
|
|
|
});
|