本文整理匯總了Java中org.springframework.data.mongodb.core.MongoOperations.dropCollection方法的典型用法代碼示例。如果您正苦於以下問題:Java MongoOperations.dropCollection方法的具體用法?Java MongoOperations.dropCollection怎麽用?Java MongoOperations.dropCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.data.mongodb.core.MongoOperations
的用法示例。
在下文中一共展示了MongoOperations.dropCollection方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner init(MongoOperations operations) {
return args -> {
// tag::log[]
operations.dropCollection(Image.class);
operations.insert(new Image("1",
"learning-spring-boot-cover.jpg"));
operations.insert(new Image("2",
"learning-spring-boot-2nd-edition-cover.jpg"));
operations.insert(new Image("3",
"bazinga.png"));
operations.findAll(Image.class).forEach(image -> {
System.out.println(image.toString());
});
// end::log[]
};
}
示例2: init
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner init(MongoOperations operations) {
return args -> {
// tag::log[]
operations.dropCollection(Image.class);
operations.insert(new Image("1",
"learning-spring-boot-cover.jpg", "greg"));
operations.insert(new Image("2",
"learning-spring-boot-2nd-edition-cover.jpg", "greg"));
operations.insert(new Image("3",
"bazinga.png", "phil"));
operations.findAll(Image.class).forEach(image -> {
System.out.println(image.toString());
});
// end::log[]
};
}
示例3: initializeUsers
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner initializeUsers(MongoOperations operations) {
return args -> {
operations.dropCollection(User.class);
operations.insert(
new User(
null,
"greg", "turnquist",
new String[]{"ROLE_USER", "ROLE_ADMIN"}));
operations.insert(
new User(
null,
"phil", "webb",
new String[]{"ROLE_USER"}));
operations.findAll(User.class).forEach(user -> {
System.out.println("Loaded " + user);
});
};
}
示例4: init
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner init(MongoOperations operations) {
return args -> {
// tag::log[]
operations.dropCollection(Image.class);
operations.insert(new Image("1",
"learning-spring-boot-cover.jpg", "greg"));
operations.insert(new Image("2",
"learning-spring-boot-2nd-edition-cover.jpg", "greg"));
operations.insert(new Image("3",
"bazinga.png", "greg"));
operations.findAll(Image.class).forEach(image -> {
System.out.println(image.toString());
});
// end::log[]
};
}
示例5: init
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner init(MongoOperations operations) {
return args -> {
operations.dropCollection(Image.class);
operations.insert(new Image("1",
"learning-spring-boot-cover.jpg"));
operations.insert(new Image("2",
"learning-spring-boot-2nd-edition-cover.jpg"));
operations.insert(new Image("3",
"bazinga.png"));
operations.findAll(Image.class).forEach(image -> {
System.out.println(image.toString());
});
};
}
示例6: onStart
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
/**
* Application runner to initialize a capped collection for {@link Event}s and insert a new {@link Event} every two
* seconds.
*
* @param operations
* @param reactiveOperations
* @return
*/
@Bean
ApplicationRunner onStart(MongoOperations operations, ReactiveMongoOperations reactiveOperations) {
return args -> {
CollectionOptions options = CollectionOptions.empty() //
.capped() //
.size(2048) //
.maxDocuments(1000);
operations.dropCollection(Event.class);
operations.createCollection(Event.class, options);
Flux.interval(Duration.ofSeconds(2)) //
.map(counter -> new Event(LocalDateTime.now())) //
.flatMap(reactiveOperations::save) //
.log() //
.subscribe();
};
}
示例7: commandLineRunner
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner commandLineRunner(MongoOperations operations) {
return (args) -> {
// Setup the streaming data endpoint
if (operations.collectionExists("tightCouplingEvent")) {
operations.dropCollection("tightCouplingEvent");
}
if (operations.collectionExists("query")) {
operations.dropCollection("query");
}
CollectionOptions options = new CollectionOptions(5242880, 100000, true);
operations.createCollection("tightCouplingEvent", options);
};
}
示例8: done
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Override
public void done(Description description) {
super.done(description);
MongoOperations mongoOperation = Application.getMongoOperations();
mongoOperation.dropCollection(Infracao.class);
mongoOperation.dropCollection(Logradouro.class);
}
示例9: truncate
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
/**
* {@link MongoInitialize#truncate()}で<code>true</code>が指定されたときにMongoDBより指定されたCollectionをすべて削除します。
* @param operations {@link MongoOperations}
* @param config {@link MongoInitialize}
*/
protected void truncate(MongoOperations operations, MongoInitialize config) {
if (config.truncate()) {
L.info(Strings.substitute(R.getString("I-MONGO-TEST#0002"), Maps.hash("collectionName", config.collectionName())));
operations.dropCollection(findCollectionName(config));
}
}
示例10: setUp
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner setUp(MongoOperations operations) {
return args -> {
operations.dropCollection(Comment.class);
};
}
示例11: done
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Override
public void done(Description description) {
MongoOperations mongoOperation = Application.getMongoOperations();
mongoOperation.dropCollection(Condutor.class);
mongoOperation.dropCollection(Veiculo.class);
}
示例12: done
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Override
public void done(Description description) {
MongoOperations mongoOperation = Application.getMongoOperations();
mongoOperation.dropCollection(Veiculo.class);
mongoOperation.dropCollection(Condutor.class);
}
示例13: dropDB
import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
/**
* Drop DB.
*
* @param mongoOperation
* the mongo operation
*/
static void dropDB(MongoOperations mongoOperation) {
mongoOperation.dropCollection(Oferta.class);
}