Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda