I have a configuration application in Nodejs. It has a Component with name and uuid. A Component can have many Schemas. A Schema has a uuid, name, componentId, json. A Schema can have many Configurations. A Configuration has name, schemaId, json and uuid. A Schema can contain reference of many other Schemas in it. Now I want to create a functionality of exporting all the data from one instance of the application ( in json format in file ) and import it in another. What should be the simplest way to do it? a few questions are
- How to tell application what to export. for now i think there should be separate arrays for components, schemas and configurations. Like
{
components: ['id1', 'id2'],
schemas: ['s1', 's2'],
configuration: ['c1', 'c2'],
}
this data should be sent to application to return a file with all information that will later be used for importing in another instance
- The real question is how should my export file look like keeping in mind that dependencies are also involved and dependencies can also overlap. for example a schema can have many other schemas referenced in its json field. eg
schema1hasschema2andschema4as its dependencies. so there is another schemaschema5that also requireschema2. so while importing we have to make sure thatschema2should be saved first before savingschema1andschema5. how to represent such file that requires order as well as overlapped dependencies, making sure thatschema2is not saved twice while importing.jsonofschema1is shown below as an example
{
"$schema": "http://json-schema.org/draft-04/schema#",
"p1": {
"$ref": "link-to-schema2"
},
"p2": {
"$ref": "link-to-schema4"
},
}
- What should be the step wise sudo algorithm i should follow while importing.