@ -513,40 +513,50 @@ class Xsql {
for ( var tableName in this . metaDb . tables ) {
let routes = [ ]
let tableObj = { }
let table = this . metaDb . tables [ tableName ] ;
tableObj [ 'resource' ] = tableName ;
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/describe' , 'describe' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/count' , 'count' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/groupby' , 'groupby' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/ugroupby' , 'ugroupby' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/chart' , 'chart' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/aggregate' , 'aggregate' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/findOne' , 'findOne' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName , 'create' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName , 'list' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName + '/bulk' , 'bulkInsert' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/bulk' , 'bulkRead' ) )
routes . push ( this . prepareRoute ( internal , 'delete' , apiPrefix , tableName + '/bulk' , 'bulkDelete' ) )
routes . push ( this . prepareRoute ( internal , 'put' , apiPrefix , tableName , 'update' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/:id' , 'read' ) )
routes . push ( this . prepareRoute ( internal , 'patch' , apiPrefix , tableName + '/:id' , 'patch' ) )
routes . push ( this . prepareRoute ( internal , 'delete' , apiPrefix , tableName + '/:id' , 'delete' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/:id/exists' , 'exists' ) )
for ( var j = 0 ; j < table [ 'foreignKeys' ] . length ; ++ j ) {
let fk = table [ 'foreignKeys' ] [ j ]
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , fk [ 'referenced_table_name' ] + '/:id/' + fk [ 'table_name' ] , 'relational' ) )
}
if ( tableName in this . sqlConfig . ignoreTables ) {
//console.log('ignore table', tableName);
} else {
tableObj [ 'routes' ] = routes ;
let routes = [ ]
let tableObj = { }
let table = this . metaDb . tables [ tableName ] ;
tableObj [ 'resource' ] = tableName ;
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/describe' , 'describe' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/count' , 'count' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/groupby' , 'groupby' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/ugroupby' , 'ugroupby' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/chart' , 'chart' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/aggregate' , 'aggregate' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/findOne' , 'findOne' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName , 'create' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName , 'list' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName + '/bulk' , 'bulkInsert' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/bulk' , 'bulkRead' ) )
routes . push ( this . prepareRoute ( internal , 'delete' , apiPrefix , tableName + '/bulk' , 'bulkDelete' ) )
routes . push ( this . prepareRoute ( internal , 'put' , apiPrefix , tableName , 'update' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/:id' , 'read' ) )
routes . push ( this . prepareRoute ( internal , 'patch' , apiPrefix , tableName + '/:id' , 'patch' ) )
routes . push ( this . prepareRoute ( internal , 'delete' , apiPrefix , tableName + '/:id' , 'delete' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/:id/exists' , 'exists' ) )
for ( var j = 0 ; j < table [ 'foreignKeys' ] . length ; ++ j ) {
let fk = table [ 'foreignKeys' ] [ j ]
if ( fk [ 'referenced_table_name' ] in this . sqlConfig . ignoreTables ) {
//console.log('ignore table',fk['referenced_table_name']);
} else {
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , fk [ 'referenced_table_name' ] + '/:id/' + fk [ 'table_name' ] , 'relational' ) )
}
schemaRoutes . push ( tableObj ) ;
}
tableObj [ 'routes' ] = routes ;
schemaRoutes . push ( tableObj ) ;
}
}
return schemaRoutes ;