awSQL/docs/docusaurus/build/assets/js/d7af1896.82e89304.js
2025-04-13 14:28:04 +02:00

1 line
12 KiB
JavaScript

"use strict";(self.webpackChunkdocusaurus=self.webpackChunkdocusaurus||[]).push([[23],{6986:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>o,frontMatter:()=>d,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"classes/awsql","title":"awSQL","description":"The default exported module that holds and manages all database instances globally.","source":"@site/docs/classes/awsql.md","sourceDirName":"classes","slug":"/classes/awsql","permalink":"/awSQL/classes/awsql","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1},"sidebar":"defaultSidebar","previous":{"title":"Classes","permalink":"/awSQL/category/classes"},"next":{"title":"Instance","permalink":"/awSQL/classes/instance"}}');var t=s(4848),r=s(8453);const d={sidebar_position:1},c="awSQL",l={},h=[{value:"Methods",id:"methods",level:2},{value:"createInstance()",id:"createinstance",level:3},{value:"getInstance()",id:"getinstance",level:3},{value:"listInstances()",id:"listinstances",level:3},{value:"deleteInstance()",id:"deleteinstance",level:3}];function a(e){const n={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,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"awsql",children:"awSQL"})}),"\n",(0,t.jsx)(n.p,{children:"The default exported module that holds and manages all database instances globally."}),"\n",(0,t.jsx)(n.p,{children:"It does not provide any additional functionality beyond managing instances."}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h2,{id:"methods",children:"Methods"}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"createinstance",children:"createInstance()"}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 (",(0,t.jsx)(n.code,{children:"hostname"})," = ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"username"})," = ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"password"})," = ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"options"}),"? = {",(0,t.jsx)(n.code,{children:"charset"}),"?: ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"defaultDatabase"}),"?: ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"multipleStatements"}),"?: ",(0,t.jsx)(n.strong,{children:"Boolean"}),", ",(0,t.jsx)(n.code,{children:"insecureAuth"}),"?: ",(0,t.jsx)(n.strong,{children:"Boolean"}),", ",(0,t.jsx)(n.code,{children:"customIdentifier"}),"?: ",(0,t.jsx)(n.strong,{children:"String"}),", ",(0,t.jsx)(n.code,{children:"isDefault"}),"?: ",(0,t.jsx)(n.strong,{children:"Boolean"}),"}) \u2192 ",(0,t.jsx)(n.a,{href:"./instance",children:"Instance"})]}),"\n",(0,t.jsx)(n.p,{children:"Creates a new database connection instance."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Parameter"}),(0,t.jsx)(n.th,{children:"Type"}),(0,t.jsx)(n.th,{children:"Description"})]})}),(0,t.jsxs)(n.tbody,{children:[(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"hostname"})}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsx)(n.td,{children:"The database hostname."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"username"})}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsx)(n.td,{children:"The username for authentication."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.code,{children:"password"})}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsx)(n.td,{children:"The password for authentication."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:[(0,t.jsx)(n.code,{children:"options"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"Object"})}),(0,t.jsx)(n.td,{children:"Additional settings for the instance."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.charset"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsx)(n.td,{children:"The character set to use."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.defaultDatabase"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsx)(n.td,{children:"Default database for queries."})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.multipleStatements"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"Boolean"})}),(0,t.jsxs)(n.td,{children:["Allow multiple SQL statements in a single query (default: ",(0,t.jsx)(n.code,{children:"false"}),")."]})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.insecureAuth"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"Boolean"})}),(0,t.jsxs)(n.td,{children:["Enables insecure authentication methods (default: ",(0,t.jsx)(n.code,{children:"false"}),")."]})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.customIdentifier"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsxs)(n.td,{children:["Custom instance identifier. Defaults to ",(0,t.jsx)(n.code,{children:"username@hostname"}),"."]})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:["\u2192 ",(0,t.jsx)(n.code,{children:"options.isDefault"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"Boolean"})}),(0,t.jsxs)(n.td,{children:["Marks this instance as the default when no identifier is provided in ",(0,t.jsx)(n.a,{href:"#getinstance",children:"getInstance()"}),"."]})]})]})]}),"\n",(0,t.jsxs)(n.admonition,{title:"Possible errors",type:"warning",children:[(0,t.jsxs)(n.p,{children:["This method ",(0,t.jsx)(n.strong,{children:"may crash"})," if:"]}),(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"password"})," or ",(0,t.jsx)(n.code,{children:"username"})," is empty."]}),"\n",(0,t.jsxs)(n.li,{children:["An instance with the same ",(0,t.jsx)(n.code,{children:"identifier"})," already exists."]}),"\n"]})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 ",(0,t.jsx)(n.a,{href:"./instance",children:"Instance"})]}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"getinstance",children:"getInstance()"}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 (",(0,t.jsx)(n.code,{children:"identifier"}),"? = ",(0,t.jsx)(n.strong,{children:"String"}),") \u2192 ",(0,t.jsx)(n.a,{href:"./instance",children:"Instance"})," / ",(0,t.jsx)(n.strong,{children:"undefined"})]}),"\n",(0,t.jsxs)(n.p,{children:["Retrieves an existing database instance by its ",(0,t.jsx)(n.code,{children:"identifier"}),"."]}),"\n",(0,t.jsx)(n.p,{children:"If no identifier is provided and a default instance exists, it returns the default instance."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Parameter"}),(0,t.jsx)(n.th,{children:"Type"}),(0,t.jsx)(n.th,{children:"Description"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:[(0,t.jsx)(n.code,{children:"identifier"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsxs)(n.td,{children:["The name of the instance to retrieve. If no explicitly set with ",(0,t.jsx)(n.code,{children:"customIdentifier"}),", instances are identified as ",(0,t.jsx)(n.code,{children:"username@hostname"}),"."]})]})})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"./instance",children:"Instance"})," - if found."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"undefined"})," - if no instance matches the identifier."]}),"\n"]}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"listinstances",children:"listInstances()"}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 () \u2192 ",(0,t.jsx)(n.strong,{children:"Array"}),"<",(0,t.jsx)(n.strong,{children:"String"}),">"]}),"\n",(0,t.jsx)(n.p,{children:"Returns a list of all defined instance identifiers."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 ",(0,t.jsx)(n.strong,{children:"Array"}),"<",(0,t.jsx)(n.strong,{children:"String"}),"> - A list of instance identifiers."]}),"\n",(0,t.jsx)(n.hr,{}),"\n",(0,t.jsx)(n.h3,{id:"deleteinstance",children:"deleteInstance()"}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 (",(0,t.jsx)(n.code,{children:"identifier"})," = ",(0,t.jsx)(n.strong,{children:"String"}),") \u2192 ",(0,t.jsx)(n.strong,{children:"true"})]}),"\n",(0,t.jsx)(n.p,{children:"Deletes an existing instance and closes its database connection."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Parameters"})}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Parameter"}),(0,t.jsx)(n.th,{children:"Type"}),(0,t.jsx)(n.th,{children:"Description"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsxs)(n.td,{children:[(0,t.jsx)(n.code,{children:"identifier"})," ",(0,t.jsx)(n.strong,{children:"optional"})]}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.strong,{children:"String"})}),(0,t.jsxs)(n.td,{children:["The identifier of the instance to delete. If ",(0,t.jsx)(n.code,{children:"customIdentifier"})," was not set, use ",(0,t.jsx)(n.code,{children:"username@hostname"}),"."]})]})})]}),"\n",(0,t.jsxs)(n.admonition,{title:"Possible Error",type:"warning",children:[(0,t.jsxs)(n.p,{children:["This method ",(0,t.jsx)(n.strong,{children:"may crash"})," if:"]}),(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"identifier"})," is empty.","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["To delete the default instance, provide its ",(0,t.jsx)(n.code,{children:"identifier"}),"."]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"identifier"})," is not a ",(0,t.jsx)(n.code,{children:"String"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:["No instance with the given ",(0,t.jsx)(n.code,{children:"identifier"})," exists."]}),"\n"]})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(n.p,{children:["\u2192 ",(0,t.jsx)(n.strong,{children:"true"})," - Awayls returns ",(0,t.jsx)(n.code,{children:"true"}),". Errors will cause an exception instead."]}),"\n",(0,t.jsx)(n.hr,{})]})}function o(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}},8453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>c});var i=s(6540);const t={},r=i.createContext(t);function d(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:d(e.components),i.createElement(r.Provider,{value:n},e.children)}}}]);