This golang project parses a loopback 3 like filter.
package main
import "github.com/xompass/lbq"
func main() {
filter, err:= lbq.ParseFilter("<your loopback filter json string>")
//...
}
var filter = lbq.Filter {
Fields: lbq.Fields{
"field1": true,
"field2": true,
"field3": false,
},
}
var filter = lbq.Filter {
Limit: 10,
Skip: 5,
}
var filter = lbq.Filter {
Order: []lbq.Order{
{
Field: "field1",
Direction: "ASC",
},
{
Field: "field2",
Direction: "DESC",
},
},
}
var filter = lbq.Filter {
Where: lbq.Where{
"field1": "value1",
"field2": lbq.Where {
"gt": 10,
},
"and": []lbq.AndOrCondition{
{ "field3": "value3" },
{ "field4": true },
},
},
}
var filter = lbq.Filter {
Include: []lbq.Include{
{
Relation: "relation1",
Scope: &lbq.Filter{
Fields: lbq.Fields{
"field1": true,
"field2": true,
},
},
},
{
Relation: "relation2",
Scope: lbq.Filter{
Fields: lbq.Where{
"field3": "value3",
},
},
},
{
Relation: "relation3",
},
},
}