How to create dynamically collection using Device Sync(realm-sync)

Is it possible to create dynamic collection using realm-sync and mongodb through Device Sync?

Do you mind elaborating on what you mean by a dynamic collection? I assume you are referencing having no schema, but not entirely sure.

Best,
Tyler

Hi Tyler,

I’ve a database which contains multiple collection(we call as a group). So is it possible to create a dynamic collection from a device sync function or any other way? Like I explain you as below screenshot

Screenshot 2023-11-02 at 3.12.23 PM

Hi @Tyler_Kaye,

Moreover, I’ve the requirement to create Group chat mobile app, with around 1M+ concurrent users. So I need to create dynamic collection(group) using device sync functions or any other way. So would it be possible or not?

Thanks,
Vishal

We do not support that architecture unfortunately, the reason being that each realm table name needs to map to a MongoDB namespace (db/collection). If you really wanted to, you could have that architecture but each of your realm table’s would need to be named something like todo_group1 and that would not be fun for you. I would strongly encourage you to not structure your data like this in general though. If you read a bit more about MongoDB’s suggested approached to multi-tenant architecture, it is an anti-pattern to try to split everything into its own collections (instead they should be in the same collection with an index on the field that “partitions” them).

As for this, I am not entirely sure I understand what you are suggesting / asking here. Do you mind elaborating?

Best,
Tyler