Import and merge Neo4j graph data models
Use File › Import… to bring in a model from pasted JSON, a file, or the schema of an existing Neo4j database. You can also turn a list of names into nodes. Open the import as a new model or add it to the one you have open. When nodes have the same labels, you decide whether to merge them.
Ways to import
- Paste a model's JSON into the Import dialog, or click Choose file… and pick a JSON file.
- Drop a JSON file anywhere in the window. On a blank model, it opens right away. Otherwise, the Import dialog opens with the file ready to import. Drop several files at once, and we add them one after another, each in a layer named after its file.
- Paste a list of names (one per line, or cells copied from a spreadsheet) into the Import dialog, or press ⌘V (Ctrl+V on Windows) on the canvas. Each name becomes the label of a new node, laid out in the same rows and columns as the list you pasted, in a layer called "Pasted names".
- Choose Neo4j database under Import from, run the two queries we provide, and paste the results. For step-by-step instructions, see Draw the schema of an existing Neo4j database.
Every import applies Neo4j's naming conventions to labels, relationship types, and property keys. A pasted model with no name is called "Imported model" (or "Imported model 2", and so on, if that name is taken).
If a file or pasted JSON isn't a model, is empty, or is damaged, toro4n doesn't import it and tells you why. For a damaged file, the message also names the first problem and where in the file it occurs.
Open as a new model or add to the open one
Choose Open as a new model to keep the import separate from the model you have open, or Add to the open model to combine the two. Adding places the new nodes beside your existing ones, selects them, and zooms to show the whole model. Either way, everything you import goes into a new layer. Name it in Layer for this import, or leave the field blank to use the imported model's name. Layers from the imported model aren't carried over.
To import without reaching for the mouse, press Enter in the layer field, or ⌘Enter (Ctrl+Enter on Windows) in the text box.
Merging nodes with the same labels
If nodes have the same labels, whether within the import, within the open model, or across the two, toro4n asks "Merge nodes with the same labels?" It lists the nodes and shows both spellings where they differ (Order / order). Merge combines each set of matching nodes into one node that keeps all of their properties and relationships. Keep separate leaves every node as it is and marks the duplicates with a red ring. toro4n never merges anything without asking.
What happens when nodes merge
- Nodes with the same labels become one; nodes without labels never merge.
- The open model's properties keep their order, and new properties are added at the end. An empty type or example is filled in from the import.
- When merging leaves two relationships of the same type between the same two nodes, they become one. Other relationships from the import are added, and any that pointed at a duplicate now point at the merged node.
- A property that's unique or required in either model stays that way after the merge.
- Attached notes stay with what they're attached to. A note with the same text as one already on the merged node isn't added twice, and a note that would cover another is placed below it.
- When an imported node merges into an existing one, the existing node also joins the import's layer. Hiding that layer hides everything the import added, while merged nodes stay visible in their original layers.
Reviewing differences
If the same property has a different type or example in the two models, toro4n shows you each difference before changing anything. Choose Keep (the default) or Use imported for each one, or settle them all at once with Keep all or Use all imported. Whatever you choose, you can undo the whole import in one step.