dsql-admin/dsql-app/.local_dist/server/pages/docs/api-reference/get.json

1 line
7.6 KiB
JSON
Raw Normal View History

2024-12-08 19:56:57 +00:00
{"pageProps":{"user":null,"pages":[{"id":8,"title":"Getting Started","slug":"getting-started","level":1,"parent_id":null},{"id":9,"title":"Getting Started","slug":"getting-started","level":2,"parent_id":3},{"id":2,"title":"Quick Start","slug":"quick-start","level":1,"parent_id":null},{"id":3,"title":"GUI Reference","slug":"gui-reference","level":1,"parent_id":null},{"id":4,"title":"API Reference","slug":"api-reference","level":1,"parent_id":null},{"id":10,"title":"Get","slug":"get","level":2,"parent_id":4},{"id":12,"title":"Database Reference","slug":"database-reference","level":1,"parent_id":null},{"id":11,"title":"Post","slug":"post","level":2,"parent_id":4},{"id":13,"title":"Data types","slug":"data-types","level":2,"parent_id":12},{"id":14,"title":"Querying Data","slug":"querying-data","level":2,"parent_id":12},{"id":15,"title":"Upload Media","slug":"upload-media","level":2,"parent_id":3}],"targetPage":{"title":"Get","slug":"get","description":"<p>Fetch data from your database quickly and securely.</p>","content":"<h2>Overview</h2><p>The get method only retrieves data. It cannot be used to write or update data. It was created to be the fastest way to access your data, that explains the key length. You can get data using the npm module or via any HTTP request.</p><h3>Using CURL</h3><pre class=\"language-markup\">CURL \n https://datasquirel.com/api/query/get?db=db_name&amp;query=SELECT+*+FROM+table_name \n-H \n \"Authorization:READ_ONLY_API_KEY\";Content-Type:application/json</pre><h3><br /></h3><h3>Using node module</h3><pre class=\"language-javascript\"><span class=\"token keyword\">const</span> datasquirel <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"datasquirel\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\ndatasquirel\n <span class=\"token punctuation\">.</span><span class=\"token function\">get</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n <span class=\"token literal-property property\">db</span><span class=\"token operator\">:</span> <span class=\"token string\">\"test\"</span><span class=\"token punctuation\">,</span>\n <span class=\"token literal-property property\">key</span><span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">DATASQUIREL_READ_ONLY_KEY</span><span class=\"token punctuation\">,</span>\n <span class=\"token literal-property property\">query</span><span class=\"token operator\">:</span> <span class=\"token string\">\"SELECT title, slug, body FROM blog_posts\"</span><span class=\"token punctuation\">,</span>\n <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">response</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=&gt;</span> <span class=\"token punctuation\">{</span>\n console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>response<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></pre><p><br /></p><h2>The response</h2><p>The response from this method returns a JSON payload with two fields: <strong>success</strong>: which could be either <code style=\"display:inline\">true</code> or <code style=\"display:inline\">false</code>, and <strong>payload: </strong>which is an array of values when the operation is successfull, or anything from <code style=\"display:inline\">null</code> to a string to an object with an error message. This