Search in sources :

Example 1 with DefaultDatabaseObjectSerializer

use of com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer in project serverless by bluenimble.

the class UpdateSimple method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.get("Employees", "5aa4192e5e6726413c7db45a");
    employee.set("address", "Got Found");
    DatabaseObject city = db.create("Cities");
    city.set("name", "Tetouan");
    employee.set("city", city);
    employee.save();
    System.out.println(employee.toString());
    System.out.println();
    System.out.println("+===============================================================================+");
    System.out.println();
    System.out.println(employee.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
Also used : DefaultDatabaseObjectSerializer(com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer) Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject)

Example 2 with DefaultDatabaseObjectSerializer

use of com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer in project serverless by bluenimble.

the class Update method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.get("Employees", "e0e296f0-1937-4b7c-b077-1d7fe50e2482");
    employee.set("age", 43);
    employee.set("salary", 200.54);
    employee.set("contact", new JsonObject().set("phone", "4089786532").set("email", "alpha@beta.com"));
    DatabaseObject city = db.create("Cities");
    city.set("name", "Sunnyvale");
    employee.set("city", city);
    employee.save();
    System.out.println(employee.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
Also used : 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 3 with DefaultDatabaseObjectSerializer

use of com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer in project serverless by bluenimble.

the class UpdateOnlyOne2One method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject driver = db.get("Drivers", "722388b0-9a9a-459e-a583-d802653a60b0");
    DatabaseObject car = (DatabaseObject) driver.get("car");
    car.set("model", "BMW");
    car.save();
    System.out.println();
    System.out.println("+===============================================================================+");
    System.out.println();
    System.out.println(car.toJson(new DefaultDatabaseObjectSerializer(2, 2)));
}
Also used : DefaultDatabaseObjectSerializer(com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer) Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject)

Example 4 with DefaultDatabaseObjectSerializer

use of com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer in project serverless by bluenimble.

the class Find method main.

public static void main(String[] args) throws Exception {
    String query = "{ where: { age: 34 } }";
    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 5 with DefaultDatabaseObjectSerializer

use of com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer in project serverless by bluenimble.

the class FindAll method main.

public static void main(String[] args) throws Exception {
    String query = "{ }";
    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)

Aggregations

Database (com.bluenimble.platform.db.Database)20 DatabaseObject (com.bluenimble.platform.db.DatabaseObject)20 DefaultDatabaseObjectSerializer (com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer)20 JsonObject (com.bluenimble.platform.json.JsonObject)11 JsonQuery (com.bluenimble.platform.db.query.impls.JsonQuery)10 ApiAccessDeniedException (com.bluenimble.platform.api.ApiAccessDeniedException)1 ApiServiceExecutionException (com.bluenimble.platform.api.ApiServiceExecutionException)1 ApiSpace (com.bluenimble.platform.api.ApiSpace)1 JsonApiOutput (com.bluenimble.platform.api.impls.JsonApiOutput)1 DatabaseException (com.bluenimble.platform.db.DatabaseException)1 JsonArray (com.bluenimble.platform.json.JsonArray)1 File (java.io.File)1