Hi,
I’m pretty new to work with mongo and I have a question, where I cannot find a good answer for.
The current circumstances are given:
- I have to use a quite old mongo version (4.0.28)
- I also have to use a quite old Java (jdk 8) + SpringFramework version 5.1.9
Also for my testcase I have the following simpel approach. One document with
an ID, name, description, owner, createDate, updatedDate und permissionSet array.
Here one example:
{
"_id": {
"$oid": "64e31163e4b086f9c5a4fe6a"
},
"_class": "de.dmi.dmixcloud.core.model.TestObject",
"name": "RandomName: 0",
"description": "Random Description 0",
"owner": "5f0707690cf241886f45d125",
"creationDate": {
"$date": "2023-08-21T07:25:23.407Z"
},
"updatedDate": {
"$date": "2023-08-21T07:25:23.407Z"
},
"permissionsSet": []
}
Now it goes about the permissionSet-Array. This will keep a list of all user ids which have access to this document. It can be that several thousand users will have access to it. That means this array will contain easily thousands of strings.
Now I recorgnized, that as bigger that array is as slower is a $push call working. Not tried what about quering of this array right now.
I’m clear that I try to do relations in a document based database, but this is something I cannot change right now. Question is now, is there a better approach to model this, instead of keeping all users which have access in a long list. I also thought about to have some kind of relation collection, with userid and document id as compound key, and then working with aggregations if I want to ask for all documents where user XY has access to.
It looks like a realtive “normal” problem, so I’m not sure why I found so little about it, maybe I’m searching jsut wrong. Maybe someone can help me, which approach is the best in terms of runtime.
Thanks and best
Andreas