Skip to content

Latest commit

 

History

History
855 lines (537 loc) · 34.8 KB

File metadata and controls

855 lines (537 loc) · 34.8 KB

@onzag/itemize / Modules / base/Root/Module/ItemDefinition/PropertyDefinition/sql

Module: base/Root/Module/ItemDefinition/PropertyDefinition/sql

Contains SQL helper functions to be used within the property definition in order to be able to perform searches of them in the database

Table of contents

Functions

Functions

buildElasticOrderByForInternalRequiredProperty

buildElasticOrderByForInternalRequiredProperty(itemDefinition, which, args, direction, nulls): Object

Builds the order by functionality for the internal properties, such as created_at, edited_at, etc...

Parameters

Name Type Description
itemDefinition default the item definition
which string basically the column name
args IRQArgs -
direction "asc" | "desc" the direction of the order by rule
nulls "first" | "last" whether nulls are first or last

Returns

Object

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:1091


buildElasticOrderByForProperty

buildElasticOrderByForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, direction, nulls, wasIncludedInSearch, wasIncludedInStrSearch): any

Builds an order by query for a given property

Parameters

Name Type Description
serverData any the server data that is being used
appData IAppDataType -
itemDefinition default the item definition in question
include default the include (or null)
propertyDefinition default the property in question
args IRQArgs -
direction "asc" | "desc" the direction to be accounted for
nulls "first" | "last" the nulls (first or last)
wasIncludedInSearch boolean whether this property was included in search
wasIncludedInStrSearch boolean whether this property was included in the str FTS search

Returns

any

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:1002


buildElasticQueryForProperty

buildElasticQueryForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, elasticQueryBuilder, language, dictionary, isOrderedByIt, fullHighlights): IElasticHighlightReply

Builds a sql search query from a given property definition, the data coming from the search module, a sql prefix to use

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
args IRQArgs the args coming from the search module in such format
elasticQueryBuilder ElasticQueryBuilder the elastic building instance
language string -
dictionary string the dictionary that is being used
isOrderedByIt boolean whether there will be a subsequent order by request
fullHighlights number -

Returns

IElasticHighlightReply

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:792


buildElasticStrSearchQueryForProperty

buildElasticStrSearchQueryForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, search, elasticQueryBuilder, language, dictionary, isOrderedByIt, fullHighlights): IElasticHighlightReply

Builds a sql str FTS search query from a given property definition, the data coming from the search module, a sql prefix to use, and the builder

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
args IRQArgs the args coming from the search module in such format
search string the search string that is being used
elasticQueryBuilder ElasticQueryBuilder the building instance
language string -
dictionary string the dictionary that is being used
isOrderedByIt boolean whether there will be a subsequent order by request
fullHighlights number -

Returns

IElasticHighlightReply

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:886


buildSQLOrderByForInternalRequiredProperty

buildSQLOrderByForInternalRequiredProperty(itemDefinition, which, args, orderByBuilder, direction, nulls): void

Builds the order by functionality for the internal properties, such as created_at, edited_at, etc...

Parameters

Name Type Description
itemDefinition default the item definition
which string basically the column name
args IRQArgs -
orderByBuilder OrderByBuilder the order by builder
direction "asc" | "desc" the direction of the order by rule
nulls "first" | "last" whether nulls are first or last

Returns

void

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:1049


buildSQLOrderByForProperty

buildSQLOrderByForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, orderByBuilder, direction, nulls, wasIncludedInSearch, wasIncludedInStrSearch): void

Builds an order by query for a given property

Parameters

Name Type Description
serverData any the server data that is being used
appData IAppDataType -
itemDefinition default the item definition in question
include default the include (or null)
propertyDefinition default the property in question
args IRQArgs -
orderByBuilder OrderByBuilder the order by builder that is currently building the query
direction "asc" | "desc" the direction to be accounted for
nulls "first" | "last" the nulls (first or last)
wasIncludedInSearch boolean whether this property was included in search
wasIncludedInStrSearch boolean whether this property was included in the str FTS search

Returns

void

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:947


buildSQLQueryForProperty

buildSQLQueryForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, whereBuilder, language, dictionary, isOrderedByIt): boolean | [string, any[]]

