コード例 #1
0
 private void findUsers(Handler<List<User>> handler, JsonObject query) {
   mongo.find(
       USER,
       query,
       result -> {
         if (result.failed()) {
           // error handling
         }
         List<User> lookupResults = JsonConverter.fromJsonList(result.result(), User.class);
         handler.handle(lookupResults);
       });
 }
コード例 #2
0
  @Override
  public void addUser(Handler<String> handler, User user) {
    String json = new Gson().toJson(user);
    JsonObject document = new JsonObject(json);

    mongo.insert(
        USER,
        document,
        res -> {
          // TODO
          // Check if the username already exists

          if (res.succeeded()) {
            handler.handle(res.result());
          } else {
            res.cause().printStackTrace();
          }
        });
  }
コード例 #3
0
 @Override
 public void start() {
   MongoClientProvider.setClient(MongoClient.createShared(vertx, new JsonObject()));
   registerServices();
   createServer();
 }