@ -70,6 +70,7 @@ class Xsql {
this . metaDb . tables [ tableName ] [ 'foreignKeys' ] = [ ]
this . metaDb . tables [ tableName ] [ 'foreignKeys' ] = [ ]
this . metaDb . tables [ tableName ] [ 'columns' ] = [ ]
this . metaDb . tables [ tableName ] [ 'columns' ] = [ ]
this . metaDb . tables [ tableName ] [ 'indicies' ] = [ ]
this . metaDb . tables [ tableName ] [ 'indicies' ] = [ ]
this . metaDb . tables [ tableName ] [ 'isView' ] = schemaRow [ 'table_name' ] [ 'isView' ]
}
}
}
}
}
}
@ -520,9 +521,9 @@ class Xsql {
let routes = [ ]
let routes = [ ]
let tableObj = { }
let tableObj = { }
let table = this . metaDb . tables [ tableName ] ;
let table = this . metaDb . tables [ tableName ] ;
let isView = this . metaDb . tables [ tableName ] [ 'isView' ] ;
tableObj [ 'resource' ] = tableName ;
tableObj [ 'resource' ] = tableName ;
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/describe' , 'describe' ) )
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 + '/count' , 'count' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/groupby' , 'groupby' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/groupby' , 'groupby' ) )
@ -530,21 +531,31 @@ class Xsql {
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/chart' , 'chart' ) )
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 + '/aggregate' , 'aggregate' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/findOne' , 'findOne' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/findOne' , 'findOne' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName , 'create' ) )
if ( ! isView ) {
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName , 'create' ) )
}
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName , 'list' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName , 'list' ) )
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName + '/bulk' , 'bulkInsert' ) )
if ( ! isView ) {
routes . push ( this . prepareRoute ( internal , 'post' , apiPrefix , tableName + '/bulk' , 'bulkInsert' ) )
routes . push ( this . prepareRoute ( internal , 'delete' , apiPrefix , tableName + '/bulk' , 'bulkDelete' ) )
}
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/bulk' , 'bulkRead' ) )
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' ) )
if ( ! isView ) {
routes . push ( this . prepareRoute ( internal , 'put' , apiPrefix , tableName , 'update' ) )
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' , 'read' ) )
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' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , tableName + '/:id/exists' , 'exists' ) )
for ( var j = 0 ; j < table [ 'foreignKeys' ] . length ; ++ j ) {
for ( var j = 0 ; j < table [ 'foreignKeys' ] . length ; ++ j ) {
let fk = table [ 'foreignKeys' ] [ j ]
let fk = table [ 'foreignKeys' ] [ j ]
if ( fk [ 'referenced_table_name' ] in this . sqlConfig . ignoreTables ) {
if ( fk [ 'referenced_table_name' ] in this . sqlConfig . ignoreTables ) {
//console.log('ignore table',fk['referenced_table_name']);
//console.log('ignore table',fk['referenced_table_name']);
} else {
} else {
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , fk [ 'referenced_table_name' ] + '/:id/' + fk [ 'table_name' ] , 'relational' ) )
routes . push ( this . prepareRoute ( internal , 'get' , apiPrefix , fk [ 'referenced_table_name' ] + '/:id/' + fk [ 'table_name' ] , 'relational' ) )