Equivalent of $objectToArray using Mongodb java driver 3

Equivalent of $objectToArray using Mongodb java driver 3

I am moving a Mongodb query from Javascript to Java. The object format is as follows:

I am moving a Mongodb query from Javascript to Java. The object format is as follows:

{
  "record": {
    "unknownName1": {
      "count": 5,
      "domain": "domain1"
    }, {
    ...
    }, {
    "unknownNameN": {
      "count": 3,
      "domain": "domainN"
    }
  }
}

The Javascript query has the following portion:

[
  { 
    $project: {
      record: { 
        $objectToArray: "$record" 
      }
    }
  }, {
    $unwind: { "$record"
  }, {
    $group: {
      device: "$record.k"
    }, 
    count: {
      $sum: "$record.v.count"
    },
    domain: {
      $min: "$record.v.domain"
    }
  }
]

I have translated the above to use the Mongodb Java Driver 3 api and have the following:

List<Bson> query = Arrays.asList(
    project(include("record")),
    unwind("$record"),
    group(computed("device", "$record.k"),
        sum("count", "$record.v.count"),
        min("domain", "$record.v.domain"))
);

The issue I am having is I can't seem to find an equivalent to $objectToArray using the Mongodb Java Driver and the subsequent sum and min operations depend on dot operating the k and v values generated from using $objectToArray.

Is there an equivalent way to map an object with unknown key names into the k and v format used by $objectToArray using the Mongodb Java Driver, preferrably version 3+?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Build a CRUD API with Java, MongoDB, and Spring Boot

This tutorial shows how to build a CRUD API with Java, MongoDB, and Spring Boot. How to build a CRUD API with Java and MongoDB. In this tutorial, you create a Java data model class and mapped it to a MongoDB domain document using Spring Data annotations. You use a simple embedded MongoDB database as the datastore. You use Spring Boot to quickly and easily expose your data model via a REST API. Finally, you secured the REST API using Okta and Okta’s Spring Boot Starter.

Developing Apps with MongoDB and Java

Want to get started with MongoDB and Java? Developing Apps with MongoDB and Java - Learn how to set up your Java project with Maven and execute a MongoDB command in Java.

CRUD Operations in MongoDB & Java | Tutorial with Examples

Learn how to use MongoDB with Java in this tutorial on CRUD operations with example code and walkthrough. Learn how to set up your Java project with Maven and execute a MongoDB command in Java. Then we will explore all the CRUD operations using the MongoDB Java driver.