Article
· Apr 4, 2022 12m read

Store Mindmaps using Globals

  

Globals are the core of the InterSystems IRIS for data persistence. It is flexible, allowing store JSON documents, relational data, object oriented data, OLAP cubes and custom data models, like Mindmaps. To see how to store, delete and get mindmap data using globals, follow these steps:

1. Clone/git pull the repo into any local directory

$ git clone https://github.com/yurimarx/global-mindmap.git

2. Open a Docker terminal in this directory and run:

$ docker-compose build

3. Run the IRIS container:

$ docker-compose up -d

4. Go to http://localhost:3000 to use the Mindmap frontend and create mindmaps like above mindmap.

 

The source code for this sample

Data to be stored (see more in: https://www.npmjs.com/package/mind-elixir):

{
  topic: 'node topic',
  id: 'bd1c24420cd2c2f5',
  style: { fontSize: '32', color: '#3298db', background: '#ecf0f1' },
  parent: null,
  tags: ['Tag'],
  icons: ['😀'],
  hyperLink: 'https://github.com/ssshooter/mind-elixir-core',
}

Pay attention to the parent property, it is used to build parent/children relationships between mindmap nodes.

Source code to store mindmap node using global

 
ClassMethod StoreMindmapNode

It was created a global called ^mindmap. For each mindmap property it is stored in a global subscript. The subscript key is the mindmap id property.

Source Code to Delete Mindmap node - kill the global

 
ClassMethod DeleteMindmapNode

This sample used mindmap.id to be the mindmap global key, so to delete is easy: call Kill ^mindmap(<mindmap id>)

Source code to Get all content stored - Looping globals with $ORDER

 
ClassMethod GetMindmap - return all mindmap global nodes

It was used $Order(^mindmap("")) - empty "" - to get the first mindmap global ocurrence (root node). For each property value it was used ^mindmap(Key,<property name>). Finally, it was called $Order(^mindmap(Key)) to get the next ocurrence.

Frontend 

Mind-elixir and React were used for render and edit the mindmap, consuming API backend built using IRIS. See the mindmap react component:

 
Mindmap React component - consuming IRIS REST API

If you liked - vote in my app on Globals Contest. Thanks!

Discussion (2)1
Log in or sign up to continue

Hi Yuri,  

Your video is now on InterSystems Developers YouTube:

⏯ Global Mindmaps InterSystems IRIS and Mind Elixir

https://www.youtube.com/embed/ACZGePL9E14
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

Enjoy!