MongoDB sub-document query limit / skip results?

I have an aggregate query that extracts subdocuments from a database in mongodb:

    (
      {
        $match: {
          username: query.username,
        },
      },
      {
        $project: {
          connections: {
            $filter: {
              input: '$connections',
              as: 'connections',
              cond: {
                $eq: ('$$connections.state', query.state),
              },
            },
          },
        },
      }
    )

The outline of the document looks like this (of typegoose, but quite explanatory):

export class Connection {
  @prop({ default: () => new Date() })
  public updated?: Date;

  @prop({ required: true, enum: ConnectionStateEnum })
  public state: ConnectionStateEnum;

  @prop({ required: true })
  public username: string;

  @prop()
  public requestIP?: string;

  @prop()
  public requestBrowserString?: string;
}

@modelOptions({
  schemaOptions: {
    collection: 'connections',
    timestamps: true,
  },
})
export class UserConnections {
  @prop({ default: v1 })
    /* tslint:disable */
  _id: string;
  /* tslint: enable */

  @prop({ unique: true })
  username: string;

  @prop({ required: true })
  lastConnectionActivityWithUsername: string;

  @arrayProp({ items: Connection })
  connections: Connection();
}

For the idea, a user has 1 document that contains his connections, therefore, the connections attribute is an array of connection objects.

If I add $ skip or $ limit to the added query, this will only result in the return of the same document, is it possible to limit / omit the number of connection objects to return within the query, or can it only be done after the query?

How is the MongoDB cursor implemented?

What happens in Mongo when you call to search and iterate over the cursor?

I mean, how is the cursor really implemented? I understand that when you call find, you will get reference to the cursor (or rather ID), which has a default timeout of 10 minutes. While alive, you can iterate over it and you will get data in batches. That is the extent of the information I found in the documents on how it works.

What I ask is, when I consult mongo, what does he really do once he finds results? Does it generate a list of document identifiers for the cursor to read and load real documents? Do you cache the actual resulting documents? How do you handle changes in documents when there is a live cursor? What are the performance and memory implications?

Thank you

update – Increase 5% to a value in MongoDB

I have the following code:

db.proyectos.update(
{"Días de Desviación":{$gte:5}},
{ $set: { "Costo":{$sum:{ $multiply: ( "$Costo", .05 ) } } }},
{ multi: true })

What I need is to increase the Cost already established by 5% but it throws me an error (I have to do everything from the shell)

The error that generates me is the following:
enter image description here

java – ExceptionInInitializerError when connecting to MongoDB with spring-boot-starter-data-mongodb

I have been investigating for more than 2 days to identify the error in this project but I have not had much success. I don't know if I'm doing the query wrong, but I didn't find much information related to the error I found.

I am making a java to mongodb connection in local environment using spring-boot-starter-data-mongodb. I have searched documentation and examples to build my MongoConfig class. In addition, I make use of spring-cloud-starter-config, which allows my .yml file to reference it from github.
However, when I run the application as SprinBootApplication, I get an exception ExceptionInInitializerError in MongoTemplate.
I will share the .yml, the classes I use and the exception generated:

In the .yml file I am declaring not only the URI, but also the connection data, although I don't use them all.

#HTTP Server
server:
  port: ${PORT:7000}

#Discovery Server Access
eureka:
  client:
    service-url:
      default-zone: http://localhost:8761/eureka
  instance:
    status-page-url-path: /infoMiClase
    health-check-url-path: /healthMiClase
    metadata-map:
       app-owner: Georgina
       description: Testing Microservice

spring:
  data:
    mongodb:
      uri: mongodb://user:pass@localhost:27017/db_name
      database: db_name
      port: 27017
      host: localhost
      username: user
      password: pass

This is the MongoConfig class:

@Configuration
@EnableMongoRepositories("com.x.package")
public class MongoConfig extends AbstractMongoClientConfiguration {

    @Value("${spring.data.mongodb.uri}")
    private String uri;

    @Value("${spring.data.mongodb.database}")
    private String database;

    @Bean
    @Override
    public MongoClient mongoClient() {
        //conString = "mongodb://user:passw@localhost:port/db_name
        return MongoClients.create(uri);
    }

    @Override
    protected String getDatabaseName() {
        return database;
    }

