spring-data-mongodb

Listen on changes through spring-webflux and spring reactive data

主宰稳场 提交于 2021-02-20 13:32:20
问题 TL;DR; Is it possible to listen on changes through spring-webflux & spring reactive data ? End of TL;DR; Hi, I did few tutorials regarding new spring webflux module and spring mongo reactive. (correct me If I'm wrong) There are two basic types in reactive spring, Mono (for 0 or single object) and Flux (0 - n) objects. If I return a Flux json object ( a list of all comments) then my client is going to receive them in one response (not in chunks or something). I did it here, I also can change

How to select between dates Spring data MongoDB using @Query

人盡茶涼 提交于 2021-02-19 06:53:05
问题 I'm using Spring data with MongoDB and i need to find between actual day and 7 days ahead. I have create repsoitories with @Query annotation and don't like to user Criteria class. Do you have some idea how to user between with @Query? thanks in advance. 回答1: You can try below query. Using @Query annotation @Query(value = "{'date':{ $lt: ?0, $gt: ?1}}") List<SomeClass> findByDateBetween(Instant from, Instant to); Or Using repository supported keywords List<SomeClass> findByDateBetween(Instant

How to select between dates Spring data MongoDB using @Query

青春壹個敷衍的年華 提交于 2021-02-19 06:52:09
问题 I'm using Spring data with MongoDB and i need to find between actual day and 7 days ahead. I have create repsoitories with @Query annotation and don't like to user Criteria class. Do you have some idea how to user between with @Query? thanks in advance. 回答1: You can try below query. Using @Query annotation @Query(value = "{'date':{ $lt: ?0, $gt: ?1}}") List<SomeClass> findByDateBetween(Instant from, Instant to); Or Using repository supported keywords List<SomeClass> findByDateBetween(Instant

How to select between dates Spring data MongoDB using @Query

纵饮孤独 提交于 2021-02-19 06:52:09
问题 I'm using Spring data with MongoDB and i need to find between actual day and 7 days ahead. I have create repsoitories with @Query annotation and don't like to user Criteria class. Do you have some idea how to user between with @Query? thanks in advance. 回答1: You can try below query. Using @Query annotation @Query(value = "{'date':{ $lt: ?0, $gt: ?1}}") List<SomeClass> findByDateBetween(Instant from, Instant to); Or Using repository supported keywords List<SomeClass> findByDateBetween(Instant

MongoDB 4.x Real Time Sync to ElasticSearch 6.x +

喜夏-厌秋 提交于 2021-02-19 02:56:06
问题 I'm trying to find an easy way to sync data in mongoDB 4.x, to elasticsearch 6.x . My use case is for partial text search that is supported by elasticsearch but no supported by mongodb. MongoDB is the primary database for my applications. All solutions i found seem outdated and only support older version of mongoDB / elasticsearch. These include mongodb-connector, mongodb river What is the best tool to use so that any changes (CRUD) to data in mongoDB is automatically synced to elasticsearch?

Why spring data mongo not returning the field having time?

筅森魡賤 提交于 2021-02-17 05:45:28
问题 I have a document in my collection like { "_id" : ObjectId("5e3aaa7cdadc161d9c3e8014"), "carrierType" : "AIR", "carrierCode" : "TK", "flightNo" : "2134", "depLocationCode" : "DEL", "arrLocationCode" : "LHR", "depCountryCode" : "DELHI", "arrCountryCode" : "LONDON", "scheduledDepDateTime" : ISODate("2020-02-05T00:30:00Z") } { "_id" : ObjectId("5e3aaacddadc161d9c3e8015"), "carrierType" : "AIR", "carrierCode" : "TK", "flightNo" : "2021", "depLocationCode" : "DEL", "arrLocationCode" : "LHR",

How to initialize MongoClient once in spring boot and export it to use its methods?

点点圈 提交于 2021-02-12 11:33:32
问题 Hello I am trying to export the MongoClient after a successful connection in Spring Boot and I am trying to use it in other files so that I do not have to call the connection every single time that I need to make changes in my MongoDB database. The connection is pretty simple but the goal would be to connect the application to my database once and then use it wherever I want by importing it in any Java file. Thank you 回答1: Here are couple of ways of creating an instance of MongoClient ,

How to initialize MongoClient once in spring boot and export it to use its methods?

久未见 提交于 2021-02-12 11:33:21
问题 Hello I am trying to export the MongoClient after a successful connection in Spring Boot and I am trying to use it in other files so that I do not have to call the connection every single time that I need to make changes in my MongoDB database. The connection is pretty simple but the goal would be to connect the application to my database once and then use it wherever I want by importing it in any Java file. Thank you 回答1: Here are couple of ways of creating an instance of MongoClient ,

Implementing MongoDB i18n with Spring Data

て烟熏妆下的殇ゞ 提交于 2021-02-11 17:44:47
问题 I'm looking for an elegant solution for persisting localized data in MongoDB in my Spring application. In the example below there is a basic solution for persisting localized data for the field description . As already suggested in how-to-do-i18n-with-mongodb the schema for localized data is "description": [{ "locale": "es", "value": "someESvalue" }, { "locale": "en", "value": "someENvalue" }] Given that, the entity looks like this: @Document(collection = "foo") public class Foo implements

Spring Data - MongoDB - JUnit test

点点圈 提交于 2021-02-10 09:33:06
问题 I would have a question concerning Spring Data - MongoDB and JUnit test. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = { UserRepository.class, User.class }) public class MyJUnitTest { The UserRepository looks like this: @Repository public interface UserRepository extends MongoRepository<User, String> { User findByUsername(final String username); } I get the following Exception: Failed to instantiate [... .repository.UserRepository]: Specified class is an