awSQL/docs/docusaurus/build/assets/js/7e36430b.97f830e2.js
2025-03-14 23:49:58 +01:00

1 line
6.0 KiB
JavaScript

"use strict";(self.webpackChunkdocusaurus=self.webpackChunkdocusaurus||[]).push([[53],{2761:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>c,contentTitle:()=>l,default:()=>o,frontMatter:()=>d,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"classes/delete","title":"Delete","description":"Performs a query to delete rows from a table.","source":"@site/docs/classes/delete.md","sourceDirName":"classes","slug":"/classes/delete","permalink":"/awSQL/classes/delete","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":5,"frontMatter":{"sidebar_position":5},"sidebar":"defaultSidebar","previous":{"title":"Insert","permalink":"/awSQL/classes/insert"},"next":{"title":"Update","permalink":"/awSQL/classes/update"}}');var t=n(4848),i=n(8453);const d={sidebar_position:5},l="Delete",c={},h=[{value:"Methods",id:"methods",level:2},{value:"selectDatabase()",id:"selectdatabase",level:3},{value:"where()",id:"where",level:3},{value:"force()",id:"force",level:3},{value:"execute()",id:"execute",level:3}];function a(e){const s={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.header,{children:(0,t.jsx)(s.h1,{id:"delete",children:"Delete"})}),"\n",(0,t.jsx)(s.p,{children:"Performs a query to delete rows from a table."}),"\n",(0,t.jsxs)(s.admonition,{title:"Possible crash",type:"warning",children:[(0,t.jsxs)(s.p,{children:["To prevent accidental deletion of all rows, this will throw an error on ",(0,t.jsx)(s.a,{href:"#execute",children:"execute()"})," if no ",(0,t.jsx)(s.a,{href:"#where",children:"where()"})," was defined."]}),(0,t.jsxs)(s.p,{children:["To enable the deletion of all rows use ",(0,t.jsx)(s.a,{href:"#force",children:"force()"}),"."]})]}),"\n",(0,t.jsx)(s.h2,{id:"methods",children:"Methods"}),"\n",(0,t.jsx)(s.h3,{id:"selectdatabase",children:"selectDatabase()"}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 (",(0,t.jsx)(s.code,{children:"database"})," = ",(0,t.jsx)(s.strong,{children:"String"}),") \u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.p,{children:"Selects a different database for this query."}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Parameters"})}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Parameter"}),(0,t.jsx)(s.th,{children:"Type"}),(0,t.jsx)(s.th,{children:"Description"})]})}),(0,t.jsx)(s.tbody,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"database"})}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.strong,{children:"String"})}),(0,t.jsx)(s.td,{children:"Name of the database to select"})]})})]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.hr,{}),"\n",(0,t.jsx)(s.h3,{id:"where",children:"where()"}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 (",(0,t.jsx)(s.code,{children:"string"})," = ",(0,t.jsx)(s.strong,{children:"String"}),", ",(0,t.jsx)(s.code,{children:"values"})," = ",(0,t.jsx)(s.strong,{children:"Array"}),"<",(0,t.jsx)(s.strong,{children:"any"}),">) \u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.p,{children:"Adds a where-clause to the query"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"Values should be set as ? in the string and given in left-to-right order via the 'values'-array to minimize the risk of sql-injection"}),"\n",(0,t.jsx)(s.li,{children:"If you are using joins, specify the table and column together: table.column"}),"\n"]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Parameters"})}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Parameter"}),(0,t.jsx)(s.th,{children:"Type"}),(0,t.jsx)(s.th,{children:"Description"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"string"})}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.strong,{children:"String"})}),(0,t.jsx)(s.td,{children:"The where-clause as a string with ? representing each values."})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"values"})}),(0,t.jsxs)(s.td,{children:[(0,t.jsx)(s.strong,{children:"Array"}),"<",(0,t.jsx)(s.strong,{children:"any"}),">"]}),(0,t.jsx)(s.td,{children:"Array containing values replacing the ? in the string (from left to right)"})]})]})]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.hr,{}),"\n",(0,t.jsx)(s.h3,{id:"force",children:"force()"}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 () \u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.p,{children:"Enables deletion of all rows."}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 ",(0,t.jsx)(s.code,{children:"this"})]}),"\n",(0,t.jsx)(s.hr,{}),"\n",(0,t.jsx)(s.h3,{id:"execute",children:"execute()"}),"\n",(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.code,{children:"async"})," \u2192 () \u2192 ",(0,t.jsx)(s.strong,{children:"any"})]}),"\n",(0,t.jsx)(s.p,{children:"Executes the prepared query."}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(s.p,{children:["\u2192 ",(0,t.jsx)(s.strong,{children:"any"})," - Query result"]}),"\n",(0,t.jsx)(s.hr,{})]})}function o(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}},8453:(e,s,n)=>{n.d(s,{R:()=>d,x:()=>l});var r=n(6540);const t={},i=r.createContext(t);function d(e){const s=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:d(e.components),r.createElement(i.Provider,{value:s},e.children)}}}]);