Search in sources :

Example 16 with JsonQuery

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)));
    }
}
Also used : JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) DefaultDatabaseObjectSerializer(com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer) Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject) JsonObject(com.bluenimble.platform.json.JsonObject)

Example 17 with JsonQuery

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)));
    }
}
Also used : JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) DefaultDatabaseObjectSerializer(com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer) Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject) JsonObject(com.bluenimble.platform.json.JsonObject)

Example 18 with JsonQuery

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)));
    }
}
Also used : JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) DefaultDatabaseObjectSerializer(com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer) Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject) JsonObject(com.bluenimble.platform.json.JsonObject)

Example 19 with JsonQuery

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());
}
Also used : CompiledQuery(com.bluenimble.platform.db.query.CompiledQuery) Query(com.bluenimble.platform.db.query.Query) JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) QueryCompiler(com.bluenimble.platform.db.query.QueryCompiler) File(java.io.File) CompiledQuery(com.bluenimble.platform.db.query.CompiledQuery)

Example 20 with JsonQuery

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());
}
Also used : CompiledQuery(com.bluenimble.platform.db.query.CompiledQuery) Query(com.bluenimble.platform.db.query.Query) JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) JsonQuery(com.bluenimble.platform.db.query.impls.JsonQuery) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) QueryCompiler(com.bluenimble.platform.db.query.QueryCompiler) File(java.io.File) CompiledQuery(com.bluenimble.platform.db.query.CompiledQuery)

Aggregations

JsonQuery (com.bluenimble.platform.db.query.impls.JsonQuery)20 DatabaseObject (com.bluenimble.platform.db.DatabaseObject)16 JsonObject (com.bluenimble.platform.json.JsonObject)16 Database (com.bluenimble.platform.db.Database)14 DefaultDatabaseObjectSerializer (com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer)10 ApiServiceExecutionException (com.bluenimble.platform.api.ApiServiceExecutionException)4 JsonApiOutput (com.bluenimble.platform.api.impls.JsonApiOutput)4 CompiledQuery (com.bluenimble.platform.db.query.CompiledQuery)4 Query (com.bluenimble.platform.db.query.Query)4 QueryCompiler (com.bluenimble.platform.db.query.QueryCompiler)4 SqlQueryCompiler (com.bluenimble.platform.db.query.impls.SqlQueryCompiler)4 File (java.io.File)4 Date (java.util.Date)4 ApiOutput (com.bluenimble.platform.api.ApiOutput)3 JsonArray (com.bluenimble.platform.json.JsonArray)3 HashMap (java.util.HashMap)3 Config (com.bluenimble.platform.api.impls.im.LoginServiceSpi.Config)2 ApiAuthenticationException (com.bluenimble.platform.api.security.ApiAuthenticationException)2 DatabaseException (com.bluenimble.platform.db.DatabaseException)2 ApiAccessDeniedException (com.bluenimble.platform.api.ApiAccessDeniedException)1