Search code examples
node.jsdatabasemongodbparse-platform

How to clone Mongo DB schema from URI (clone only schema, no data)


TL;DR: a nutshell: I want to copy all classes with their columns (column names and type), but without data, from a URI

uri example: mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]

I'm looking for a method/library/suggestion to clone a Mongo db Schema from a Mongo URI. I do not have access to the IU (in order to export schema).

I'm using a Parse Server app, so I can manipulate the data and schema, but it's required to be able to clone the schema recurrently with a cronjob. (no manual copies then).

I found a couple of libraries that can be used to clone databases, or create a JSON file from a schema (plane mongo or using mongoose), but these alternatives does not take a URI, but uses a schema instanced by my own.

I hope a hand, suggestion, anything where to start.


Solution

  • I found two ways to achieve this:

    1. Using mongodb-compass and proceed with the UI assistant.

    2. Using mongodrdl: https://docs.mongodb.com/bi-connector/current/reference/mongodrdl/ (link provided by @semperlabs)