1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | 'use strict';
|
7 |
|
8 | const path = require('path'),
|
9 | fs = require('fs'),
|
10 | DataSource = require('../lib/datasource').DataSource;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function loadSchemasSync(schemaFile, dataSource) {
|
18 |
|
19 | if (!dataSource) {
|
20 | dataSource = new DataSource('memory');
|
21 | }
|
22 |
|
23 |
|
24 | const schemas = JSON.parse(fs.readFileSync(schemaFile));
|
25 |
|
26 | return dataSource.buildModels(schemas);
|
27 | }
|
28 |
|
29 | let models = loadSchemasSync(path.join(__dirname, 'jdb-schemas.json'));
|
30 |
|
31 | for (const s in models) {
|
32 | const m = models[s];
|
33 | console.log(m.modelName, new m());
|
34 | }
|
35 |
|
36 | models = loadSchemasSync(path.join(__dirname, 'schemas.json'));
|
37 | for (const s in models) {
|
38 | const m = models[s];
|
39 | console.log(m.modelName, new m());
|
40 | }
|