"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[1791],{10:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"XXTLanControl.lua/tabledb/list","title":"Query Rows With Conditions (LCC.db.list)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/tabledb/list.md","sourceDirName":"XXTLanControl.lua/tabledb","slug":"/XXTLanControl.lua/tabledb/list","permalink":"/docs/en/XXTLanControl.lua/tabledb/list","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":60,"frontMatter":{"sidebar_position":60},"sidebar":"tutorialSidebar","previous":{"title":"Batch Update Rows (LCC.db.edit)","permalink":"/docs/en/XXTLanControl.lua/tabledb/edit"},"next":{"title":"Count Rows (LCC.db.count)","permalink":"/docs/en/XXTLanControl.lua/tabledb/count"}}');var t=s(4848),i=s(8453);const o={sidebar_position:60},l="Query Rows With Conditions (LCC.db.list)",d={},c=[{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 a(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"query-rows-with-conditions-lccdblist",children:"Query Rows With Conditions (LCC.db.list)"})}),"\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:"rows, err = LCC.db.list(name, opts?, 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:["opts",(0,t.jsx)(n.br,{}),"\n","Table, optional. Query options:","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"conditions"}),": key/value pairs combined with AND"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"order_by"}),": string, column to sort by (",(0,t.jsx)(n.code,{children:'"id"'})," by default)"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"desc"}),": boolean, ",(0,t.jsx)(n.code,{children:"true"})," for descending order, default ",(0,t.jsx)(n.code,{children:"false"})]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"limit"}),": integer, maximum rows to return"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"offset"}),": integer, number of rows to skip (default ",(0,t.jsx)(n.code,{children:"0"}),")"]}),"\n"]}),"\n"]}),"\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:["rows",(0,t.jsx)(n.br,{}),"\n","Table. Array of rows that match; ",(0,t.jsx)(n.code,{children:"nil"})," on failure."]}),"\n",(0,t.jsxs)(n.li,{children:["err",(0,t.jsx)(n.br,{}),"\n","String or ",(0,t.jsx)(n.code,{children:"nil"}),". Error description such as ",(0,t.jsx)(n.code,{children:"unknown column"})," or ",(0,t.jsx)(n.code,{children:"unknown table"}),"."]}),"\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:["Runs a filtered query; all user columns are returned as strings while ",(0,t.jsx)(n.code,{children:"id"})," is returned as a number.",(0,t.jsx)(n.br,{}),"\n","Without ",(0,t.jsx)(n.code,{children:"opts"})," it returns every record in ascending ",(0,t.jsx)(n.code,{children:"id"})," order."]}),"\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 rows, err = LCC.db.list("tasks", {\n    conditions = { Status = "Idle" },\n    order_by = "id",\n    limit = 20\n})\nif rows then\n    print("Idle tasks:", #rows)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,i.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:()=>o,x:()=>l});var r=s(6540);const t={},i=r.createContext(t);function o(e){const n=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]);