Use JS to interact with the editor

Is there a way to disable the monaco editor?

My use case:
I really need to filter out a table and its relationships. Also, hide irrelevant columns. Using python, I can load the editor content, set a filter value and comment all lines that I’m not interested in. And then generate a new dbml string.
But it requires me to leave dbdiagram and use an external code.
Then, I tried to create a chrome extension to do the same using js. The problem I’m facing is: each line is inside a different, and unordered, div element. Worst, after I modify my string to comment undesired lines, I cannot inject the new string into the editor. I tried to replace the textarea.inputarea content but it doesn`t work.
If the editor were a single textarea, I could easily load its content, change it, and send it back to the textarea.

Option B: I got to get a diagramId content via API using python (endpoint = f’https://api.dbdiagram.io/query/{SOURCE_DIAGRAM}'), but when I try to write it back, it creates a new diagram, instead of updating the existing one. Is it possible to update an existing diagram instead of creating a new one? I tried to send the id using both _id and ìd` keys (ignored).

payload = {
 '_id': xxx,
 'content': '//test',
 'userid': xxx,
 'name': 'Test',
 'id': xxx}

requests.post(f'https://api.dbdiagram.io/query', headers=headers, json=payload)

Hey Lazaro,

We currently don’t have support for the request to filter out tables and relationships, but we will look into that and try to see if we can include it in the product roadmap. Thank you for the valuable feedback!

For the API option, we have an update diagram API. The sample request will look like this:

payload = {
   'content': 'table a { id int }',
   'name': 'Test',
   'diagram': {
        'tables': [
            {
                'name': 'a',
                'schemaName': 'public',
                'x': 10,
                'y': 20
            }
        ]
   },
  'tableGroups': [] // table group collapse states
}

requests.put(f'https://api.dbdiagram.io/query/{your_diagram_id}', headers=headers, json=payload)

We suggest you add diagram and tableGroups to the payload to retain the table positions and table group collapse states of your diagram. You can get this data when calling the get diagram content API.

Thank you so much!

Thank you so much. It is working!

Making some more adjustments and I’ll come back here to share my solution. If lucky, GPT will get to convert my python code into a js extension.