org.evcode.queryfy:queryfy-core

Queryfy translate a SQL-like DSL in an query object

Лицензия

Лицензия

Группа

Группа

org.evcode.queryfy
Идентификатор

Идентификатор

queryfy-core
Последняя версия

Последняя версия

1.2.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

Queryfy translate a SQL-like DSL in an query object
Организация-разработчик

Организация-разработчик

Edmo Vamerlatti Costa

Скачать queryfy-core

Как подключить последнюю версию

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.parboiled : parboiled-java jar 1.1.7

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

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

Версии библиотеки

Версия
1.2.2
1.2.1
1.2.0
1.0.0
v1.0.0