public class Example {
Database database;
public void connect() {
// Replace MongoDB() with your database type
this.database = new MongoDB();
Map<String, String> credentials = new HashMap<>();
credentials.put("name", "name of db");
credentials.put("username", "username");
credentials.put("password", "password");
credentials.put("host", "DNS or IP");
credentials.put("port", "port");
this.database.connect(credentials);
}
}
Create model
ExampleModel.class
@Model(tableName="example-table")
public class ExampleModel extends BaseModel {
@ModelField(isPrimaryKey = true)
int id;
@ModelField
String username = "default value";
// Custom table name
@ModelField(name="test")
String oneName;
}