4.1.1 • Published 3 years ago

tg-knex-query-resolver v4.1.1

Weekly downloads
145
License
ISC
Repository
github
Last release
3 years ago

tg-query

Query Builder and Parser for the front and back end

QueryBuilder Usage:

Note for simple cases, a plain filter object can be passed to filter like:

filter: {
    id: 4
}

or 

filter: {
    id: [4,6,12]
}

or 

filter: {
    name: 'thomas'
}

For more complex cases, we'll need to use tg-client-query-builder

import QueryBuilder from "tg-client-query-builder";

//make sure to instantiate the qb anew each time you want to use it
//If it isn't re-instantaited it will grow bigger and bigger!
let qb = new QueryBuilder("notificationRecipient"); //instantiate with the model name
 j
const filter = qb.whereAll({ //either whereAll or whereOr 
    userId: currentUser.userId, //make normal where statements like this
    notificationId: qb.related("notification.id").whereAll({ //specify the connection like this
        type: "info" //add more where statements
        volume: qb.lessThan(2)
    })
}).toJSON() //remember to call toJSON

list of possible filters:

 qb.greaterThan(2)
 qb.inList([2, 4, 6])
 qb.inList(['happy', 'go', 'lucky'])
 qb.lessThan(2)
 qb.lessThanOrEqual(2)
 qb.equals(2)
 qb.greaterThanOrEqual(2)
 qb.notEquals(2)
 qb.notNull()
 qb.isNull()
 qb.between(2, 67)
 qb.notInList([2,5,67])
 qb.startsWith('thom')
 qb.endsWith('as')
 qb.contains('tree') 
 qb.notContains('tree') 
 qb.dateOnly( ???? ) //ADAM THOMAS CAN YOU ADD THIS EXAMPLE?
 qb.upperCase('thomas') //uppercase search
 qb.lowerCase('thoMas') //lowercases the search 
 qb.subString('ma')
 qb.matchesRegex("th.*s") //regex searches for the string
 qb.fuzzy("thms") //fuzzy searches for the string
4.1.1

3 years ago

3.2.0

3 years ago

4.1.0

3 years ago

4.0.0

3 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.11.0

5 years ago

2.10.2

6 years ago

2.10.1

7 years ago

2.10.0

8 years ago

2.9.1

8 years ago

2.9.0

8 years ago

2.8.0

8 years ago

2.7.1

8 years ago

2.7.0

8 years ago

2.6.4

8 years ago

2.6.3

8 years ago

2.6.2

8 years ago

2.6.1

8 years ago

2.6.0

8 years ago

2.5.2

8 years ago

2.5.1

8 years ago

2.5.0

8 years ago

2.4.0

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago