io.vertx.mutiny.pgclient.PgPool Java Examples
The following examples show how to use
io.vertx.mutiny.pgclient.PgPool.
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 File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 5 votes |
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 File: PgClients.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
synchronized PgPool getPool() { PgPool ret = pool.get(); if(ret == null) { ret = pgClientFactory.sqlClient(POOL_SIZE); pool.set(ret); } return ret; }
Example #3
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 2 votes |
public static Multi<Fruit> findAll(PgPool client) { return client.query("SELECT id, name FROM fruits ORDER BY name ASC").execute() .onItem().produceMulti(set -> Multi.createFrom().items(() -> StreamSupport.stream(set.spliterator(), false))) .onItem().apply(Fruit::from); }
Example #4
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 2 votes |
public static Uni<Fruit> findById(PgPool client, Long id) { return client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id)) .onItem().apply(RowSet::iterator) .onItem().apply(iterator -> iterator.hasNext() ? from(iterator.next()) : null); }
Example #5
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 2 votes |
public Uni<Boolean> update(PgPool client) { return client.preparedQuery("UPDATE fruits SET name = $1 WHERE id = $2").execute(Tuple.of(name, id)) .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1); }
Example #6
Source File: PgClientFactory.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 2 votes |
PgPool sqlClient(int size) { PoolOptions options = new PoolOptions(); PgConnectOptions connectOptions = new PgConnectOptions(); Matcher matcher = Pattern.compile(PG_URI_MATCHER).matcher(url); matcher.matches(); connectOptions.setDatabase(matcher.group(3)); connectOptions.setHost(matcher.group(1)); connectOptions.setPort(Integer.parseInt(matcher.group(2))); connectOptions.setUser(user); connectOptions.setPassword(pass); connectOptions.setCachePreparedStatements(true); options.setMaxSize(size); return PgPool.pool(vertx, connectOptions, options); }
Example #7
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 1 votes |
public Uni<Long> save(PgPool client) { return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)").execute(Tuple.of(name)) .onItem().apply(pgRowSet -> pgRowSet.iterator().next().getLong("id")); }
Example #8
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 1 votes |
public Uni<Boolean> update(PgPool client) { return client.preparedQuery("UPDATE fruits SET name = $1 WHERE id = $2").execute(Tuple.of(name, id)) .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1); }
Example #9
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 1 votes |
public static Uni<Boolean> delete(PgPool client, Long id) { return client.preparedQuery("DELETE FROM fruits WHERE id = $1").execute(Tuple.of(id)) .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1); }
Example #10
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 1 votes |
public Uni<Long> save(PgPool client) { return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING (id)").execute(Tuple.of(name)) .onItem().apply(pgRowSet -> pgRowSet.iterator().next().getLong("id")); }
Example #11
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | 1 votes |
public static Uni<Boolean> delete(PgPool client, Long id) { return client.preparedQuery("DELETE FROM fruits WHERE id = $1").execute(Tuple.of(id)) .onItem().apply(pgRowSet -> pgRowSet.rowCount() == 1); }
Example #12
Source File: Fruit.java From quarkus-quickstarts with Apache License 2.0 | votes |
public static Uni<Fruit> findById(PgPool client, Long id) { return client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id)) .onItem().apply(RowSet::iterator) .onItem().apply(iterator -> iterator.hasNext() ? from(iterator.next()) : null); }