任何人都知道如何将不确定的参数传递给client.preparedQuery
?请看下面的图片,感谢任何帮助!
@Override
public Future<List<User>> getByIds(List<String> ids) {
Promise<List<User>> promise = Promise.promise();
// How to pass the uncertain parameters to preparedQuery?
pool.preparedQuery("SELECT * FROM users WHERE id IN ($1)", Tuple.wrap(ids.toArray()), ar -> {
if (ar.succeeded()) {
RowSet<Row> rows = ar.result();
List<User> users = new ArrayList<>();
for (Row row : rows) {
User user = User.fromDatabaseRow(row);
users.add(user);
}
promise.complete(users);
} else {
promise.fail(ar.cause());
}
});
return promise.future();
}