"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[1615],{4361:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>i,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"XXTLanControl.lua/kvdb/dict/copy_value","title":"Copy A Key (LCC.kvdb.dict.copy_value)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/kvdb/dict/copy_value.md","sourceDirName":"XXTLanControl.lua/kvdb/dict","slug":"/XXTLanControl.lua/kvdb/dict/copy_value","permalink":"/docs/en/XXTLanControl.lua/kvdb/dict/copy_value","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":40,"frontMatter":{"sidebar_position":40},"sidebar":"tutorialSidebar","previous":{"title":"Move A Key (LCC.kvdb.dict.move_value)","permalink":"/docs/en/XXTLanControl.lua/kvdb/dict/move_value"},"next":{"title":"Atomic Increment/Decrement (LCC.kvdb.dict.incr)","permalink":"/docs/en/XXTLanControl.lua/kvdb/dict/incr"}}');var s=t(4848),o=t(8453);const i={sidebar_position:40},l="Copy A Key (LCC.kvdb.dict.copy_value)",c={},a=[{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 d(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"copy-a-key-lcckvdbdictcopy_value",children:"Copy A Key (LCC.kvdb.dict.copy_value)"})}),"\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:"ok, old_value_or_err = LCC.kvdb.dict.copy_value(src_name, src_key, dst_name?, dst_key?, 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:["src_name",(0,s.jsx)(n.br,{}),"\n","String. Source dictionary name (non-empty, max ",(0,s.jsx)(n.code,{children:"256"})," bytes)."]}),"\n",(0,s.jsxs)(n.li,{children:["src_key",(0,s.jsx)(n.br,{}),"\n","String. Source key (must be valid UTF-8 and non-empty)."]}),"\n",(0,s.jsxs)(n.li,{children:["dst_name",(0,s.jsx)(n.br,{}),"\n","String, optional. Destination dictionary name, defaults to the source name (non-empty, max ",(0,s.jsx)(n.code,{children:"256"})," bytes)."]}),"\n",(0,s.jsxs)(n.li,{children:["dst_key",(0,s.jsx)(n.br,{}),"\n","String, optional. Destination key, defaults to the source key (must be valid UTF-8 and non-empty)."]}),"\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:["ok",(0,s.jsx)(n.br,{}),"\n","Boolean. ",(0,s.jsx)(n.code,{children:"true"})," on success, ",(0,s.jsx)(n.code,{children:"false"})," on failure."]}),"\n",(0,s.jsxs)(n.li,{children:["old_value_or_err",(0,s.jsx)(n.br,{}),"\n","String or ",(0,s.jsx)(n.code,{children:"nil"}),". Previous value at the destination (or ",(0,s.jsx)(n.code,{children:"nil"})," when absent); on failure returns an error description."]}),"\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:["Copies the value to the destination key; the source key is preserved.",(0,s.jsx)(n.br,{}),"\n","When source and destination are identical it simply returns the existing value while reporting success.\nMissing source keys return ",(0,s.jsx)(n.code,{children:"false"}),"."]}),"\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 ok, old = LCC.kvdb.dict.copy_value("templates", "default", "user", "default")\nif not ok then\n    error(old)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>l});var r=t(6540);const s={},o=r.createContext(s);function i(e){const n=r.useContext(o);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(s):e.components||s:i(e.components),r.createElement(o.Provider,{value:n},e.children)}}}]);