Abstractions

CreateAppAI has only two Abstractions (or DSL), one for Query String to support Advance Search/Sort scenarios and another one to support multi-row editable table form.

Search - Sort Query String

File: app\models\search.ts

CreateAppAI seek/get methods support rich search functionality modeled using following search interface

interface SearchParam {
  field: string;
  value: any;
  value2?: any;
  criteria: string;
  childParams?: Array<SearchParam>;
  orChildParams?: boolean;
}
interface SearchParam {
  field: string;
  value: any;
  value2?: any;
  criteria: string;
  childParams?: Array<SearchParam>;
  orChildParams?: boolean;
}

Search Query String Expression

In order to support client side rich search experience, CreateAppAI encodes Search expression using following format

Individual Expression fields are joined with tilde '': FieldNamecriteria~value

Only FieldName and Value are required, so if you are searching for widgetName it will be encoded as widgetName~abcd

Multiple Expressions are joined with comma ',': Field1Value1,Field2Value2

Above encoding is done using utility function getSearchExpression found in file app\models\search.ts

function getSearchExpression(searchParams: SearchParam[]):string
function getSearchExpression(searchParams: SearchParam[]):string

Another function getSearchParams can be used to convert search Expression to List of Search Parameters, this is mainly provided for testing purpose (not used in code)

function getSearchParams(search: string): SearchParam[]
function getSearchParams(search: string): SearchParam[]

Server Search Expression Parser

Above shows simple search scenarios. In order to support rich search, server expression parser supports following File: app\models\search.server.ts

Criteria Supported

=
LIKE
!=
<>
>
>=
<=
<
BETWEEN
IS NULL
IS NOT NULL
NOT IN
IN
=
LIKE
!=
<>
>
>=
<=
<
BETWEEN
IS NULL
IS NOT NULL
NOT IN
IN

Criteria is optional and if it is not provided is defaults to 'LIKE' for string. For fields that end with 'Date', default for criteria is '>=', for fields that start with 'has' or end with 'Flag', default is '=', for fields that end with 'Id', default is '='

Server auto appends '%' to any value for LIKE criteria and removes existing '%' to prevent any attempt to overload db as leading '%' will cause database to search without using index and can have sever impact on performance. You can remove that protection, but you have been warned!

For IN and NOT IN, you can provide a list of values separated by pipe '|' character.

By default multiple expression are 'AND'ed for searching. To perform an 'OR' search, field names are prepended with an asterisk - '*'

Example of a ORed expression

*widgetName~abc,*widgetName~xyz

Please note that for majority parts, included controls internally handle this automatically and you should never have to worry about encoding by hand.

Sort

File: app\models\sort.ts

CreateAppAI seek/get methods support sort functionality modeled using following sort interface

interface SortParam {
  field: string;
  descending: boolean;
}
interface SortParam {
  field: string;
  descending: boolean;
}

Sort Query String Expression

In order to support client side sort search experience, CreateAppAI encodes Sort expression using following format

FieldD or FieldA

Where

Field = Field Name to sort on D = descending sort A = ascending sort

Currently only single sort expression is supported, this might change in future. Multiple sort expressions are separated using comma ','

If you decide to change search or sort query string expression, please change both utility function used by various client controls getSearchExpression and the server expression parser.

Form Field Naming to support multi record editable table

In order to support parent children scenario, where in the main parent form contains editable table of children items, each form field in editable table is named with pattern

modelName.fieldName
modelName.fieldName

This prevents collision with parent fields of same name and servers as namespace for children fields.

This is handled transparently by included Editable Table control and by generated get${modelName}FromFormList function in the app\models\model.ts file. If you decide to change how fields are name in editable table by changing generated code, please make corresponding changes to get${modelName}FromFormList as well to support your naming Abstractions.