dsql-admin/dsql-app/.local_dist/server/pages/docs/api-reference/post.html
Benjamin Toby a7dfd48284 Updates
2024-12-09 10:39:09 +01:00

1 line
20 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width, initial-scale=1" data-next-head=""/><meta name="author" content="Datasquirel"/><meta name="Copyright" content="Copyright (c) 2024 Datasquirel"/><meta name="robots" content="noindex,nofollow"/><link rel="preconnect" href="https://fonts.googleapis.com/" crossorigin="anonymous"/><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono"/><script src="/scripts/themeSelector.js"></script><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta property="og:site_name" content="DATASQUIREL"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary"/><meta property="og:image" content="https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"/><meta itemProp="image" content="https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"/><meta name="twitter:image" content="https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"/><link rel="stylesheet" href="/styles/prism.css"/><script src="/scripts/prism.js" async=""></script><script>var DSQL = {}</script><link rel="preload" href="/_next/static/css/59f9d939bb2b7c23.css" as="style"/><link rel="stylesheet" href="/_next/static/css/59f9d939bb2b7c23.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-5381863dc66a9c32.js" defer=""></script><script src="/_next/static/chunks/framework-898697981b1ca118.js" defer=""></script><script src="/_next/static/chunks/main-36f93e1764e6ea94.js" defer=""></script><script src="/_next/static/chunks/pages/_app-946b7f00d529ca86.js" defer=""></script><script src="/_next/static/chunks/pages/docs/%5Bpage%5D/%5Bsub-page%5D-d986893c235e6d5b.js" defer=""></script><script src="/_next/static/Nq-wCyHRgv6y1x0kf3WAs/_buildManifest.js" defer=""></script><script src="/_next/static/Nq-wCyHRgv6y1x0kf3WAs/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"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":"Post","slug":"post","description":"\u003cp\u003eFull CRUD operations on your database using our feature-rich API integration.\u003c/p\u003e","content":"\u003ch2\u003eOverview\u003c/h2\u003e\u003cp\u003eThe \u003ccode style=\"display:inline\"\u003epost\u003c/code\u003e  method expands on the \u003ccode style=\"display:inline\"\u003eget\u003c/code\u003e method. It adds the ability to insert, update, and delete data, as well as add and delete images from your static files directories.\u003c/p\u003e\u003cp\u003eThe post method contains the full spectrum of CRUD operations. And it works \u003cstrong\u003e*only \u003c/strong\u003ewith the \u003cstrong\u003eFull Access \u003c/strong\u003eAPI key. The read only API key will not work for post methods.\u003c/p\u003e\u003ch3\u003eUsing CURL\u003cbr /\u003e\u003c/h3\u003e\u003cpre class=\"language-markup\"\u003eCURL --json\n '{ \n \"database\": \"social_network\",\n \"query\": \"UPDATE users SET name = 'John' WHERE id = 1\"\n }'\n https://datasquirel.com/api/query/post \n-H \n \"Authorization:FULL_ACCESS_API_KEY\"`\u003c/pre\u003e\u003cp\u003e\u003cbr /\u003e\u003c/p\u003e\u003ch3\u003eUsing our npm module\u003cbr /\u003e\u003c/h3\u003e\u003cpre class=\"language-javascript\"\u003e\u003cspan class=\"token keyword\"\u003econst\u003c/span\u003e datasquirel \u003cspan class=\"token operator\"\u003e=\u003c/span\u003e \u003cspan class=\"token function\"\u003erequire\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token string\"\u003e\"datasquirel\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n\ndatasquirel\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003epost\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003edatabase\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"social_network\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003ekey\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e process\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003eenv\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token constant\"\u003eFULL_ACCESS_API_KEY\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003equery\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"UPDATE users SET name = 'John' WHERE id = 1\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003ethen\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token parameter\"\u003eresponse\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e \u003cspan class=\"token operator\"\u003e=\u0026gt;\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n console\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003elog\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003eresponse\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\u003c/pre\u003e\u003ch2\u003e\u003cbr /\u003e\u003c/h2\u003e\u003ch2\u003eThe Response\u003c/h2\u003e\u003cp\u003eThe process yeilds simalar results, but with a slight difference: for operations like \u003cstrong\u003einsert \u003c/strong\u003eand \u003cstrong\u003eupdate\u003c/strong\u003e, the \u003ccode style=\"display:inline\"\u003esuccess\u003c/code\u003e field yeilds \u003ccode style=\"display:inline\"\u003etrue\u003c/code\u003e while the \u003ccode style=\"display:inline\"\u003epayload\u003c/code\u003e field yeilds an object containing fields like \u003c/p\u003e\u003cpre class=\"language-javascript\"\u003e\u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003esuccess\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token boolean\"\u003etrue\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003epayload\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eserverStatus\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token number\"\u003e37\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eaffectedRows\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token number\"\u003e1\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\n\u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003c/pre\u003e\u003cp\u003e\u003cbr /\u003e\u003c/p\u003e\u003ch2\u003ePost with object \u003cem\u003equery\u003c/em\u003e\u003c/h2\u003e\u003cp\u003eThe post method can also take an object as the \u003ccode style=\"display:inline\"\u003equery\u003c/code\u003e instead of a string. Example:\u003c/p\u003e\u003cpre class=\"language-javascript\"\u003e\u003cspan class=\"token keyword\"\u003econst\u003c/span\u003e datasquirel \u003cspan class=\"token operator\"\u003e=\u003c/span\u003e \u003cspan class=\"token function\"\u003erequire\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token string\"\u003e\"datasquirel\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n\ndatasquirel\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003epost\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003edatabase\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"social_network\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003ekey\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e process\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003eenv\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token constant\"\u003eFULL_ACCESS_API_KEY\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003equery\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eaction\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"update\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003etable\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"users\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003edata\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003ename\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"John\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eidentifierColumnName\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"id\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eidentifierValue\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token number\"\u003e1\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003ethen\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token parameter\"\u003eresponse\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e \u003cspan class=\"token operator\"\u003e=\u0026gt;\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n console\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003elog\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003eresponse\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\u003c/pre\u003e\u003cp\u003eThis yields the exact same result as before.\u003c/p\u003e\u003cp\u003e\u003cbr /\u003e\u003c/p\u003e\u003ch2\u003eAdding media\u003c/h2\u003e\u003cp\u003eIn addition to the full CRUD operations the \u003ccode style=\"display:inline\"\u003epost\u003c/code\u003e method offers, you can also add media to your static files directory. This uses the same post method, but with sligtly different parameters. Also, the media you send \u003cstrong\u003e*must \u003c/strong\u003ebe in \u003ccode style=\"display:inline\"\u003ebase64\u003c/code\u003e format. You can use our npm client module to convert images and documents to \u003ccode style=\"display:inline\"\u003ebase64\u003c/code\u003e format.\u003c/p\u003e\u003ch3\u003eUsing our node module\u003c/h3\u003e\u003cpre class=\"language-javascript\"\u003e\u003cspan class=\"token keyword\"\u003econst\u003c/span\u003e datasquirel \u003cspan class=\"token operator\"\u003e=\u003c/span\u003e \u003cspan class=\"token function\"\u003erequire\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token string\"\u003e\"datasquirel\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n\ndatasquirel\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003emedia\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003euploadImage\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003ekey\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e process\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003eenv\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token constant\"\u003eDATASQUIREL_FULL_ACCESS_API_KEY\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003epayload\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eimageData\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"--------- LONG BASE64 STRING ---------\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003eimageName\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"sunflower\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003efolder\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"flowers\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e \u003cspan class=\"token comment\"\u003e// Optional\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003emimeType\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token string\"\u003e\"jpeg\"\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e \u003cspan class=\"token comment\"\u003e// Optional\u003c/span\u003e\n \u003cspan class=\"token literal-property property\"\u003ethumbnailSize\u003c/span\u003e\u003cspan class=\"token operator\"\u003e:\u003c/span\u003e \u003cspan class=\"token number\"\u003e300\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e \u003cspan class=\"token comment\"\u003e// Optional\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e,\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003ethen\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003e\u003cspan class=\"token parameter\"\u003eresponse\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e \u003cspan class=\"token operator\"\u003e=\u0026gt;\u003c/span\u003e \u003cspan class=\"token punctuation\"\u003e{\u003c/span\u003e\n console\u003cspan class=\"token punctuation\"\u003e.\u003c/span\u003e\u003cspan class=\"token function\"\u003elog\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e(\u003c/span\u003eresponse\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\n \u003cspan class=\"token punctuation\"\u003e}\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e)\u003c/span\u003e\u003cspan class=\"token punctuation\"\u003e;\u003c/span\u003e\u003c/pre\u003e"}},"__N_SSG":true},"page":"/docs/[page]/[sub-page]","query":{"page":"api-reference","sub-page":"post"},"buildId":"Nq-wCyHRgv6y1x0kf3WAs","isFallback":false,"gsp":true,"scriptLoader":[]}</script></body></html>