Builds a sql search query from a given property definition, the data coming from the search module, a sql prefix to use

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
args IRQArgs the args coming from the search module in such format
whereBuilder WhereBuilder the where building instance
language string -
dictionary string the dictionary that is being used
isOrderedByIt boolean whether there will be a subsequent order by request

Returns

boolean | [string, any[]]

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:752


buildSQLStrSearchQueryForProperty

buildSQLStrSearchQueryForProperty(serverData, appData, itemDefinition, include, propertyDefinition, args, search, whereBuilder, language, dictionary, isOrderedByIt): boolean | [string, any[]]

Builds a sql str FTS search query from a given property definition, the data coming from the search module, a sql prefix to use, and the builder

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
args IRQArgs the args coming from the search module in such format
search string the search string that is being used
whereBuilder WhereBuilder the where building instance
language string -
dictionary string the dictionary that is being used
isOrderedByIt boolean whether there will be a subsequent order by request

Returns

boolean | [string, any[]]

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:840


convertRQValueToSQLValueForProperty

convertRQValueToSQLValueForProperty(serverData, appData, mod, itemDefinition, include, propertyDefinition, data, oldData, uploadsClient, domain, language, dictionary): ISQLStreamComposedTableRowValue

Converts a rq value into a sql value, that is rq data into row data to be immediately added to the database as it is

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
mod default the module
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
data IRQArgs the rq data
oldData IRQValue the old rq data
uploadsClient default<any> -
domain string -
language string | ISQLTableRowValue -
dictionary string | ISQLTableRowValue the dictionary to use in full text search mode

Returns

ISQLStreamComposedTableRowValue

a composed value with a partial row value and the consume streams functionality included in it

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:650


convertSQLValueToElasticSQLValueForProperty

convertSQLValueToElasticSQLValueForProperty(serverData, appData, itemDefinition, include, propertyDefinition, row): IRQValue

Parameters

Name Type
serverData any
appData IAppDataType
itemDefinition default
include default
propertyDefinition default
row ISQLTableRowValue

Returns

IRQValue

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:612


convertSQLValueToRQValueForProperty

convertSQLValueToRQValueForProperty(serverData, appData, itemDefinition, include, propertyDefinition, row): IRQValue

Takes row data information that is in the SQL form and converts it into a rq form, only for this specific property

Parameters

Name Type Description
serverData any the server data
appData IAppDataType -
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question
row ISQLTableRowValue the row that we want to extract information from

Returns

IRQValue

the rq value for the property

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:551


getElasticSchemaForProperty

getElasticSchemaForProperty(itemDefinition, include, propertyDefinition, serverData, appData): IElasticIndexDefinitionType

Parameters

Name Type
itemDefinition default
include default
propertyDefinition default
serverData any
appData IAppDataType

Returns

IElasticIndexDefinitionType

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:516


getSQLTableDefinitionForProperty

getSQLTableDefinitionForProperty(itemDefinition, include, propertyDefinition): ISQLTableDefinitionType

Provides the table bit that is necessary to include this property and this property alone, that is a table bit

Parameters

Name Type Description
itemDefinition default the item definition that contains the property
include default the include within the item definition, or null
propertyDefinition default the property definition in question

Returns

ISQLTableDefinitionType

the partial sql table definition for the property

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:496


getStandardElasticFor

getStandardElasticFor(type, nullValue, format?, disabled?): (arg: IArgInfo) => IElasticIndexDefinitionType

Parameters

Name Type
type string
nullValue any
format? string
disabled? boolean

Returns

fn

▸ (arg): IElasticIndexDefinitionType

Parameters
Name Type
arg IArgInfo
Returns

IElasticIndexDefinitionType

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:66


getStandardElasticForWithNullField

getStandardElasticForWithNullField(type, format?, disabled?): (arg: IArgInfo) => IElasticIndexDefinitionType

Parameters

Name Type
type string
format? string
disabled? boolean

Returns

fn

▸ (arg): IElasticIndexDefinitionType

Parameters
Name Type
arg IArgInfo
Returns

IElasticIndexDefinitionType

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:97


getStandardSQLFnFor

