1.1.0 • Published 6 years ago

@nexys/digis-ddl v1.1.0

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

JSON Data Definition Language (DDL)

npm version npm version CircleCi TavisCI

See it in action

There is an available UI to test different JSON structures described here

Check out

  • CRUD.md
  • FetchR.md

We define an array of entities. All entities have attributes and are assigned primary keys in the form of ids or uuids.

Entity

Arg NamePossible valuesExample
namename of the entity. has to start with a capital letter"Country"
tablename of the SQL table. This field is optional, if not given the table is the snake case version of namemy_country
uuidboolean, if set to true, the primary key is a uuid vs a idfalse
withOrderallows ordering (UI: drag/drop)false
descriptiondescription of the entity, optional
logUsersaves user idfalse
isLogadd log logic in tablefalse
logTablecreates mirror log tablefalse
extendsextends a particular preprogrammed entity (e.g. user)null
uniqueSetarray with combination of params that are unique (e.g ["countryId", "userId"])null

Attribute

Arg NamePossible valuesDefault
Namefield name-
typesee sectionstring
optionaltrue/falsefalse
constraintssee section[]
descriptiondescription of the attribute
ui{textarea, datepicker, slider, etc..}fieldType

Field Types

TypeExample values
Int1, 2, 3
Long65432345, 2345432345
Stringhello
Booleantrue / false
Decimal23.34
Date2019-01-31
Datetime2019-01-31 15:23
Time15:23
-Country

Every entity name automatically becomes a type. Hence the last example of the table where the type is Country, referring to the entity Country and creating a relation with that other entity.

a more formal version can be found in https://github.com/Nexysweb/DevelopmentConsultingFramework/blob/master/src/types.js

mapping SQL JSON-ddl

BigDecimal => Decimal 10, 4
Int => int(11)
Long => bigint(20)
LocalDateTime => Datetime
LocalDate => Datetime

Constraints

Arg NamePossible valuesDefault
typeIdsee section-
valuevalue of the constraint-
msgoverrides default message-

Constraint Types

Checking format

The format can be checked with the schema-validation: https://github.com/Nexysweb/DevelopmentConsultingFramework/blob/master/src/schema-validation.js

Variable types

Explicit variables

Explicit variables need to be explicitly specified when inserting a record (are part of the payload)

Implicit variables

Implicit variables are not explicitly stated. E.g. taken from auth (userId)

System variables

System variables are not speicified in the model.

Examples are:

  • id / uuid
  • dateAdded
  • dateEdited

Example (simple)

This is an example of a simple model, that links countries and cities.

https://github.com/Nexysweb/digis-ddl/tree/master/src/example/simple-country-city.json

Example (advanced)

https://github.com/Nexysweb/digis-ddl/tree/master/src/example/advanced.js

1.1.0

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago