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));
}
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));
}
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();
}
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)));
}
}
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)));
}
}
Aggregations