README ¶
Command line datly executor
./datly -h
DSQL (datly SQL)
The general structure for DSQL
SELECT mainViewAlias.* [EXCEPT COLUMN]
[, secondViewAlias.* ]
[, NviewAlias.* ]
FROM (
SELECT
ID [ColumnConfig],
...,
other_column
FROM table1
) mainViewAlias [ViewConfig],
[
JOIN (
SELECT OTHER_ID,
...,
other_column
FROM table2
) secondViewAlias [ViewConfig] ON mainViewAlias.ID = secondViewAlias.OTHER_ID
]
Where
- RouteConfig is JSON representation of Route settings i.e {"URI":"app1/view1/{Id}"}
- OutputConfig is JSON representation of Output settings
- ColumnConfig is JSON representation of Column settings i.e {"DataType":"bool"}
- ViewConfig is JSON representation of View settings i.e {"Cache":{"Ref":"aerospike"}}
See e2e testcase for more examples
One to many
rule.sql
SELECT
dept.*
employee.*
FROM DEPARMENT dept
JOIN EMP employee ON dept.ID = employee.DEPT_ID
datly -N=dept -X=rule.sql
One to one relation
rule.sql
SELECT
dept.*
employee.*,
organization.*
FROM DEPARMENT dept
JOIN EMP employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
datly -N=dept -X=rule.sql
Excluding output column
rule.sql
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID,
organization.*
FROM DEPARMENT dept
JOIN EMP employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
datly -N=dept -X=rule.sql
View SQL
rule.sql
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID,
organization.*
FROM (SELECT * FROM DEPARMENT t) dept
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
datly -N=dept -X=rule.sql
View SQL with velty template and query parameters
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID,
organization.*
FROM (SELECT * FROM DEPARMENT t) dept
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
WHERE 1=1
#if ($Has.Id)
AND ID = $Id
#end
View SQL with query parameters
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID,
organization.*
FROM (SELECT * FROM DEPARMENT t) dept
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
WHERE ID = $Id
View SQL column type codec
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID,
organization.*
FROM (SELECT * FROM DEPARMENT t) dept
JOIN (SELECT ID, NAME, DEPT_ID,
(CASE WHEN COLUMN_X = 1 THEN
'x1,x2'
WHEN COLUMN_X = 2 THEN
'x3,x4'
END) AS SLICE /* {"Codec":{"Ref":"AsStrings"}, "DataType": "string"} */
FROM EMP t) employee ON dept.ID = employee.DEPT_ID
JOIN ORG organization ON organization.ID = demp.ORG_ID AND 1=1
WHERE ID = $Id
Supported conversion Codecs
- AsStrings: converts coma separated value into []string
Setting matching URI
/* {"URI":"dept/"} */
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID
FROM (SELECT * FROM DEPARMENT t) dept
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee
ON dept.ID = employee.DEPT_ID
Setting data caching
/* {"URI":"dept/",
"Cache":{
"Name": "fs"
"Location": "/tmp/cache/${view.Name}",
"TimeToLiveMs": 360000
}
} */
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID
FROM (SELECT * FROM DEPARMENT t) dept /* {"Cache":{"Ref":"fs"}} */
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee /* {"Cache":{"Ref":"fsgit p"}} */
ON dept.ID = employee.DEPT_ID
/* {"URI":"dept/",
"Cache":{
"Name": "aerospike",
"Provider": "aerospike://127.0.0.1:3000/test",
"Location": "${view.Name}",
"TimeToLiveMs": 360000
}
} */
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID
FROM (SELECT * FROM DEPARMENT t) dept /* {"Cache":{"Ref":"aerospike"}} */
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee /* {"Cache":{"Ref":"aerospike"}} */
ON dept.ID = employee.DEPT_ID
Setting selector
SELECT
dept.* EXCEPT ORG_ID
employee.* EXCEPT DEPT_ID
FROM (SELECT * FROM DEPARMENT t) dept /* {"Selector":{"Limit": 40, "Constraints"{"Criteria": false}}} */
JOIN (SELECT ID, NAME, DEPT_ID FROM EMP t) employee /* {"Selector":{"Limit": 80, "Constraints"{"Criteria": false, "Limit": false, "Offset": false}}} */
ON dept.ID = employee.DEPT_ID
Persisting routes/config to the local folder
Use -w=location switch
datly -N=dept -T=DEPT -w=my_project
Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheWarmup ¶ added in v0.2.11
type CacheWarmup struct {
WarmupURIs []string `short:"u" long:"wuri" description:"uri to warmup cache" `
}
type Connector ¶
type Connector struct { Connects []string `short:"C" long:"conn" description:"name|driver|dsn|secret|secretkey" ` DbName string `short:"V" long:"dbname" description:"db/connector name" ` Driver string `short:"D" long:"driver" description:"driver" ` DSN string `short:"A" long:"dsn" description:"DSN" ` Secret string `short:"E" long:"secret" description:"database secret" ` SecretKey string // contains filtered or unexported fields }
type Module ¶ added in v0.8.0
type Module struct { ModuleDst string `long:"moduleDst" description:"output module path"` ModuleSrc []string `long:"moduleSrc" description:"input module path"` ModuleArgs []string `long:"moduleArgs" description:"args need to be passed to generate a plugin"` ModuleName string `long:"moduleName" description:"module name"` ModuleMain string `long:"moduleMain" description:"module main"` ModuleLdFlags string `long:"moduleLdFlags" description:"module ldflags"` ModuleOS string `long:"moduleOS" description:"module OS"` ModuleArch string `long:"moduleArch" description:"plugin ARCH"` ModuleGoVersion string `long:"moduleGoVersion" description:"module go Version"` }
type Options ¶
type Options struct { Port int `short:"p" long:"port" description:"port" ` RouteURL string `short:"r" long:"routeURL" description:"route URL" ` DependencyURL string `short:"d" long:"deps" description:"dependencies URL" ` ConfigURL string `short:"c" long:"config" description:"configuration URL" ` PartialConfigURL string `short:"e" long:"partialConfig" description:"partial configuration file URL"` JWTVerifierRSAKey string `short:"j" long:"jwtRSAKey" description:"PublicKeyPath|EncKey" ` JWTVerifierHMACKey string `short:"m" long:"jwtHMACKey" description:"digest key" ` WriteLocation string `short:"w" long:"write" description:"dump all config files to specified location" ` BuildMode string `` /* 149-byte string literal not displayed */ Generate Connector CacheWarmup Prepare OpenApiURL string `short:"o" long:"openapi"` Version bool `short:"v" long:"version" description:"build version"` RelativePath string `long:"relative" description:"allow to control relative path where path is used"` RoutePrefix string `short:"x" long:"routePrefix" description:"route prefix default dev"` ApiURIPrefix string `short:"i" long:"apiPrefix" description:"api prefix default /v1/api/"` Plugins Package Module AssetsURL string `short:"a" long:"assetsURL" description:"assets destination"` ConstURL string `long:"constURL" description:"path where const files are stored"` Legacy bool `short:"l"` SubstituesURL []string `long:"substituesURL" description:"substitues URL, expands template before processing"` JobURL string `short:"z" long:"joburl" description:"job url"` // contains filtered or unexported fields }
deprecated
func (*Options) BuildOption ¶ added in v0.8.0
type Plugins ¶ added in v0.8.0
type Plugins struct { PluginDst string `long:"pluginDst" description:"output plugin path"` PluginSrc []string `long:"pluginSrc" description:"input plugin path"` PluginArgs []string `long:"pluginArgs" description:"args need to be passed to generate a plugin"` PluginsURL string `long:"pluginsURL" description:"generated plugins destination"` PluginName string `long:"pluginName" description:"plugin name"` PluginGoVersion string `long:"pluginGoVersion" description:"plugin go Version"` PluginOS string `long:"pluginOS" description:"plugin OS"` PluginArch string `long:"pluginArch" description:"plugin ARCH"` }
type Prepare ¶ added in v0.8.0
type Prepare struct { PrepareRule string `short:"G" long:"generate" description:"prepare rule for patch|post|put"` ExecKind string `long:"execKind" description:"allows to switch between service / dml"` DSQLOutput string `long:"dqlOutput" description:"output path"` GoFileOutput string `long:"goFileOut" description:"destination of go file"` GoModulePkg string `long:"goModulePkg" description:"go module package"` LoadPrevious bool `long:"loadSQL" description:"decides whether to load records using "` }
Click to show internal directories.
Click to hide internal directories.