2.14.3 • Published 1 year ago

tg-client-query-builder v2.14.3

Weekly downloads
942
License
ISC
Repository
-
Last release
1 year 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
2.14.3

1 year ago

2.14.1

2 years ago

2.14.2

2 years ago

2.13.1

4 years ago

2.13.0

4 years ago

3.0.0

4 years ago

2.12.2

5 years ago

2.12.1

7 years ago

2.12.0

7 years ago

2.10.2

7 years ago

2.10.1

7 years ago

2.10.0

7 years ago

2.9.2

7 years ago

2.9.1

7 years ago

2.9.0

7 years ago

2.8.0

7 years ago

2.7.1

7 years ago

2.7.0

7 years ago

2.5.1

7 years ago

2.6.0

7 years ago

2.5.0

7 years ago

2.4.0

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago