Search in sources :

Example 26 with Database

use of com.bluenimble.platform.db.Database in project serverless by bluenimble.

the class Get method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.get("Employees", "5aa4192e5e6726413c7db45a");
    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 27 with Database

use of com.bluenimble.platform.db.Database in project serverless by bluenimble.

the class GetOne2One method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject driver = db.get("Drivers", "5aa425145e67264b7858685a");
    DatabaseObject car = (DatabaseObject) driver.get("car");
    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 28 with Database

use of com.bluenimble.platform.db.Database in project serverless by bluenimble.

the class GetWithId method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject dbo = db.get("WithIds", 100);
    System.out.println("Object Id: " + dbo.getId());
    System.out.println(dbo.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 29 with Database

use of com.bluenimble.platform.db.Database in project serverless by bluenimble.

the class UpdateOne2One method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.get("Employees", "5aa4192e5e6726413c7db45a");
    employee.set("address", "Never Found");
    DatabaseObject city = (DatabaseObject) employee.get("city");
    city.set("name", "Eldorado");
    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 30 with Database

use of com.bluenimble.platform.db.Database in project serverless by bluenimble.

the class Load method main.

public static void main(String[] args) throws Exception {
    Database db = new DatabaseServer().get();
    DatabaseObject spa = db.create("SpaStreams");
    spa.load(Json.load(new File("tests/data-1.json")));
    spa.save();
    System.out.println(spa.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) File(java.io.File)

Aggregations

Database (com.bluenimble.platform.db.Database)41 DatabaseObject (com.bluenimble.platform.db.DatabaseObject)37 JsonObject (com.bluenimble.platform.json.JsonObject)27 DefaultDatabaseObjectSerializer (com.bluenimble.platform.db.impls.DefaultDatabaseObjectSerializer)20 JsonQuery (com.bluenimble.platform.db.query.impls.JsonQuery)14 ApiServiceExecutionException (com.bluenimble.platform.api.ApiServiceExecutionException)11 JsonApiOutput (com.bluenimble.platform.api.impls.JsonApiOutput)11 DatabaseException (com.bluenimble.platform.db.DatabaseException)8 ApiAccessDeniedException (com.bluenimble.platform.api.ApiAccessDeniedException)6 ApiSpace (com.bluenimble.platform.api.ApiSpace)6 JsonArray (com.bluenimble.platform.json.JsonArray)5 ApiOutput (com.bluenimble.platform.api.ApiOutput)4 Date (java.util.Date)4 Config (com.bluenimble.platform.api.impls.im.LoginServiceSpi.Config)2 Messenger (com.bluenimble.platform.messaging.Messenger)2 JsonRecipient (com.bluenimble.platform.messaging.impls.JsonRecipient)2 JsonSender (com.bluenimble.platform.messaging.impls.JsonSender)2 Field (com.bluenimble.platform.db.Database.Field)1 File (java.io.File)1