use of com.bluenimble.platform.db.query.impls.JsonQuery in project serverless by bluenimble.
the class FindAllWithCount method main.
public static void main(String[] args) throws Exception {
String query = "{ count: 1 }";
Database db = new DatabaseServer().get();
List<DatabaseObject> employees = db.find("Employees", new JsonQuery(new JsonObject(query)), null);
for (DatabaseObject employee : employees) {
System.out.println(employee.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
}
use of com.bluenimble.platform.db.query.impls.JsonQuery in project serverless by bluenimble.
the class FindAllWithSelect method main.
public static void main(String[] args) throws Exception {
String query = "{ select: [name], orderBy: { name: asc } }";
Database db = new DatabaseServer().get();
List<DatabaseObject> employees = db.find("Employees", new JsonQuery(new JsonObject(query)), null);
for (DatabaseObject employee : employees) {
System.out.println(employee.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
}
use of com.bluenimble.platform.db.query.impls.JsonQuery in project serverless by bluenimble.
the class FindAllWithSort method main.
public static void main(String[] args) throws Exception {
String query = "{ orderBy: { name: asc } }";
Database db = new DatabaseServer().get();
List<DatabaseObject> employees = db.find("Employees", new JsonQuery(new JsonObject(query)), null);
for (DatabaseObject employee : employees) {
System.out.println(employee.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
}
use of com.bluenimble.platform.db.query.impls.JsonQuery in project serverless by bluenimble.
the class TestStartPageQueryCompiler method main.
public static void main(String[] args) throws Exception {
Query query = new JsonQuery(Json.load(new File("tests/queries/complete.json")));
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select) {
private static final long serialVersionUID = -1248971549807669897L;
@Override
protected void onQuery(Timing timing, Query query) throws DatabaseException {
super.onQuery(timing, query);
if (Timing.start.equals(timing)) {
return;
}
if (query.start() > 0) {
buff.append(Lang.SPACE).append("skip").append(Lang.SPACE).append(query.start());
}
if (query.count() > 0) {
buff.append(Lang.SPACE).append("limit").append(Lang.SPACE).append(query.count());
}
}
};
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
use of com.bluenimble.platform.db.query.impls.JsonQuery in project serverless by bluenimble.
the class TestQueryCompiler method main.
public static void main(String[] args) throws Exception {
Query query = new JsonQuery(Json.load(new File("tests/queries/simple.json")));
System.out.println("Select==>");
QueryCompiler sc = new SqlQueryCompiler(Query.Construct.select);
CompiledQuery cq = sc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
System.out.println("Delete==>");
QueryCompiler dc = new SqlQueryCompiler(Query.Construct.delete);
cq = dc.compile(query);
System.out.println(" query: " + cq.query());
System.out.println();
System.out.println("bindings: " + cq.bindings());
}
Aggregations