<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Exporting data model via CLI (Unable due to read access only)]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Currently the only method to export the data model structure in Directus is through the CLI. However, due to read access limitation in Cloudron, this is not working.</p>
<p dir="auto">Reference: <a href="https://www.restack.io/docs/directus-knowledge-directus-export-schema-guide" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.restack.io/docs/directus-knowledge-directus-export-schema-guide</a></p>
<p dir="auto">So how I can export it then?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.cloudron.io/topic/13038/exporting-data-model-via-cli-unable-due-to-read-access-only</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 09:45:44 GMT</lastBuildDate><atom:link href="https://forum.cloudron.io/topic/13038.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 31 Dec 2024 14:31:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Exporting data model via CLI (Unable due to read access only) on Tue, 31 Dec 2024 14:45:27 GMT]]></title><description><![CDATA[<p dir="auto">I have been able to find a turnaround for exporting the schema using Node.js.</p>
<p dir="auto">===========<br />
To export your schema from a Directus instance using Node.js</p>
<h3>Prerequisites</h3>
<ul>
<li><strong>Node.js Installed</strong>: Ensure Node.js is installed on your system.</li>
<li><strong>Directus Instance and Token</strong>: Obtain your source Directus project URL and access token.</li>
</ul>
<h3>Steps to Export the Schema</h3>
<ol>
<li>
<p dir="auto"><strong>Setup Node.js Project</strong>:</p>
<ul>
<li>Create a new directory and initialize a Node.js project:<pre><code class="language-bash">mkdir directus-schema-export
cd directus-schema-export
npm init -y
</code></pre>
</li>
<li>Install the required package:<pre><code class="language-bash">npm install cross-fetch
</code></pre>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Create the Script</strong>:</p>
<ul>
<li>
<p dir="auto">Create a file, e.g., <code>export-schema.js</code>, and add the following code:</p>
<pre><code class="language-javascript">const fetch = require('cross-fetch');

// Replace with your actual Directus project URL and access token
const SOURCE_URL = 'https://your-directus-instance.com'; // Your Directus URL
const SOURCE_TOKEN = 'your-access-token'; // Your Directus access token

async function exportSchema() {
  try {
    const response = await fetch(`${SOURCE_URL}/schema/snapshot?access_token=${SOURCE_TOKEN}`);
    if (!response.ok) {
      throw new Error(`Failed to fetch schema: ${response.statusText}`);
    }
    const { data } = await response.json();
    console.log('Schema exported successfully:', data);
    return data;
  } catch (error) {
    console.error('Error exporting schema:', error.message);
  }
}

// Call the function
exportSchema();
</code></pre>
</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Run the Script</strong>:</p>
<ul>
<li>Execute the script using Node.js:<pre><code class="language-bash">node export-schema.js
</code></pre>
</li>
<li>The schema will be logged to the console. You can redirect it to a file:<pre><code class="language-bash">node export-schema.js &gt; schema.json
</code></pre>
</li>
</ul>
</li>
</ol>
]]></description><link>https://forum.cloudron.io/post/99135</link><guid isPermaLink="true">https://forum.cloudron.io/post/99135</guid><dc:creator><![CDATA[igaudette]]></dc:creator><pubDate>Tue, 31 Dec 2024 14:45:27 GMT</pubDate></item></channel></rss>