Queryfy (Parent)

Queryfy translate a SQL-like DSL in an query object

License

License

GroupId

GroupId

org.evcode.queryfy
ArtifactId

ArtifactId

queryfy-root
Last Version

Last Version

1.2.2
Release Date

Release Date

Type

Type

pom
Description

Description

Queryfy (Parent)
Queryfy translate a SQL-like DSL in an query object
Project URL

Project URL

https://github.com/edmocosta/queryfy
Project Organization

Project Organization

Edmo Vamerlatti Costa
Source Code Management

Source Code Management

https://github.com/edmocosta/queryfy

Download queryfy-root

Filename Size
queryfy-root-1.2.2.pom 5 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-root/ -->
<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-root</artifactId>
    <version>1.2.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-root/
implementation 'org.evcode.queryfy:queryfy-root:1.2.2'
// https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-root/
implementation ("org.evcode.queryfy:queryfy-root:1.2.2")
'org.evcode.queryfy:queryfy-root:pom:1.2.2'
<dependency org="org.evcode.queryfy" name="queryfy-root" rev="1.2.2">
  <artifact name="queryfy-root" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.evcode.queryfy', module='queryfy-root', version='1.2.2')
)
libraryDependencies += "org.evcode.queryfy" % "queryfy-root" % "1.2.2"
[org.evcode.queryfy/queryfy-root "1.2.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • queryfy-core
  • queryfy-querydsl
  • queryfy-mongodb

Queryfy

Build Status

Queryfy is a simple SQL-like language designed to provide a safe and flexible way to filter, sort and to paginate data over REST APIs and Front-end as well.

  • As it is NOT SQL, there is no SQL Injection.

  • The Queryfy-Core is responsible for build the abstract syntax tree (AST) from the query string and use a provided visitor to build the filter object (eg. JPAQuery, etc).

  • You can use the existing implementation (QueryDSL JPA, MongoDB (Bson)) or implement your own visitor.

Usage

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-core</artifactId>
    <version>1.2.2</version>
</dependency>

QueryDSL

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-querydsl-jpa</artifactId>
    <version>1.2.2</version>
</dependency>
EntityManager em = ...;
String query = "select name, age where age > 18 order by name limit 0, 100";

JPAQueryDslParser parser = new JPAQueryDslParser(em);

//Create an evaluation context. All paths added here will be available on the query syntax
QueryDslContext context = QueryDslContext.from(QTest.test)
                .withPath("name", QTest.test.name)
                .withPath("age", QTest.test.age)
                .withPath("other.id", QTest.test.other.id)
                .withPath("other.name", QTest.test.other.name)
                .build();
                
//Parse the query string into a QueryDSL JPAQuery or JPAEvaluatedQuery object
JPAEvaluatedQuery jpaQuery = parser.parseAndFind(query, context);

//List applying the projections fields (name and age)
List<Test> list = jpaQuery.listWithProjections();

MongoDB (Bson)

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-mongodb</artifactId>
    <version>1.2.2</version>
</dependency>
String query = "select name, age where age > 18 order by name limit 0, 100"; 
MongodbQueryParser parser = new MongodbQueryParser();

//Create an evaluation context. All paths added here will be available on the query syntax
MongodbContext context = MongodbContext.builder()
                .withPath("name")
                .withPath("age")
                .withPath("otherId", "other.id")
                .build();
                
MongoCollection<Document> collection = ....;

//The parseAndFind method will parse the query and return a MongoDB FindIterable. you can also use the parseAndApply method
//to set the parameters on an existing FindIterable object.
FindIterable<Document> result = parser.parseAndFind(collection, query, context);

See more

Documentation

Versions

Version
1.2.2
1.2.1
1.2.0
1.0.0
v1.0.0