Java Code Examples for io.vertx.mutiny.sqlclient.Row

The following examples show how to use io.vertx.mutiny.sqlclient.Row. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: quarkus-quickstarts   Source File: Fruit.java    License: Apache License 2.0 5 votes vote down vote up
public static Uni<List<Fruit>> findAll(PgPool client) {
    return client.query("SELECT id, name FROM fruits ORDER BY name ASC").execute()
            .onItem().apply(pgRowSet -> {
                List<Fruit> list = new ArrayList<>(pgRowSet.size());
                for (Row row : pgRowSet) {
                    list.add(from(row));
                }
                return list;
            });
}
 
Example 2
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<JsonArray> listFruits() {
    return client.query("SELECT * FROM fruits").execute()
            .map(mysqlRowSet -> {
                JsonArray jsonArray = new JsonArray();
                for (Row row : mysqlRowSet) {
                    jsonArray.add(toJson(row));
                }
                return jsonArray;
            })
            .subscribeAsCompletionStage();
}
 
Example 3
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<JsonArray> listFruits() {
    return client.query("SELECT * FROM fruits").execute()
            .map(mysqlRowSet -> {
                JsonArray jsonArray = new JsonArray();
                for (Row row : mysqlRowSet) {
                    jsonArray.add(toJson(row));
                }
                return jsonArray;
            })
            .subscribeAsCompletionStage();
}
 
Example 4
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<JsonArray> listFruits() {
    return client.query("SELECT * FROM fruits").execute()
            .map(pgRowSet -> {
                JsonArray jsonArray = new JsonArray();
                for (Row row : pgRowSet) {
                    jsonArray.add(toJson(row));
                }
                return jsonArray;
            })
            .subscribeAsCompletionStage();
}
 
Example 5
Source Project: quarkus   Source File: HotReloadFruitResource.java    License: Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<JsonArray> listFruits() {
    return client.query("SELECT * FROM fruits").execute()
            .map(pgRowSet -> {
                JsonArray jsonArray = new JsonArray();
                for (Row row : pgRowSet) {
                    jsonArray.add(toJson(row));
                }
                return jsonArray;
            })
            .subscribeAsCompletionStage();
}
 
Example 6
public Uni<List<Fortune>> findAll() {
    return clients.getClient().preparedQuery("SELECT * FROM Fortune" )
            .execute()
            .map(rowset -> {
                List<Fortune> ret = new ArrayList<>(rowset.size()+1);
                for(Row r : rowset) {
                    ret.add(new Fortune(r.getInteger("id"), r.getString("message")));
                }
                return ret;
            });
}
 
Example 7
public Uni<World> find(int id) {
    return clients.getClient().preparedQuery("SELECT id, randomNumber FROM World WHERE id = $1")
            .execute(Tuple.of(id))
            .map(rowset -> {
                Row row = rowset.iterator().next();
                return new World(row.getInteger(0), row.getInteger(1));
            });
}
 
Example 8
Source Project: quarkus-quickstarts   Source File: Fruit.java    License: Apache License 2.0 4 votes vote down vote up
private static Fruit from(Row row) {
    return new Fruit(row.getLong("id"), row.getString("name"));
}
 
Example 9
Source Project: quarkus-quickstarts   Source File: Fruit.java    License: Apache License 2.0 4 votes vote down vote up
private static Fruit from(Row row) {
    return new Fruit(row.getLong("id"), row.getString("name"));
}
 
Example 10
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 4 votes vote down vote up
private JsonObject toJson(Row row) {
    return new JsonObject()
            .put("id", row.getLong("id"))
            .put("name", row.getString("name"));
}
 
Example 11
Source Project: quarkus   Source File: HibernateReactiveDB2TestEndpoint.java    License: Apache License 2.0 4 votes vote down vote up
private Uni<RowSet<Row>> populateDB() {
    return db2Pool.query("DELETE FROM Pig").execute()
            .flatMap(junk -> db2Pool.preparedQuery("INSERT INTO Pig (id, name) VALUES (5, 'Aloi')").execute());
}
 
Example 12
Source Project: quarkus   Source File: HibernateReactiveTestEndpoint.java    License: Apache License 2.0 4 votes vote down vote up
private Uni<RowSet<Row>> populateDB() {
    return pgPool.query("DELETE FROM Pig").execute()
            .flatMap(junk -> pgPool.preparedQuery("INSERT INTO Pig (id, name) VALUES (5, 'Aloi')").execute());
}
 
Example 13
private Uni<RowSet<Row>> populateDB() {
    return mysqlPool.query("DELETE FROM Pig").execute()
            .flatMap(junk -> mysqlPool.preparedQuery("INSERT INTO Pig (id, name) VALUES (5, 'Aloi')").execute());
}
 
Example 14
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 4 votes vote down vote up
private JsonObject toJson(Row row) {
    return new JsonObject()
            .put("id", row.getLong("id"))
            .put("name", row.getString("name"));
}
 
Example 15
Source Project: quarkus   Source File: FruitResource.java    License: Apache License 2.0 4 votes vote down vote up
private JsonObject toJson(Row row) {
    return new JsonObject()
            .put("id", row.getLong("id"))
            .put("name", row.getString("name"));
}
 
Example 16
Source Project: quarkus   Source File: HotReloadFruitResource.java    License: Apache License 2.0 4 votes vote down vote up
private JsonObject toJson(Row row) {
    return new JsonObject()
            .put("id", row.getLong("id"))
            .put("name", row.getString("name"));
}