Search in sources :

Example 36 with Database

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

the class CreateOne2OneExisting method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    // create driver
    DatabaseObject driver = db.create("Drivers");
    driver.set("name", "One2One-New-4");
    driver.set("info", new JsonObject().set("x", "40987").set("y", 76623));
    driver.set("salary", 48.50);
    // create car
    DatabaseObject car = db.get("Cars", "5aa425145e67264b78586859");
    driver.set("car", car);
    driver.save();
    System.out.println(driver.toJson(null));
}
Also used : Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject) JsonObject(com.bluenimble.platform.json.JsonObject)

Example 37 with Database

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

the class CreateWithId method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.create("WithIds");
    employee.set("name", "New-1");
    employee.setId(100);
    employee.save();
    System.out.println(employee.toJson(null));
}
Also used : Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject)

Example 38 with Database

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

the class Delete method main.

public static void main(String[] args) throws DatabaseException {
    Database db = new DatabaseServer().get();
    DatabaseObject employee = db.get("Employees", "5aa2f0805e67263db04675ad");
    employee.delete();
}
Also used : Database(com.bluenimble.platform.db.Database) DatabaseObject(com.bluenimble.platform.db.DatabaseObject)

Example 39 with Database

use of com.bluenimble.platform.db.Database 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 40 with Database

use of com.bluenimble.platform.db.Database 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)

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