"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[7827],{5655:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"XXTLanControl.lua/tabledb/edit","title":"Batch Update Rows (LCC.db.edit)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/tabledb/edit.md","sourceDirName":"XXTLanControl.lua/tabledb","slug":"/XXTLanControl.lua/tabledb/edit","permalink":"/docs/en/XXTLanControl.lua/tabledb/edit","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":50,"frontMatter":{"sidebar_position":50},"sidebar":"tutorialSidebar","previous":{"title":"Batch Delete Rows (LCC.db.del)","permalink":"/docs/en/XXTLanControl.lua/tabledb/del"},"next":{"title":"Query Rows With Conditions (LCC.db.list)","permalink":"/docs/en/XXTLanControl.lua/tabledb/list"}}');var s=t(4848),a=t(8453);const i={sidebar_position:50},o="Batch Update Rows (LCC.db.edit)",l={},d=[{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,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"batch-update-rows-lccdbedit",children:"Batch Update Rows (LCC.db.edit)"})}),"\n",(0,s.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-lua",children:"rows, err = LCC.db.edit(name, rows, timeout?)\n"})}),"\n",(0,s.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["name",(0,s.jsx)(n.br,{}),"\n","String. Table name. Must be non-empty and no longer than 256 bytes."]}),"\n",(0,s.jsxs)(n.li,{children:["rows",(0,s.jsx)(n.br,{}),"\n","Table. Array of objects containing ",(0,s.jsx)(n.code,{children:"id"})," plus the fields to update. Every item must include an integer-valued ",(0,s.jsx)(n.code,{children:"id"})," greater than or equal to ",(0,s.jsx)(n.code,{children:"1"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["timeout",(0,s.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,s.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["rows",(0,s.jsx)(n.br,{}),"\n","Table. Array of original rows before the update; ",(0,s.jsx)(n.code,{children:"nil"})," on failure."]}),"\n",(0,s.jsxs)(n.li,{children:["err",(0,s.jsx)(n.br,{}),"\n","String or ",(0,s.jsx)(n.code,{children:"nil"}),". Error message such as ",(0,s.jsx)(n.code,{children:"unknown table"})," or ",(0,s.jsx)(n.code,{children:"unknown column"}),"."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["Updates multiple rows by ",(0,s.jsx)(n.code,{children:"id"})," and returns the pre-update data.",(0,s.jsx)(n.br,{}),"\n","A missing ",(0,s.jsx)(n.code,{children:"id"}),", or an ",(0,s.jsx)(n.code,{children:"id"})," that is not an integer value greater than or equal to ",(0,s.jsx)(n.code,{children:"1"}),", triggers a Lua parameter validation error.\nThe ",(0,s.jsx)(n.code,{children:"id"})," column itself cannot be updated."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-lua",children:'local before, err = LCC.db.edit("tasks", {\n    { id = 5, Status = "Done" },\n    { id = 6, Status = "Running", Remark = "Manual approval" }\n})\nif not before then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>o});var r=t(6540);const s={},a=r.createContext(s);function i(e){const n=r.useContext(a);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(s):e.components||s:i(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]);