    @Override
    protected String getMappingBasePackage() {
        return "com.x.package";
    }

    @Bean
    @Override
    public MongoTemplate mongoTemplate() throws Exception {
        return new MongoTemplate(mongoClient(), getDatabaseName());
    }

    @Bean
    public MongoDbFactory dbFactoryBean() throws Exception {
        MongoDbFactory dbFactoryBean = new SimpleMongoClientDbFactory(mongoClient(), database);
        return dbFactoryBean;
    }

}

I have already tried to eliminate some of the methods, add others … and even so the error generated is identical.

Finally, this is my Application class:

@SpringBootApplication
@EnableDiscoveryClient
public class MyclassApplication {

    public static void main(String() args) {
        SpringApplication.run(MyclassApplication.class, args);
    }

}

And in the console the log is shown with the exception generated:

(INFO ) 2020-02-10 00:32:16 (restartedMain) ConfigServicePropertySourceLocator - Fetching config from server at : http://localhost:5000
(INFO ) 2020-02-10 00:32:17 (restartedMain) ConfigServicePropertySourceLocator - Located environment: name=x.package, profiles=(default), label=null, version=1099c5eddeec953f0a0f7ae271107c9bfef376e5, state=null
(INFO ) 2020-02-10 00:32:17 (restartedMain) PropertySourceBootstrapConfiguration - Located property source: CompositePropertySource {name='configService', propertySources=(MapPropertySource {name='configClient'})}
(INFO ) 2020-02-10 00:32:18 (restartedMain) RepositoryConfigurationDelegate - Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
(INFO ) 2020-02-10 00:32:18 (restartedMain) RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 77ms. Found 1 MongoDB repository interfaces.
(INFO ) 2020-02-10 00:32:18 (restartedMain) GenericScope - BeanFactory id=93880b7e-3900-3ff7-a938-2947239e7c50
(INFO ) 2020-02-10 00:32:19 (restartedMain) PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type (org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$73f21667) is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
(INFO ) 2020-02-10 00:32:19 (restartedMain) TomcatWebServer - Tomcat initialized with port(s): 7000 (http)
(INFO ) 2020-02-10 00:32:19 (restartedMain) Http11NioProtocol - Initializing ProtocolHandler ("http-nio-7000")
(INFO ) 2020-02-10 00:32:19 (restartedMain) StandardService - Starting service (Tomcat)
(INFO ) 2020-02-10 00:32:19 (restartedMain) StandardEngine - Starting Servlet engine: (Apache Tomcat/9.0.30)
(INFO ) 2020-02-10 00:32:19 (restartedMain) (/) - Initializing Spring embedded WebApplicationContext
(INFO ) 2020-02-10 00:32:19 (restartedMain) ContextLoader - Root WebApplicationContext: initialization completed in 2168 ms
(INFO ) 2020-02-10 00:32:19 (restartedMain) cluster - Cluster created with settings {hosts=(localhost:27017), mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
(INFO ) 2020-02-10 00:32:20 (cluster-ClusterId{value='5e40eae3e4e5e75d67d95154', description='null'}-localhost:27017) connection - Opened connection (connectionId{localValue:1, serverValue:41}) to localhost:27017
(INFO ) 2020-02-10 00:32:20 (cluster-ClusterId{value='5e40eae3e4e5e75d67d95154', description='null'}-localhost:27017) cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=(3, 6, 13)}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=3904400}
(WARN ) 2020-02-10 00:32:20 (restartedMain) AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'MyclassController': Unsatisfied dependency expressed through field 'MyclassService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'MyclassService': Unsatisfied dependency expressed through field 'MyclassRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyclassRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource (com/x/package/config/MongoConfig.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
(INFO ) 2020-02-10 00:32:20 (restartedMain) StandardService - Stopping service (Tomcat)
(INFO ) 2020-02-10 00:32:20 (restartedMain) ConditionEvaluationReportLoggingListener - 

(ERROR) 2020-02-10 00:32:20 (restartedMain) SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'MyclassController': Unsatisfied dependency expressed through field 'MyclassService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'MyclassService': Unsatisfied dependency expressed through field 'MyclassRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyclassRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource (com/x/package/config/MongoConfig.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'MyclassService': Unsatisfied dependency expressed through field 'MyclassRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyclassRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource (com/x/package/config/MongoConfig.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyclassRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource (com/x/package/config/MongoConfig.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1699) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1444) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource (com/x/package/config/MongoConfig.class): Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate (org.springframework.data.mongodb.core.MongoTemplate): Factory method 'mongoTemplate' threw exception; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1699) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1444) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: java.lang.ExceptionInInitializerError
    at java.text.RBTableBuilder.build(RBTableBuilder.java:107) ~(?:1.8.0_211)
    at java.text.RBCollationTables.(RBCollationTables.java:83) ~(?:1.8.0_211)
    at java.text.RuleBasedCollator.(RuleBasedCollator.java:300) ~(?:1.8.0_211)
    at java.text.RuleBasedCollator.(RuleBasedCollator.java:281) ~(?:1.8.0_211)
    at sun.util.locale.provider.CollatorProviderImpl.getInstance(CollatorProviderImpl.java:106) ~(?:1.8.0_211)
    at java.text.Collator.getInstance(Collator.java:242) ~(?:1.8.0_211)
    at java.text.Collator.getInstance(Collator.java:224) ~(?:1.8.0_211)
    at org.springframework.data.mongodb.core.convert.GeoConverters.(GeoConverters.java:71) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.convert.MongoCustomConversions.(MongoCustomConversions.java:55) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.getDefaultMongoConverter(MongoTemplate.java:2852) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:258) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:234) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at com.x.package.config.MongoConfig.mongoTemplate(MongoConfig.java:53) ~(classes/:?)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d.CGLIB$mongoTemplate$0() ~(classes/:?)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d$$FastClassBySpringCGLIB$$3f5863e6.invoke() ~(classes/:?)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~(spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~(spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d.mongoTemplate() ~(classes/:?)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~(?:1.8.0_211)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~(?:1.8.0_211)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~(?:1.8.0_211)
    at java.lang.reflect.Method.invoke(Method.java:498) ~(?:1.8.0_211)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    ... 24 more
Caused by: java.lang.RuntimeException: could not locate data
    at sun.text.normalizer.NormalizerImpl.(NormalizerImpl.java:60) ~(?:1.8.0_211)
    at java.text.RBTableBuilder.build(RBTableBuilder.java:107) ~(?:1.8.0_211)
    at java.text.RBCollationTables.(RBCollationTables.java:83) ~(?:1.8.0_211)
    at java.text.RuleBasedCollator.(RuleBasedCollator.java:300) ~(?:1.8.0_211)
    at java.text.RuleBasedCollator.(RuleBasedCollator.java:281) ~(?:1.8.0_211)
    at sun.util.locale.provider.CollatorProviderImpl.getInstance(CollatorProviderImpl.java:106) ~(?:1.8.0_211)
    at java.text.Collator.getInstance(Collator.java:242) ~(?:1.8.0_211)
    at java.text.Collator.getInstance(Collator.java:224) ~(?:1.8.0_211)
    at org.springframework.data.mongodb.core.convert.GeoConverters.(GeoConverters.java:71) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.convert.MongoCustomConversions.(MongoCustomConversions.java:55) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.getDefaultMongoConverter(MongoTemplate.java:2852) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:258) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:234) ~(spring-data-mongodb-2.2.4.RELEASE.jar:2.2.4.RELEASE)
    at com.x.package.config.MongoConfig.mongoTemplate(MongoConfig.java:53) ~(classes/:?)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d.CGLIB$mongoTemplate$0() ~(classes/:?)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d$$FastClassBySpringCGLIB$$3f5863e6.invoke() ~(classes/:?)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~(spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~(spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at com.x.package.config.MongoConfig$$EnhancerBySpringCGLIB$$745df10d.mongoTemplate() ~(classes/:?)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~(?:1.8.0_211)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~(?:1.8.0_211)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~(?:1.8.0_211)
    at java.lang.reflect.Method.invoke(Method.java:498) ~(?:1.8.0_211)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~(spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE)
    at 
    ... 24 more

As can be seen on line 15 and 16 of the console, if the connection to Mongo is made, but then the error is generated and the process is terminated. I'm using spring-boot-starter-parent with version 2.2.3.RELEASE.

Has something similar happened to someone? I suspect it is a minimal configuration that I am overlooking and I do not realize 🙁
Thanks for your help!

The size of mdodb datadir differs abnormally from the mongodb backup

I am working on relocating my mongodb data directory from its default path to a volume that is mounted from an SSD drive.
I know that every day, when I make a backup copy of the databases and before compressing them, I have a directory of more than 50 GB. but today I realized that the mongodb data directory just took 16 GB of my storage. So can you tell me what is the reason for this difference? And is it enough for me to achieve more speed if I relocate the mongodb data directory or not?

How to remove XFS file system warning in mongodb shell?

Every time I start a mongodb shell, I receive this annoying warning:

Server has startup warnings:
2020-02-01T08:54:27.220+0100 I  STORAGE  [initandlisten]
2020-02-01T08:54:27.220+0100 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-02-01T08:54:27.220+0100 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem

I understand that in some environments, this is useful. But in my particular case, I am using mongodb on a VPS server that has the ext4 file system preinstalled. There is no option to change that. And it is not necessary anyway: in this particular application, there are no performance problems and never will be. The server is already dominated for this application.

I was reviewing the documentation to find a command line option to suppress this warning message, but there is none. Or maybe there is, but I couldn't find it.

Resetting MongoDB data

Hello, I am starting to use MongoDB and I have the following problem … Every time I connect to the bank I can create my database, table, insert data normally … But always when I stop my instance or restart my computer, my data I had saved are no longer there, I think it is a configuration problem but I cannot identify them.

mongodb – Update object with mongoose without ID

I am trying to update my BD but it does not work, it does not update, the reason I do not use the default IDs of the DB, is because I only use one object from the whole array and random data from different servers.

var mesa = new Schema({
    mesas: Object,
    tienda: String,
    uri: String,
});

const MMesa = mongoose.model('MMesa', mesa);

Method

socket.on('client/mesas', (mes) => {
socket.broadcast.emit('server/mesas', mes);
//let contacto = new MMesa({ mesas: mes, tienda: mes.tienda, uri: mes.uri });
//contacto.save();
MMesa.findOne({ uri: mes.uri, tienda: mes.tienda }, (err, mesa) => {
  if (mesa) {
    mesa.mesas = mes;
    mesa.save();
  } else {
    let mesa = new MMesa({ mesas: mes, tienda: mes.tienda, uri: mes.uri });
    mesa.save();
  }
});
//MMesa.findOneAndUpdate({ tienda: mes.tienda, uri: mes.uri }, {$set,{ mesas: mes }});
});

Is it possible to make a backup of the users of the MongoDB administration database?

The title sums it up very well.
Essentially, what I ask is, is it possible to make a backup (maybe use mongodump?) Only users (accounts created for human users)?

ssl: encryption in transit does not work in MongoDB

I am using MongoDB 4.0.6 with a set of 3-node replicas. I am updating my cluster to use SSL, below are the following steps:

1) I generated the CA.pem, server.pem and client.pem file and updated it in my mongo configuration,

  dbPath: /xvdf/data/lib/mongodb
  journal:
    enabled: true
  engine: wiredTiger

systemLog:
  destination: file
  logAppend: true
  logRotate: reopen
  path: /var/log/mongodb/mongod.log

net:
  port: 27017
  bindIp: (IP address)
  ssl:
    mode: allowSSL
    PEMKeyFile: /etc/server.pem
    CAFile: /etc/ssl/ca.pem


processManagement:
  pidFilePath: /var/run/mongodb/mongod.pid

replication:
  replSetName: test

security:
  keyFile: /etc/mongodb-test-keyfile 

2) After updating my configuration, I restarted mongo, it started successfully with the SSL option.

3) Then I executed the db.adminCommand ({setParameter: 1, sslMode: "preferSSL"}) command to allow both SSL and non-SSL connections from the client.

4) After that, when I enabled SSL from the client side, I updated my API configuration with "SSL: true" and with certificates, I get the following error in the mongo log file:

"Error receiving client request: SSLHandshakeFailed: error in the certificate validation of the same SSL: error in signing the certificate"

Please help me on this as soon as possible.

Thank you.. 🙂