Programmatically duplicate Realm Apps

Disclaimer: Realm Newbie

Please think of my project similar to a website builder, where websites are created through an admin web app. Each new website requires it’s own MongoDB database and Realm App.

The database stuff is all fine and achievable through the SDKs. I can also create the Realm App along with required functions through the Realm Administration API. However my Realm App needs a specific JSON schema (not generated) and custom resolvers. I cannot see any way that I can set those through the Administration API or the SDK. Am I missing it - it might be a terminology issue?

Currently the only way I can see to create a fully configured Realm App is through an import using the CLI which isn’t ideal from a web application programming perspective. Any assistance is much appreciated.

Hi @David_Peck, welcome to the community forum!

I’m not an expert on the MongoDB Realm CLI (you may attract better-qualified eyeballs in the “MongoDB Realm” category.

One API endpoint I did notice in the docs is generate_schema, which could work if you’d set up sample data?

Thanks for responding.

Unfortunately I don’t think so. The generate schema creates a schema from sample data but because unfortunately what it creates is not suitable for our needs so we have modified it. Also I think that call generates a schema for you, but I don’t know if it sets it or just returns it in the response.

As it’s a POST, I’d assumed that it would add the schema to the app, but the docs aren’t explicit.

I’ll dig a bit more to see if there’s something we’re missing.

1 Like

The answer is that it’s a work-in-progress. Currently you’d set the schema through the rules endpoint but it will be moved from there to a more specific endpoint very soon. So, the short-term recommendation is to use the CLI.

There may also be an undocumented endpoint that works at an app level that could be used. We’re checking if this is something suitable to use/document (and won’t become obsolete with the separation of schema and rules).

1 Like

That’s a great answer (albeit not the one I was hoping for). Thank you Andrew, and please do let me know if there are any undocumented endpoints.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.