C
C
Crunchor2021-07-05 15:48:46
Java
Crunchor, 2021-07-05 15:48:46

How are maps stored in mongodb?

There is a class in java

public class MyClass {
    String id;
    Map<String, String> params;
}

How will this class be stored in mongodb?
Tried something like this, but he refuses to mapitsya.
{
    "id" : "ABC",
    "params" : {
        "param1" : "value1",
        "param2" : "value2" 
   }
}

PS The example is super simplified.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rag'n' Code Man, 2021-07-07
@iDmitriyWinX

In our CRM system, we store the students' schedule using map. Key — group id, Value — its schedule (array of day information objects).
The end result is something like this:

localSchedule: {
    "id1": [{}, {}]
}

But our project uses NodeJS and a special ODM to work with the database, so maybe under the hood it just turns it into JSON.
Well, maybe you will find a solution here: https://docs.mongodb.com/manual/reference/operator...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question