1 line
5.2 KiB
JavaScript
1 line
5.2 KiB
JavaScript
"use strict";(self.webpackChunkdocusaurus=self.webpackChunkdocusaurus||[]).push([[579],{7712:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>o,default:()=>u,frontMatter:()=>l,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"typedefs/constraint-options","title":"ConstraintOptions","description":"Type: Object","source":"@site/docs/typedefs/constraint-options.md","sourceDirName":"typedefs","slug":"/typedefs/constraint-options","permalink":"/awSQL/typedefs/constraint-options","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":3,"frontMatter":{"sidebar_position":3},"sidebar":"defaultSidebar","previous":{"title":"ColumnStructure","permalink":"/awSQL/typedefs/column-structure"},"next":{"title":"Example Database","permalink":"/awSQL/category/example-database"}}');var i=s(4848),t=s(8453);const l={sidebar_position:3},o="ConstraintOptions",d={},a=[{value:"Example structure",id:"example-structure",level:2},{value:"Properties",id:"properties",level:2},{value:".primary",id:"primary",level:3},{value:".index",id:"index",level:3},{value:".null",id:"null",level:3},{value:".unique",id:"unique",level:3},{value:".default",id:"default",level:3},{value:".auto_increment",id:"auto_increment",level:3},{value:".unsigned",id:"unsigned",level:3}];function c(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"constraintoptions",children:"ConstraintOptions"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Type:"})," ",(0,i.jsx)(n.code,{children:"Object"})]}),"\n",(0,i.jsxs)(n.p,{children:["Defines additional constraints for a column within a ",(0,i.jsx)(n.a,{href:"../classes/structure",children:"Structure"}),"."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"All keys in the object are optional"})}),"\n",(0,i.jsx)(n.li,{children:"Only define the keys for the constraints you want to enable."}),"\n"]})}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"example-structure",children:"Example structure"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-js",children:'{\r\n "primary": true,\r\n "index": true,\r\n "null": true,\r\n "unique": true,\r\n "default": "Some default text",\r\n "auto_increment": false,\r\n "unsigned": true\r\n}\n'})}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"primary",children:".primary"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsx)(n.p,{children:"Defines if this column should be the primary key."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"index",children:".index"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsx)(n.p,{children:"Marks the column as indexable (improves query speed but slows insertion)."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"null",children:".null"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsxs)(n.p,{children:["Determines if the column allows ",(0,i.jsx)(n.code,{children:"NULL"})," values by default."]}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"unique",children:".unique"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsx)(n.p,{children:"Ensures that all values in this column are unique, preventing duplicates."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"default",children:".default"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"String"})]}),"\n",(0,i.jsx)(n.p,{children:"The default value inserted when no value is providded."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"auto_increment",children:".auto_increment"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsx)(n.p,{children:"Increments the column value automatically on new insertions (typically used for primary keys)."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h3,{id:"unsigned",children:".unsigned"}),"\n",(0,i.jsxs)(n.p,{children:["\u2192 ",(0,i.jsx)(n.strong,{children:"Boolean"})]}),"\n",(0,i.jsxs)(n.p,{children:["Defines whether the column should be ",(0,i.jsx)(n.strong,{children:"unsigned"})," (i.e., only allow non-negative numbers)."]}),"\n",(0,i.jsx)(n.admonition,{title:"Warning",type:"danger",children:(0,i.jsxs)(n.p,{children:["This option is ",(0,i.jsx)(n.strong,{children:"only valid for numerical columns"}),"."]})}),"\n",(0,i.jsx)(n.hr,{})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},8453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>o});var r=s(6540);const i={},t=r.createContext(i);function l(e){const n=r.useContext(t);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]); |