getStandardSQLFnFor(type, ext?, indexCalculator?): (arg: ISQLArgInfo) => ISQLTableDefinitionType

Provides the sql function that defines the schema that is used to build the partial table definition

Parameters

Name Type Default value Description
type string undefined the postgresql type
ext string null a extension to require for this type
indexCalculator? (subtype: string, sqlPrefix: string, id: string) => ISQLTableIndexType undefined an function to decide how to build an index for this type

Returns

fn

a function that returns the partial table definition object with the given type

▸ (arg): ISQLTableDefinitionType

Parameters
Name Type
arg ISQLArgInfo
Returns

ISQLTableDefinitionType

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:38


standardElasticOrderBy

standardElasticOrderBy(arg): Object

Parameters

Name Type
arg ISQLOrderByInfo

Returns

Object

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:133


standardElasticSearchFnExactAndRange

standardElasticSearchFnExactAndRange(nullFieldValue, arg): Object

You must ensure no overlap in ranged search, if they are availbe in order for this function to be useful, it will not pluck them out

Parameters

Name Type
nullFieldValue string
arg IElasticSearchInfo

Returns

Object

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:448


standardElasticSearchFnWithNullFieldExactAndRange

standardElasticSearchFnWithNullFieldExactAndRange(arg): Object

Parameters

Name Type
arg IElasticSearchInfo

Returns

Object

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:452


standardSQLBtreeIndexable

standardSQLBtreeIndexable(arg): string[]

The standard btree indexable column builder

Parameters

Name Type Description
arg ISQLBtreeIndexableInfo the sql btree indexable arg

Returns

string[]

an array of the columns to index

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:484


standardSQLElasticInFn

standardSQLElasticInFn(arg): any

The standard sql elastic out that converts to the elastic stored form

Parameters

Name Type Description
arg ISQLOutInfo the out arg info

Returns

any

the property value out

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:265


standardSQLEqualFn

standardSQLEqualFn(arg): void

The standard function that perfoms equality checks within the database

Parameters

Name Type Description
arg ISQLEqualInfo the equal info arg

Returns

void

a valid args to use in the where expression or an object for where many

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:462


standardSQLInFn

standardSQLInFn(arg): ISQLTableRowValue

The standard sql in function that specifies how a property inputs its value into a table

Parameters

Name Type Description
arg ISQLInInfo the in arg

Returns

ISQLTableRowValue

the partial row value

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:163


standardSQLOrderBy

standardSQLOrderBy(arg): [string, string, string]

the standard order by functionality

Parameters

Name Type Description
arg ISQLOrderByInfo the orer by info arg

Returns

[string, string, string]

an array of string with the order by

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:129


standardSQLOutFn

standardSQLOutFn(fallbackNull, arg): any

The standard sql out function that defines how a value for a property is extracted from a given row

Parameters

Name Type Description
fallbackNull any -
arg ISQLOutInfo the out arg info

Returns

any

the property value out

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:224


standardSQLOutWithJSONParseFn

standardSQLOutWithJSONParseFn(fallbackNull, arg): any

The standard sql out function that deserializes values as they are expected to be stored serialized

Parameters

Name Type Description
fallbackNull any -
arg ISQLOutInfo the sql out info arg

Returns

any

the supported type json parsed

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:277


standardSQLSearchFnExactAndRange

standardSQLSearchFnExactAndRange(arg): boolean

The standard function that build queries for the property

Parameters

Name Type Description
arg ISQLSearchInfo the search info arg

Returns

boolean

a boolean on whether it was searched by it

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:308


standardSQLSelect

standardSQLSelect(arg): string[]

The standard sql select function that is used to select the minimum necessary for a selection in a traditional search

Parameters

Name Type Description
arg IArgInfo the in arg

Returns

string[]

the rows to select

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:145


stardardSQLInWithJSONStringifyFn

stardardSQLInWithJSONStringifyFn(arg): ISQLTableRowValue

The standard sql in function that inputs its value but uses JSON stringify as a serialization tool

Parameters

Name Type Description
arg ISQLInInfo the in arg

Returns

ISQLTableRowValue

the partial row value

Defined in

base/Root/Module/ItemDefinition/PropertyDefinition/sql/index.ts:203