Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!