當前位置: 首頁>>代碼示例>>Java>>正文


Java MongoOperations.dropCollection方法代碼示例

本文整理匯總了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[]
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:20,代碼來源:InitDatabase.java

示例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[]
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:20,代碼來源:InitDatabase.java

示例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);
		});
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:22,代碼來源:InitUsers.java

示例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[]
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:20,代碼來源:InitDatabase.java

示例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());
		});
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:18,代碼來源:InitDatabase.java

示例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();
	};
}
 
開發者ID:olivergierke,項目名稱:spring-five-functional-reactive,代碼行數:29,代碼來源:WebfluxDemo.java

示例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);
    };
}
 
開發者ID:kbastani,項目名稱:service-block-samples,代碼行數:16,代碼來源:MongoConfig.java

示例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);
}
 
開發者ID:UNGPublic,項目名稱:sampleng-backend,代碼行數:8,代碼來源:InfracaoResourceCondition.java

示例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));
    }
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:12,代碼來源:TestMongoKeeper.java

示例10: setUp

import org.springframework.data.mongodb.core.MongoOperations; //導入方法依賴的package包/類
@Bean
CommandLineRunner setUp(MongoOperations operations) {
	return args -> {
		operations.dropCollection(Comment.class);
	};
}
 
開發者ID:PacktPublishing,項目名稱:Learning-Spring-Boot-2.0-Second-Edition,代碼行數:7,代碼來源:CommentService.java

示例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);
}
 
開發者ID:UNGPublic,項目名稱:sampleng-backend,代碼行數:7,代碼來源:CondutorResourceCondition.java

示例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);
}
 
開發者ID:UNGPublic,項目名稱:sampleng-backend,代碼行數:7,代碼來源:VeiculoResourceCondition.java

示例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);

}
 
開發者ID:acardoco,項目名稱:crauler_ISI,代碼行數:11,代碼來源:MongoFunctions.java


注:本文中的org.springframework.data.mongodb.core.MongoOperations.dropCollection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。