nest_jsx_query_builder 0.0.1 nest_jsx_query_builder: ^0.0.1 copied to clipboard
This package provides a simple API to create queries with ease for NestJs CRUD
example/main.dart
import 'package:nest_jsx_query_builder/literals.dart';
import 'package:nest_jsx_query_builder/nest_jsx_query_builder.dart';
main() {
// Search by field name that can be either null OR equals Superman
// ?s={"name": {"$or": {"$isnull": true, "$eq": "Superman"}}}
NestJsxQueryBuilder.or([
{"name": "{${NestJsQueryLiterals.EQUAL_LITERAL}: \"Superman\"}"},
{"name": "{${NestJsQueryLiterals.IS_NULL_LITERAL}: \"true\"}"},
]);
// Search an entity where isActive is true AND createdAt not equal 2008-10-01T17:04:32
// ?s={"$and": [{"isActive": true}, {"createdAt": {"$ne": "2008-10-01T17:04:32"}}]}
NestJsxQueryBuilder.and([
{"isActive": "true"},
{
"createdAt":
"{${NestJsQueryLiterals.NOT_EQUAL_LITERAL}: \"2008-10-01T17:04:32\"}"
},
]);
// Search an entity where: (`from` is $beforeNow AND (`to` is $beforeNow OR `status` is `approved`OR `status` is `canceled`))
NestJsxQueryBuilder.and([
{
"from":
"{${NestJsQueryLiterals.LESS_THAN_LITERAL}: \"${DateTime.now().toIso8601String()}\"}"
},
NestJsxQueryBuilder.or([
NestJsxQueryBuilder.and([
{
"to":
"{${NestJsQueryLiterals.LESS_THAN_LITERAL}: \"${DateTime.now().toIso8601String()}\"}"
},
{"status": "{${NestJsQueryLiterals.EQUAL_LITERAL}: \"approved\"}"},
]),
{"status": "{${NestJsQueryLiterals.EQUAL_LITERAL}: \"canceled\"}"},
])
]);
}