本文整理汇总了Java中io.vertx.ext.mongo.MongoClient.dropCollection方法的典型用法代码示例。如果您正苦于以下问题:Java MongoClient.dropCollection方法的具体用法?Java MongoClient.dropCollection怎么用?Java MongoClient.dropCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.mongo.MongoClient
的用法示例。
在下文中一共展示了MongoClient.dropCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dropAndCreate
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
private static void dropAndCreate(MongoClient db) {
db.dropCollection("users", drop -> {
if (drop.failed()) {
throw new RuntimeException(drop.cause());
}
List<JsonObject> users = new LinkedList<>();
users.add(new JsonObject()
.put("username", "pmlopes")
.put("firstName", "Paulo")
.put("lastName", "Lopes")
.put("address", "The Netherlands"));
users.add(new JsonObject()
.put("username", "timfox")
.put("firstName", "Tim")
.put("lastName", "Fox")
.put("address", "The Moon"));
for (JsonObject user : users) {
db.insert("users", user, res -> {
System.out.println("inserted " + user.encode());
});
}
});
}
示例2: testCreateDate
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
@Test
public void testCreateDate(TestContext context) {
Async async = context.async();
MongoClient mongoClient = context.get("mongoClient");
mongoClient.dropCollection(MongoDateExampleVerticle.COLLECTION_NAME, mongoHandler -> {
context.assertTrue(mongoHandler.succeeded());
context.assertFalse(mongoHandler.failed());
JsonObject person = new JsonObject()
.put("name", "Alan Turing")
.put("birthDate", "1912-06-23T16:07:37Z");
rule.vertx().eventBus().send("person.save", person, handler -> {
context.assertTrue(handler.succeeded());
context.assertFalse(handler.failed());
context.assertNotNull(handler.result());
mongoClient.count(MongoDateExampleVerticle.COLLECTION_NAME, new JsonObject(), countHandler -> {
context.assertTrue(countHandler.succeeded());
context.assertFalse(countHandler.failed());
context.assertEquals(1L, countHandler.result());
async.complete();
});
});
});
}
示例3: example11_3
import io.vertx.ext.mongo.MongoClient; //导入方法依赖的package包/类
public void example11_3(MongoClient mongoClient) {
mongoClient.dropCollection("mynewcollectionr", res -> {
if (res.succeeded()) {
// Dropped ok!
} else {
res.cause().printStackTrace();
}
});
}