Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

237
Vistas
mongodb compatibility with documentdb

We have a spring boot application (2.2.2) which uses mongodb. As we want to deploy it in AWS we need to migrate to DocumentDB. But when we migrate, things which were working in MongoDB are no longer working. See the following code:

public int getCount(String collection, List<Bson> pipeline, MongoTemplate mongoTemplate) {

    List<Bson> newpipeline = new ArrayList<Bson>();
    newpipeline.addAll(pipeline);

    String cntStr = "{$group:{_id:null, val:{'$sum':1}}}";
    newpipeline.add(BasicDBObject.parse(cntStr));

    MongoDatabase mongo = mongoTemplate.getDb();

    int count = 0;

    try {
        count = mongo.getCollection(collection).aggregate(newpipeline).first().getInteger("val");
    } catch (NullPointerException e) {

    } catch (Exception e) {
        e.printStackTrace();
    }

    return count;
}

This works in mongodb, but not in documentdb.Gives error like:

{"timestamp":"2021-03-29T08:29:58.101+0000","status":500,"error":"Internal Server Error","message":"Command failed with error 18537: 'Could not convert date to string: date component was outside the supported range of 0-9999: 10000' on server xxxx-manager-document-db.cn30hpxqos6b.eu-central-1.docdb.amazonaws.com:27017. The full response is {\"ok\": 0.0, \"operationTime\": {\"$timestamp\": {\"t\": 1617006598, \"i\": 1}}, \"code\": 18537, \"errmsg\": \"Could not convert date to string: date component was outside the supported range of 0-9999: 10000\"}","path":"/pmt/api/v1/pm/analytics/getKpiByDimension"}

Is it possible that some of the cursor apis do not work in documentDB?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Another option that you have is to install MongoDB on an EC2 instance then you can use the MongoDB API within a Spring BOOT Application. To learn how to install MongoDB on EC2, see:

Install and configure MongoDB community edition

There is an example of creating a Spring BOOT app that uses MongoDB to store application data here.

Creating the MongoDB web application item tracker

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda