private void placeOrder(Message<JsonObject> msg) { mongo.save("orders", msg.body(), save -> { // error handling if (save.failed()) { msg.fail(500, save.cause().getMessage()); return; } msg.reply(new JsonObject()); }); }
mongoClient.save("products", product1, id -> { System.out.println("Inserted id: " + id.result());
/** * Save a document in the specified collection * <p> * This operation might change <i>_id</i> field of <i>document</i> parameter * @param collection the collection * @param document the document * @param resultHandler result handler will be provided with the id if document didn't already have one * @return */ public io.vertx.rxjava.ext.mongo.MongoClient save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler) { delegate.save(collection, document, resultHandler); return this; }
@Override public MongoService save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler) { client.save(collection, document, resultHandler); return this; }
/** * Save a document in the specified collection * <p> * This operation might change <i>_id</i> field of <i>document</i> parameter * @param collection the collection * @param document the document * @param resultHandler result handler will be provided with the id if document didn't already have one * @return */ public io.vertx.rxjava.ext.mongo.MongoClient save(String collection, JsonObject document, Handler<AsyncResult<String>> resultHandler) { delegate.save(collection, document, resultHandler); return this; }
@Override public void saveStore(Store store, Handler<AsyncResult<Void>> resultHandler) { client.save(COLLECTION, new JsonObject().put("_id", store.getSellerId()) .put("name", store.getName()) .put("description", store.getDescription()) .put("openTime", store.getOpenTime()), ar -> { if (ar.succeeded()) { resultHandler.handle(Future.succeededFuture()); } else { resultHandler.handle(Future.failedFuture(ar.cause())); } } ); }
public static io.vertx.ext.mongo.MongoClient save(io.vertx.ext.mongo.MongoClient j_receiver, java.lang.String collection, java.util.Map<String, Object> document, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.save(collection, document != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(document) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>() { public void handle(io.vertx.core.AsyncResult<java.lang.String> ar) { resultHandler.handle(ar.map(event -> event)); } } : null)); return j_receiver; } public static io.vertx.ext.mongo.MongoClient saveWithOptions(io.vertx.ext.mongo.MongoClient j_receiver, java.lang.String collection, java.util.Map<String, Object> document, io.vertx.ext.mongo.WriteOption writeOption, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> resultHandler) {
@Override public void updateModules(String id, SortedMap<String, Boolean> enabled, Handler<ExtendedAsyncResult<Void>> fut) { JsonObject jq = new JsonObject().put("_id", id); cli.find(COLLECTION, jq, gres -> { if (gres.failed()) { logger.debug("disableModule: find failed: " + gres.cause().getMessage()); fut.handle(new Failure<>(INTERNAL, gres.cause())); } else { List<JsonObject> l = gres.result(); if (l.isEmpty()) { logger.debug("disableModule: not found: " + id); fut.handle(new Failure<>(NOT_FOUND, messages.getMessage("1100", id))); } else { JsonObject d = l.get(0); final Tenant t = decodeTenant(d); t.setEnabled(enabled); JsonObject document = encodeTenant(t, id); cli.save(COLLECTION, document, sres -> { if (sres.failed()) { logger.debug("TenantStoreMongo: disable: saving failed: " + sres.cause().getMessage()); fut.handle(new Failure<>(INTERNAL, sres.cause())); } else { fut.handle(new Success<>()); } }); } } }); }
@Override public void insertUser(String username, String password, List<String> roles, List<String> permissions, Handler<AsyncResult<String>> resultHandler) { JsonObject principal = new JsonObject(); principal.put(getUsernameField(), username); if (roles != null) { principal.put(roleField, new JsonArray(roles)); } if (permissions != null) { principal.put(permissionField, new JsonArray(permissions)); } MongoUser user = new MongoUser(principal, this); if (getHashStrategy().getSaltStyle() == HashSaltStyle.COLUMN) { principal.put(getSaltField(), DefaultHashStrategy.generateSalt()); } String cryptPassword = getHashStrategy().computeHash(password, user); principal.put(getPasswordField(), cryptPassword); mongoClient.save(getCollectionName(), user.principal(), resultHandler); }