"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[4108],{8358:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>u,frontMatter:()=>l,metadata:()=>s,toc:()=>i});const s=JSON.parse('{"id":"XXTLanControl.lua/tabledb/add","title":"Batch Insert Rows (LCC.db.add)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/tabledb/add.md","sourceDirName":"XXTLanControl.lua/tabledb","slug":"/XXTLanControl.lua/tabledb/add","permalink":"/docs/en/XXTLanControl.lua/tabledb/add","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":30,"frontMatter":{"sidebar_position":30},"sidebar":"tutorialSidebar","previous":{"title":"Create A Table (LCC.db.create)","permalink":"/docs/en/XXTLanControl.lua/tabledb/create"},"next":{"title":"Batch Delete Rows (LCC.db.del)","permalink":"/docs/en/XXTLanControl.lua/tabledb/del"}}');var t=r(4848),a=r(8453);const l={sidebar_position:30},d="Batch Insert Rows (LCC.db.add)",o={},i=[{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Notes",id:"notes",level:2},{value:"Example",id:"example",level:2}];function c(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"batch-insert-rows-lccdbadd",children:"Batch Insert Rows (LCC.db.add)"})}),"\n",(0,t.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.db.add(name, rows, timeout?)\n"})}),"\n",(0,t.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["name",(0,t.jsx)(n.br,{}),"\n","String. Table name. Must be non-empty and no longer than 256 bytes."]}),"\n",(0,t.jsxs)(n.li,{children:["rows",(0,t.jsx)(n.br,{}),"\n","Table. Array of row objects. Field names must already exist, and ",(0,t.jsx)(n.code,{children:"id"})," must not be included."]}),"\n",(0,t.jsxs)(n.li,{children:["timeout",(0,t.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,t.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["ok",(0,t.jsx)(n.br,{}),"\n","Boolean. ",(0,t.jsx)(n.code,{children:"true"})," when insert succeeds, otherwise ",(0,t.jsx)(n.code,{children:"false"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:["err",(0,t.jsx)(n.br,{}),"\n","String or ",(0,t.jsx)(n.code,{children:"nil"}),". Error details (invalid columns, empty payload, etc.)."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["Inserts rows in bulk; all user columns are stored as strings.",(0,t.jsx)(n.br,{}),"\n","Including an ",(0,t.jsx)(n.code,{children:"id"})," field causes an error.",(0,t.jsx)(n.br,{}),"\n","Unknown tables or columns produce error messages."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.db.add("tasks", {\n    { Name = "Deploy script", Status = "Running" },\n    { Name = "Clean data", Status = "Idle", Remark = "Night batch" }\n})\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},8453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>d});var s=r(6540);const t={},a=s.createContext(t);function l(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),s.createElement(a.Provider,{value:n},e.children)}}}]);