// Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ]
import { Sequelize } from 'sequelize-typescript'
+type SortType = { sortModel: any, sortValue: string }
+
function getSort (value: string, lastSort: string[] = [ 'id', 'ASC' ]) {
let field: any
let direction: 'ASC' | 'DESC'
)
}
-function createSearchTrigramQuery (col: string, value: string) {
- return {
- [ Sequelize.Op.or ]: [
- // FIXME: use word_similarity instead of just similarity?
- Sequelize.where(searchTrigramNormalizeCol(col), ' % ', searchTrigramNormalizeValue(value)),
-
- Sequelize.where(searchTrigramNormalizeCol(col), ' LIKE ', searchTrigramNormalizeValue(`%${value}%`))
- ]
- }
-}
-
// ---------------------------------------------------------------------------
export {
+ SortType,
getSort,
getSortOnModel,
createSimilarityAttribute,
throwIfNotValid,
- buildTrigramSearchIndex,
- createSearchTrigramQuery
+ buildTrigramSearchIndex
}
// ---------------------------------------------------------------------------