CINXE.COM

ObjectBox Swift

<!DOCTYPE html><html lang="en" class="scroll-pt-[76px] plain-background"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/_next/static/css/2d00a2f28ca4dc5d.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/99f50cfb598d2941.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/d42d805b938873da.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/0673bb6e29c473c8.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/c311d6484335995a.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/7235fa9d119901d4.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/86d6274f3e6d760c.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/a91fbeec63857000.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/2d0986519abf0323.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/3e09ca0bd98e7d25.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/5a687dea857dc6f5.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/0f891de5863d7182.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh" href="/_next/static/chunks/webpack-21fb00c223e55731.js"/><script src="/_next/static/chunks/1dd3208c-b11c3db6cd7d86b2.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/9978-293e379e3e1468f4.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/main-app-9ebfecd6c4e0cf57.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/app/global-error-19768e91f18f21d9.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/b5d5b83b-3d9186fb60556c53.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/7609-ae1015bd89577747.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/1281-411df876b32e19c2.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/4012-d5519c7c19347ff0.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/app/(space)/~gitbook/pdf/layout-8b38eddf87d0e8b6.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/9505-a8f112b566ef7f41.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/6150-57a79db9099e4be8.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/8510-2f41b25832a6d317.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/1285-2b0f91300e0c0b9a.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/3902-19c217a299034164.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/9028-bdf215f649fe02e9.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><script src="/_next/static/chunks/app/(space)/~gitbook/pdf/page-76eab181be4c30d4.js" async="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script><title>ObjectBox Swift</title><meta name="robots" content="noindex, nofollow"/><meta name="next-size-adjust"/><link rel="privacy-policy" href="https://objectbox.io/wordpress/wp-content/uploads/2022/08/Object-Box-Privacy-Notice.pdf"/><style> :root { --primary-color-50: 232 246 246; --primary-color-100: 209 237 237; --primary-color-200: 162 219 219; --primary-color-300: 116 202 202; --primary-color-400: 69 184 184; --primary-color-500: 23 166 166; --primary-color-600: 18 133 133; --primary-color-700: 14 100 100; --primary-color-800: 9 66 66; --primary-color-900: 5 33 33; --contrast-primary-50: 0 0 0; --contrast-primary-100: 0 0 0; --contrast-primary-200: 0 0 0; --contrast-primary-300: 0 0 0; --contrast-primary-400: 0 0 0; --contrast-primary-500: 0 0 0; --contrast-primary-600: 0 0 0; --contrast-primary-700: 255 255 255; --contrast-primary-800: 255 255 255; --contrast-primary-900: 255 255 255; --primary-base-50: 232 246 246; --primary-base-100: 209 237 237; --primary-base-200: 162 219 219; --primary-base-300: 116 202 202; --primary-base-400: 69 184 184; --primary-base-500: 23 166 166; --primary-base-600: 18 133 133; --primary-base-700: 14 100 100; --primary-base-800: 9 66 66; --primary-base-900: 5 33 33; --header-background-50: 255 255 255; --header-background-100: 255 255 255; --header-background-200: 255 255 255; --header-background-300: 255 255 255; --header-background-400: 255 255 255; --header-background-500: 255 255 255; --header-background-600: 204 204 204; --header-background-700: 153 153 153; --header-background-800: 102 102 102; --header-background-900: 51 51 51; --header-link-50: 232 246 246; --header-link-100: 209 237 237; --header-link-200: 162 219 219; --header-link-300: 116 202 202; --header-link-400: 69 184 184; --header-link-500: 23 166 166; --header-link-600: 18 133 133; --header-link-700: 14 100 100; --header-link-800: 9 66 66; --header-link-900: 5 33 33; --header-button-text-50: 230 230 230; --header-button-text-100: 204 204 204; --header-button-text-200: 153 153 153; --header-button-text-300: 102 102 102; --header-button-text-400: 51 51 51; --header-button-text-500: 0 0 0; --header-button-text-600: 0 0 0; --header-button-text-700: 0 0 0; --header-button-text-800: 0 0 0; --header-button-text-900: 0 0 0; } .dark { --primary-color-50: 232 246 246; --primary-color-100: 209 237 237; --primary-color-200: 162 219 219; --primary-color-300: 116 202 202; --primary-color-400: 69 184 184; --primary-color-500: 23 166 166; --primary-color-600: 18 133 133; --primary-color-700: 14 100 100; --primary-color-800: 9 66 66; --primary-color-900: 5 33 33; --primary-base-50: 232 246 246; --primary-base-100: 209 237 237; --primary-base-200: 162 219 219; --primary-base-300: 116 202 202; --primary-base-400: 69 184 184; --primary-base-500: 23 166 166; --primary-base-600: 18 133 133; --primary-base-700: 14 100 100; --primary-base-800: 9 66 66; --primary-base-900: 5 33 33; --contrast-primary-50: 0 0 0; --contrast-primary-100: 0 0 0; --contrast-primary-200: 0 0 0; --contrast-primary-300: 0 0 0; --contrast-primary-400: 0 0 0; --contrast-primary-500: 0 0 0; --contrast-primary-600: 0 0 0; --contrast-primary-700: 255 255 255; --contrast-primary-800: 255 255 255; --contrast-primary-900: 255 255 255; --header-background-50: 230 230 230; --header-background-100: 204 204 204; --header-background-200: 153 153 153; --header-background-300: 102 102 102; --header-background-400: 51 51 51; --header-background-500: 0 0 0; --header-background-600: 0 0 0; --header-background-700: 0 0 0; --header-background-800: 0 0 0; --header-background-900: 0 0 0; --header-link-50: 232 246 246; --header-link-100: 209 237 237; --header-link-200: 162 219 219; --header-link-300: 116 202 202; --header-link-400: 69 184 184; --header-link-500: 23 166 166; --header-link-600: 18 133 133; --header-link-700: 14 100 100; --header-link-800: 9 66 66; --header-link-900: 5 33 33; --header-button-text-50: 230 230 230; --header-button-text-100: 204 204 204; --header-button-text-200: 153 153 153; --header-button-text-300: 102 102 102; --header-button-text-400: 51 51 51; --header-button-text-500: 0 0 0; --header-button-text-600: 0 0 0; --header-button-text-700: 0 0 0; --header-button-text-800: 0 0 0; --header-button-text-900: 0 0 0; } </style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule="" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh"></script></head><body class="__variable_274faa __variable_a7f53a __variable_e782a9 __className_053b0a __variable_0e9704 bg-light dark:bg-dark"><div class="print-mode"><div class="fixed left-12 top-12 print:hidden z-50"><a title="Go back to content" href="/" class="flex flex-row items-center justify-center text-sm text-dark/6 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white shadow-sm hover:shadow-md border-slate-300 border"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/arrow-left.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon size-6"></svg></a></div><div class="fixed right-12 top-12 print:hidden z-50"><button title="Print or Save as PDF" class="flex flex-row items-center justify-center text-sm text-dark/6 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white shadow-sm hover:shadow-md border-slate-300 border"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/print.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon size-6"></svg></button></div><div class="fixed left-12 bottom-12 flex flex-col gap-2 print:hidden z-50"><a class="inline-block rounded-md straight-corners:rounded-none place-self-start ring-1 ring-inset grow-0 shrink-0 truncate transition-colors bg-dark/2 ring-dark/1 hover:bg-dark/3 dark:bg-light/2 dark:ring-light/1 dark:hover:bg-light/3 text-base px-4 py-2" href="https://swift.objectbox.io/~gitbook/pdf">All pages</a><div class="mt-5"><a target="_blank" href="https://www.gitbook.com/?utm_source=content&amp;utm_medium=trademark&amp;utm_campaign=-LR7sVOoZyL01-NkNVQJ" class="font-semibold ring-1 ring-inset ring-dark/2 pointer-events-auto transition-colors flex flex-row items-center hover:bg-dark/1 bg-light dark:bg-dark px-4 py-4 rounded-lg straight-corners:rounded-none hover:backdrop-blur-sm lg:ring-0 tracking-[-0.016em] dark:hover:bg-light/1 dark:ring-light/1 border border-dark/2 dark:border-light/2"><svg style="mask-image:url(/~gitbook/static/icons/svgs/custom-icons/gitbook.svg?v=2);mask-repeat:no-repeat;mask-position:center" class="gb-icon size-5 mr-3"></svg>Powered by GitBook</a></div></div><div class="fixed right-12 bottom-12 flex flex-col items-end gap-2 print:hidden z-50"><div class="flex flex-row items-center justify-center text-lg text-dark/6 px-6 py-2 bg-slate-100 rounded-full shadow-sm border-slate-300 border">1<!-- --> of <!-- -->1</div></div><!--$?--><template id="B:0"></template><div id="pdf-page--LRIJnzhhl3cynIFNMlD" class="my-11 print:my-0 mx-auto max-w-4xl w-full p-12 print:p-0 shadow-xl print:shadow-none rounded-sm bg-white min-h-[29.7cm] print:min-h-0 break-before-page break-anywhere"><p>Loading...</p></div><!--/$--></div><script src="/_next/static/chunks/webpack-21fb00c223e55731.js" nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh" async=""></script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"1:HC[\"/\",\"\"]\n2:HL[\"/_next/static/css/2d00a2f28ca4dc5d.css\",\"style\"]\n3:HL[\"/_next/static/css/99f50cfb598d2941.css\",\"style\"]\n4:HL[\"/_next/static/css/d42d805b938873da.css\",\"style\"]\n5:HL[\"/_next/static/css/0673bb6e29c473c8.css\",\"style\"]\n6:HL[\"/_next/static/css/c311d6484335995a.css\",\"style\"]\n7:HL[\"/_next/static/css/7235fa9d119901d4.css\",\"style\"]\n8:HL[\"/_next/static/css/86d6274f3e6d760c.css\",\"style\"]\n9:HL[\"/_next/static/css/a91fbeec63857000.css\",\"style\"]\na:HL[\"/_next/static/css/2d0986519abf0323.css\",\"style\"]\nb:HL[\"/_next/static/css/3e09ca0bd98e7d25.css\",\"style\"]\nc:HL[\"/_next/static/css/5a687dea857dc6f5.css\",\"style\"]\nd:HL[\"/_next/static/css/0f891de5863d7182.css\",\"style\"]\ne:I[11815,[],\"default\"]\n12:I[55092,[],\"default\"]\n13:I[82023,[],\"default\"]\n19:I[44622,[\"6470\",\"static/chunks/app/global-error-19768e91f18f21d9.js\"],\"default\"]\n14:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n15:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n16:{\"display\":\"inline-block\"}\n17:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\n1a:[]\n0:[\"$\",\"$Le\",null,{\"buildId\":\"6YnOxlQa6DuDEkBdh389I\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"~gitbook\",\"pdf?page=-LRIJnzhhl3cynIFNMlD\u0026only=yes\"],\"initialTree\":[\"\",{\"children\":[\"(space)\",{\"children\":[\"~gitbook\",{\"children\":[\"pdf\",{\"children\":[\"__PAGE__?{\\\"page\\\":\\\"-LRIJnzhhl3cynIFNMlD\\\",\\\"only\\\":\\\"yes\\\"}\",{}]},\"$undefined\",\"$undefined\",true]}]}]}],\"initialSeedData\":[\"\",{\"children\":[\"(space)\",{\"children\":[\"~gitbook\",{\"children\":[\"pdf\",{\"children\":[\"__PAGE__\",{},[[\"$Lf\",\"$L10\",[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/7235fa9d119901d4.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/86d6274f3e6d760c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"2\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/a91fbeec63857000.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"3\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/2d0986519abf0323.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"4\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/3e09ca0bd98e7d25.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"5\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/5a687dea857dc6f5.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"6\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/0f891de5863d7182.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]]],null],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/2d00a2f28ca4dc5d.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/99f50cfb598d2941.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"2\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/d42d805b938873da.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"3\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/0673bb6e29c473c8.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"4\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/c311d6484335995a.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],\"$L11\"],null],null]},[null,[\"$\",\"$L12\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"(space)\",\"children\",\"~gitbook\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L13\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[null,[\"$\",\"$L12\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"(space)\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L13\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,",{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]],null]},[null,[\"$\",\"$L12\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L13\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$14\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$15\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$16\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$17\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$L18\"],\"globalErrorComponent\":\"$19\",\"missingSlots\":\"$W1a\"}]\n1b:I[22563,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"4012\",\"static/chunks/4012-d5519c7c19347ff0.js\",\"5542\",\"static/chunks/app/(space)/~gitbook/pdf/layout-8b38eddf87d0e8b6.js\"],\"Icon\"]\n1c:I[72668,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"9505\",\"static/chunks/9505-a8f112b566ef7f41.js\",\"6150\",\"static/chunks/6150-57a79db9099e4be8.js\",\"8510\",\"static/chunks/8510-2f41b25832a6d317.js\",\"1285\",\"static/chunks/1285-2b0f91300e0c0b9a.js\",\"3902\",\"static/chunks/3902-19c217a299034164.js\",\"9028\",\"static/chunks/9028-bdf215f649fe02e9.js\",\"3350\",\"static/chunks/app/(space)/~gitbook/pdf/page-76eab181be4c30d4.js\"],\"PrintButton\"]\n1d:I[18906,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"9505\",\"static/chunks/9505-a8f112b566ef7f41.js\",\"6150\",\"static/chunks/6150-57a79db9099e4be8.js\",\"8510\",\"static/chunks/8510-2f41b25832a6d317.js\",\"1285\",\"static/chunks/1285-2b0f91300e0c0b9a.js\",\"3902\",\"static/chunks/3902-19c217a299034164.js\",\"9028\",\"static/chunks/9028-bdf215f649fe02e9.js\",\"3350\",\"static/chunks/app/(space)/~gitbook/pdf/page-76eab181be4c30d4.js\"],\"PageControlButtons\"]\n1e:\"$Sreact.suspense\"\n10:[\"$\",\"div\",null,{\"className\":\"print-mode\",\"children\":[[\"$\",\"div\",null,{\"className\":\"fixed left-12 top-12 print:hidden z-50\",\"children\":[\"$\",\"a\",null,{\"title\":\"Go back to content\",\"href\":\"/\",\"className\":\"flex flex-row items-center justify-center text-sm text-dark/6 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white shadow-sm hover:shadow-md border-slate-300 border\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"arrow-left\",\"className\":\"size-6\"}]}]}],[\"$\",\"div\",null,{\"className\":\"fixed right-12 top-12 print:hidden z-50\",\"children\":[\"$\",\"$L1c\",null,{\"title\":\"Print or Save as P"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"DF\",\"className\":\"flex flex-row items-center justify-center text-sm text-dark/6 hover:text-primary p-4 dark:text-light/5 rounded-full bg-white shadow-sm hover:shadow-md border-slate-300 border\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"print\",\"className\":\"size-6\"}]}]}],[\"$\",\"$L1d\",null,{\"pageIds\":[[\"-LRIJnzhhl3cynIFNMlD\",\"pdf-page--LRIJnzhhl3cynIFNMlD\"]],\"pdfHref\":\"https://swift.objectbox.io/~gitbook/pdf?page=-LRIJnzhhl3cynIFNMlD\u0026only=yes\",\"singlePageMode\":true,\"total\":1,\"limit\":100,\"trademark\":[\"$\",\"a\",null,{\"target\":\"_blank\",\"href\":\"https://www.gitbook.com/?utm_source=content\u0026utm_medium=trademark\u0026utm_campaign=-LR7sVOoZyL01-NkNVQJ\",\"className\":\"font-semibold ring-1 ring-inset ring-dark/2 pointer-events-auto transition-colors flex flex-row items-center hover:bg-dark/1 bg-light dark:bg-dark px-4 py-4 rounded-lg straight-corners:rounded-none hover:backdrop-blur-sm lg:ring-0 tracking-[-0.016em] dark:hover:bg-light/1 dark:ring-light/1 border border-dark/2 dark:border-light/2\",\"children\":[[\"$\",\"$L1b\",null,{\"icon\":\"gitbook\",\"className\":\"size-5 mr-3\"}],\"Powered by GitBook\"]}]}],null,[[\"$\",\"$1e\",\"-LRIJnzhhl3cynIFNMlD\",{\"fallback\":[\"$\",\"div\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD\",\"className\":\"my-11 print:my-0 mx-auto max-w-4xl w-full p-12 print:p-0 shadow-xl print:shadow-none rounded-sm bg-white min-h-[29.7cm] print:min-h-0 break-before-page break-anywhere\",\"children\":[\"$\",\"p\",null,{\"children\":\"Loading...\"}]}],\"children\":\"$L1f\"}]]]}]\n18:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"ObjectBox Swift\"}],[\"$\",\"meta\",\"3\",{\"name\":\"robots\",\"content\":\"noindex, nofollow\"}],[\"$\",\"meta\",\"4\",{\"name\":\"next-size-adjust\"}]]\nf:null\n21:I[5145,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"4012\",\"static/chunks/4012-d5519c7c19347ff0.js\",\"5542\",\"static/chunks/app/(space)/~gitbook/pdf/layout-8b38eddf87d0e8b6.js\"],\"IconsProvider\"]\n22:I[75489,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"4012\",\"static/chunks/4012-d5519c7c19347ff0.js\",\"5542\",\"static/chunks/app/(space)/~gitbook/pdf/layout-8b38eddf87d0e8b6.js\"],\"ClientContexts\"]\n20:T112c,\n :root {\n --primary-color-50: 232 246 246;\n--primary-color-100: 209 237 237;\n--primary-color-200: 162 219 219;\n--primary-color-300: 116 202 202;\n--primary-color-400: 69 184 184;\n--primary-color-500: 23 166 166;\n--primary-color-600: 18 133 133;\n--primary-color-700: 14 100 100;\n--primary-color-800: 9 66 66;\n--primary-color-900: 5 33 33;\n --contrast-primary-50: 0 0 0;\n--contrast-primary-100: 0 0 0;\n--contrast-primary-200: 0 0 0;\n--contrast-primary-300: 0 0 0;\n--contrast-primary-400: 0 0 0;\n--contrast-primary-500: 0 0 0;\n--contrast-primary-600: 0 0 0;\n--contrast-primary-700: 255 255 255;\n--contrast-primary-800: 255 255 255;\n--contrast-primary-900: 255 255 255;\n\n --primary-base-50: 232 246 246;\n--primary-base-100: 209 237 237;\n--primary-base-200: 162 219 219;\n--primary-base-300: 116 202 202;\n--primary-base-400: 69 184 184;\n--primary-base-500: 23 166 166;\n--primary-base-600: 18 133 133;\n--primary-base-700: 14 100 100;\n--primary-base-800: 9 66 66;\n--primary-base-900: 5 33 33;\n --header-background-50: 255 255 255;\n--header-background-100: 255 255 255;\n--header-background-200: 255 255 255;\n--header-background-300: 255 255 255;\n--header-background-400: 255 255 255;\n--header-background-500: 255 255 255;\n--header-background-600: 204 204 204;\n--header-background-700: 153 153 153;\n--header-background-800: 102 102 102;\n--header-background-900: 51 51 51;\n --header-link-50: 232 246 246;\n--header-link-100: 209 237 237;\n--header-link-200: 162 219 219;\n--header-link-300: 116 202 202;\n--header-link-400: 69 184 184;\n--header-link-500: 23 166 166;\n--header-link-600: 18 133 133;\n--header-link-700: 14 100 10"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"0;\n--header-link-800: 9 66 66;\n--header-link-900: 5 33 33;\n --header-button-text-50: 230 230 230;\n--header-button-text-100: 204 204 204;\n--header-button-text-200: 153 153 153;\n--header-button-text-300: 102 102 102;\n--header-button-text-400: 51 51 51;\n--header-button-text-500: 0 0 0;\n--header-button-text-600: 0 0 0;\n--header-button-text-700: 0 0 0;\n--header-button-text-800: 0 0 0;\n--header-button-text-900: 0 0 0;\n }\n .dark {\n --primary-color-50: 232 246 246;\n--primary-color-100: 209 237 237;\n--primary-color-200: 162 219 219;\n--primary-color-300: 116 202 202;\n--primary-color-400: 69 184 184;\n--primary-color-500: 23 166 166;\n--primary-color-600: 18 133 133;\n--primary-color-700: 14 100 100;\n--primary-color-800: 9 66 66;\n--primary-color-900: 5 33 33;\n --primary-base-50: 232 246 246;\n--primary-base-100: 209 237 237;\n--primary-base-200: 162 219 219;\n--primary-base-300: 116 202 202;\n--primary-base-400: 69 184 184;\n--primary-base-500: 23 166 166;\n--primary-base-600: 18 133 133;\n--primary-base-700: 14 100 100;\n--primary-base-800: 9 66 66;\n--primary-base-900: 5 33 33;\n --contrast-primary-50: 0 0 0;\n--contrast-primary-100: 0 0 0;\n--contrast-primary-200: 0 0 0;\n--contrast-primary-300: 0 0 0;\n--contrast-primary-400: 0 0 0;\n--contrast-primary-500: 0 0 0;\n--contrast-primary-600: 0 0 0;\n--contrast-primary-700: 255 255 255;\n--contrast-primary-800: 255 255 255;\n--contrast-primary-900: 255 255 255;\n --header-background-50: 230 230 230;\n--header-background-100: 204 204 204;\n--header-background-200: 153 153 153;\n--header-background-300: 102 102 102;\n--header-background-400: 51 51 51;\n--header-background-500: 0 0 0;\n--header-background-600: 0 0 0;\n--header-background-700: 0 0 0;\n--header-background-800: 0 0 0;\n--header-background-900: 0 0 0;\n --header-link-50: 232 246 246;\n--header-link-100: 209 237 237;\n--header-link-200: 162 219 219;\n--header-link-300: 116 202 202;\n--header-link-400: 69 184 184;\n--header-link-500: 23 166 166;\n--header-link-600: 18 133 133;\n--header-link-700: 14 100 100;\n--header-link-800: 9 66 66;\n--header-link-900: 5 33 33;\n --header-button-text-50: 230 230 230;\n--header-button-text-100: 204 204 204;\n--header-button-text-200: 153 153 153;\n--header-button-text-300: 102 102 102;\n--header-button-text-400: 51 51 51;\n--header-button-text-500: 0 0 0;\n--header-button-text-600: 0 0 0;\n--header-button-text-700: 0 0 0;\n--header-button-text-800: 0 0 0;\n--header-button-text-900: 0 0 0;\n }\n 11:[\"$\",\"html\",null,{\"suppressHydrationWarning\":true,\"lang\":\"en\",\"className\":\"scroll-pt-[76px] plain-background\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"link\",null,{\"rel\":\"privacy-policy\",\"href\":\"https://objectbox.io/wordpress/wp-content/uploads/2022/08/Object-Box-Privacy-Notice.pdf\"}],[\"$\",\"style\",null,{\"nonce\":\"$undefined\",\"children\":\"$20\"}]]}],[\"$\",\"body\",null,{\"className\":\"__variable_274faa __variable_a7f53a __variable_e782a9 __className_053b0a __variable_0e9704 bg-light dark:bg-dark\",\"children\":[\"$\",\"$L21\",null,{\"assetsURL\":\"https://ka-p.fontawesome.com/releases/v6.6.0/\",\"assetsURLToken\":\"a463935e93\",\"assetsByStyles\":{\"custom-icons\":{\"assetsURL\":\"/~gitbook/static/icons\"}},\"iconStyle\":\"regular\",\"children\":[\"$\",\"$L22\",null,{\"language\":{\"locale\":\"en\",\"powered_by_gitbook\":\"Powered by GitBook\",\"sponsored_via_gitbook\":\"Sponsored via GitBook\",\"switch_to_dark_theme\":\"Switch to dark theme\",\"switch_to_light_theme\":\"Switch to light theme\",\"switch_to_system_theme\":\"Switch to system theme\",\"search\":\"Search\",\"search_or_ask\":\"Ask or Search\",\"search_input_placeholder\":\"Search content\",\"search_ask_input_placeholder\":\"Search content or ask a question\",\"search_no_results\":\"No results for \\\"${1}\\\".\",\"search_scope_space\":\"$${1}\",\"search_scope_all\":\"All content\",\"search_ask\":\"Ask \\\"${1}\\\"\",\"search_ask_sources\":\"Sources\",\"search_ask_sources_no_answer\":\"Related pages\",\"search_ask_no_answer\":\"An answer could not be found for your que"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"stion. You could try rephrasing it, or be more specific.\",\"search_ask_error\":\"Something went wrong. Please try again later.\",\"on_this_page\":\"On this page\",\"next_page\":\"Next\",\"previous_page\":\"Previous\",\"page_last_modified\":\"Last updated ${1}\",\"was_this_helpful\":\"Was this helpful?\",\"was_this_helpful_positive\":\"Yes, it was!\",\"was_this_helpful_neutral\":\"Not sure\",\"was_this_helpful_negative\":\"No\",\"was_this_helpful_thank_you\":\"Thank you!\",\"annotation_button_label\":\"Open annotation\",\"code_copied\":\"Copied!\",\"code_copy\":\"Copy\",\"table_of_contents_button_label\":\"Open table of contents\",\"cookies_title\":\"Cookies\",\"cookies_prompt\":\"This site uses cookies to deliver its service and to analyse traffic. By browsing this site, you accept the ${1}.\",\"cookies_prompt_privacy\":\"privacy policy\",\"cookies_accept\":\"Accept\",\"cookies_reject\":\"Reject\",\"cookies_close\":\"Close\",\"edit_on_git\":\"Edit on ${1}\",\"notfound_title\":\"Page not found\",\"notfound\":\"The page you are looking for doesn't exist.\",\"unexpected_error_title\":\"An error occurred\",\"unexpected_error\":\"Sorry, an unexpected error has occurred. Please try again later.\",\"unexpected_error_retry\":\"Retry\",\"pdf_download\":\"Export as PDF\",\"pdf_goback\":\"Go back to content\",\"pdf_print\":\"Print or Save as PDF\",\"pdf_page_of\":\"$${1} of ${2}\",\"pdf_mode_only_page\":\"Only this page\",\"pdf_mode_all\":\"All pages\",\"pdf_limit_reached\":\"Couldn't generate the PDF for ${1} pages, generation stopped at ${2}.\",\"pdf_limit_reached_continue\":\"Extend with ${1} more pages.\",\"more\":\"More\"},\"children\":[\"$\",\"$L12\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"(space)\",\"children\",\"~gitbook\",\"children\",\"pdf\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L13\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]}]}]}]]}]\n"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"23:\"$Sreact.fragment\"\n"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"1f:[\"$\",\"div\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD\",\"className\":\"my-11 print:my-0 mx-auto max-w-4xl w-full p-12 print:p-0 shadow-xl print:shadow-none rounded-sm bg-white min-h-[29.7cm] print:min-h-0 break-before-page break-anywhere\",\"children\":[[\"$\",\"h1\",null,{\"className\":\"text-4xl font-bold\",\"children\":\"Transactions\"}],[\"$\",\"p\",null,{\"className\":\"decoration-primary/6 mt-2 mb-3\",\"children\":\"ObjectBox for Swift is a fully transactional NoSQL database and ACID compliant. Learn here how database transactions work. Also, how does multiversion concurrency work?\"}],[\"$\",\"div\",null,{\"className\":\"mt-6 space-y-6 whitespace-pre-wrap\",\"children\":[[\"$\",\"h2\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-what-are-objectbox-transactions\",\"className\":\"text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-what-are-objectbox-transactions\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[1em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"What are ObjectBox Transactions?\"}]]]}]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"A database transaction groups several operations into a single unit of work that either executes completely or not at all. If you are looking for a more detailed introduction to transactions in general, check out this Wikipedia article on \"}]],\"$L24\",[[\"$\",\"$23\",\"0\",{\"children\":\".\"}]]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"You may not notice it, but almost all interactions with ObjectBox involve transactions. For example, if you call \"}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"put\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\" a write transaction is used. Also if you \"}],[\"$\",\"$23\",\"3\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"get\"}]}],[\"$\",\"$23\",\"4\",{\"children\":\" an object or query for objects, a read transaction is used. All of this is done under the hood and transparent to you. It may be fine to completely ignore transactions in your app without running into any problems. With more complex apps however, it’s usually worth learning transaction basics to make your app more consistent and efficient.\"}]]]}],[\"$\",\"h2\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-explicit-transactions\",\"className\":\"text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-explicit-transactions\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hov"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"er:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[1em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Explicit transactions\"}]]]}]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"All ObjectBox operations run in implicit transactions – unless an explicit transaction is in progress. In the latter case, multiple operations share the (explicit) transaction. In other words, with explicit transactions you control the transaction boundary. Doing so can greatly improve efficiency and consistency in your app.\"}]]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"The class \"}]],\"$L25\",[[\"$\",\"$23\",\"0\",{\"children\":\" offers the following methods to perform explicit transactions:\"}]]]}],[\"$\",\"ul\",null,{\"className\":\"space-y-2 w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"li\",null,{\"className\":\"leading-normal flex items-start\",\"children\":[[\"$\",\"div\",null,{\"className\":\"text-base leading-normal flex items-center justify-center mr-1 min-h-[1lh] min-w-6 text-dark/6 dark:text-light/5\",\"children\":[\"$\",\"div\",null,{\"className\":\"before:font-var before:content-[--pseudoBefore--content]\",\"style\":{\"--pseudoBefore--content\":\"'•'\",\"--font-family\":\"Arial\",\"fontSize\":\"min(1.5em, 24px)\",\"lineHeight\":1}}]}],[\"$\",\"div\",null,{\"className\":\"space-y-2 flex flex-col flex-1\",\"children\":[[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-3xl min-h-[1lh] flip-heading-hash [\u0026:is(h2)\u003ediv]:mt-0 [\u0026:is(h3)\u003ediv]:mt-0 [\u0026:is(h4)\u003ediv]:mt-0\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"runInTransaction\"}]}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"strong\",null,{\"className\":\"font-bold\",\"children\":\":\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\" Runs the given closure inside a transaction (comes in result-forwarding and/or throwing variants).\"}]]]}]]}]]}],[\"$\",\"li\",null,{\"className\":\"leading-normal flex items-start\",\"children\":[[\"$\",\"div\",null,{\"className\":\"text-base leading-normal flex items-center justify-center mr-1 min-h-[1lh] min-w-6 text-dark/6 dark:text-light/5\",\"children\":[\"$\",\"div\",null,{\"className\":\"before:font-var before:content-[--pseudoBefore--content]\",\"style\":{\"--pseudoBefore--content\":\"'•'\",\"--font-family\":\"Arial\",\"fontSize\":\"min(1.5em, 24px)\",\"lineHeight\":1}}]}],[\"$\",\"div\",null,{\"className\":\"space-y-2 flex flex-col flex-1\",\"children\":[[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-3xl min-h-[1lh] flip-heading-hash [\u0026:is(h2)\u003ediv]:mt-0 [\u0026:is(h3)\u003ediv]:mt-0 [\u0026:is(h4)\u003ediv]:mt-0\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"runInReadOnlyTransaction\"}]}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"strong\",null,{\"className\":\"font-bold\",\"children\":\":\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\" Runs the given closure inside a read(-only) transaction. Unlike write transactions, multiple read transactions can run at the same time.\"}]]]}]]}]]}]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"The advantage of explicit transactions over the bulk put operations is that you can perform any number of operations and use objects of multiple boxes. In addition, you get a consistent (transactional) view on your data while the transaction is in progress.\"}]]]}],[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Example for a write transaction:\"}]]]}],\"$L26\",[\"$\",\"$1e\",null,{\""])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"fallback\":[\"$\",\"div\",null,{\"id\":\"transaction-costs\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[47px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"h2\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-transaction-costs\",\"className\":\"text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-transaction-costs\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[1em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Transaction Costs\"}]]]}]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Understanding transactions is essential to master database performance. If you just remember one sentence on this topic, it should be this one: a write transaction has its price.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"classN"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"ame\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Committing a transaction involves syncing data to the physical storage, which is a relatively expensive operation for databases. Only when the file system confirms that all data has been stored in a durable manner (not just memory cached), the transaction can be considered successful. This file sync required by a transaction may take a couple of milliseconds. Keep this in mind and try to group several operations (e.g.\"}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"put\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\"calls) in one transaction.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Consider this example:\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"skeleton-paragraph\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md [height:calc(15rem-1px)] [max-width:calc(48rem-1px)] w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_48px_48px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":\"$L27\"}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Do you see what’s wrong wit"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"h that code? There is an implicit transaction for each user which is very inefficient especially for a high number of objects. It is much more efficient to use of of the put overloads to store all users at once:\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"skeleton-paragraph\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md [height:calc(15rem-1px)] [max-width:calc(48rem-1px)] w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_48px_48px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":\"$L28\"}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Much better! If you have 1,000 users, the latter example uses a single transaction to store all users. The first code example uses 1,000 (!) implicit transactions causing a massive slow down.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"read-transactions\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[47px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"h2\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-read-transactions\",\"className\":\"text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-read-transactions\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight\",\"children\":[\"$\",\"$L1b\",null,{\"ico"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"n\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[1em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Read Transactions\"}]]]}]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"In ObjectBox, read transactions are cheap. In contrast to write transactions, there is no commit and thus no expensive sync to the file system. Operations like \"}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"get\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\" , \"}],[\"$\",\"$23\",\"3\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"count\"}]}],[\"$\",\"$23\",\"4\",{\"children\":\" , and queries run inside an implicit read transaction if they are not called when already inside an explicit transaction (read or write). Note that it is illegal to \"}],[\"$\",\"$23\",\"5\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"put\"}]}],[\"$\",\"$23\",\"6\",{\"children\":\" when inside a read transaction: an exception will be thrown.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"While read transactions are much cheaper than write transactions, there is still some overhead to starting a read transaction. Thus, for a high number of reads (e.g. hundreds, in a loop), you can improve performance by grouping"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1," those reads in a single read transaction (see explicit transactions below).\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"multiversion-concurrency\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[47px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"h2\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-multiversion-concurrency\",\"className\":\"text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-multiversion-concurrency\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[1em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Multiversion concurrency\"}]]]}]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"ObjectBox gives developers \"}]],\"$L29\",[[\"$\",\"$23\",\"0\",{\"children\":\" semantics. This allows multiple concurrent readers (read transactions) which can execute immediately without blocking or waiting. This is guaranteed by storing multiple versions of (committed) data. Even if a write transaction is in progress, a read transaction can read the last consistent state immediately. Write transactions are executed sequentially to ensure a consistent state. Thus, it is advised to keep write transactions short to avoid blocking other pending write transactions. For example, it is usually a bad idea to do networking or complex calculations while inside a write transaction. Instead, do any expensive operation and prepare objects before entering a write transaction.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:rin"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"g-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Note that you do not have to worry about making write transactions sequential yourself. If multiple threads want to write at the same time (e.g. via \"}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"put\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\" or \"}],[\"$\",\"$23\",\"3\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"runInTransaction\"}]}],[\"$\",\"$23\",\"4\",{\"children\":\"), one of the threads will be selected to go first, while the other threads have to wait. It works just like a lock.\"}]]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"locking-inside-a-write-transaction\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[47px] [max-width:calc(48rem-1px)]\",\"children\":[\"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"h3\",null,{\"id\":\"pdf-page--LRIJnzhhl3cynIFNMlD-locking-inside-a-write-transaction\",\"className\":\"text-2xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[0.75em]\",\"children\":[\"$\",\"a\",null,{\"href\":\"#pdf-page--LRIJnzhhl3cynIFNMlD-locking-inside-a-write-transaction\",\"aria-label\":\"Direct link to heading\",\"className\":\"inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-snug\",\"children\":[\"$\",\"$L1b\",null,{\"icon\":\"hashtag\",\"className\":\"w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4\"}]}]}],[\"$\",\"div\",null,{\"className\":\"grid-area-1-1 z-[1] mt-[0.75em]\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Locking inside a Write Transaction\"}]]]}]]}]}],[\"$\",\"$1e\",null,{\"fallback\":[\"$\",\"div\",null,{\"id\":\"$undefined\",\"role\":\"status\",\"aria-busy\":true,\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[\"$\",\"div\",null,{\"className\":\"ring-1 ring-dark/2 overflow-hidden relative grid dark:ring-light/1 rounded-md h-[35px] [max-width:calc(48rem-1px)]\",\"children\":[\""])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"$\",\"div\",null,{\"className\":\"w-full bg-dark-4/4 dark:bg-light-3/1 grid grid-area-1-1 overflow-hidden [mask:conic-gradient(from_90deg_at_1px_1px,_#0000_90deg,_#0003_0)_calc(50%+1px)_calc(0%+47px)_/_12px_12px]\",\"children\":[\"$\",\"div\",null,{\"className\":\"aspect-square from-dark-4 to-transparent grid-area-1-1 relative origin-[50%_50%] top-[50%] self-stretch bg-transparent will-change-transform animate-[rotateLoop_2s_linear_infinite] [background-image:conic-gradient(from_-90deg_at_50%_50%,_var(--tw-gradient-stops)_0deg,_var(--tw-gradient-stops)_90deg,_var(--tw-gradient-stops)_280deg)] dark:from-light-4/6\"}]}]}]}],\"children\":[\"$\",\"p\",null,{\"className\":\"w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Avoid locking (even implicitly by e.g. calling \"}],[\"$\",\"$23\",\"1\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"DispatchQueue.sync\"}]}],[\"$\",\"$23\",\"2\",{\"children\":\"or explicitly using \"}],[\"$\",\"$23\",\"3\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"NSLock\"}]}],[\"$\",\"$23\",\"4\",{\"children\":\" or \"}],[\"$\",\"$23\",\"5\",{\"children\":[\"$\",\"code\",null,{\"className\":\"py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]\",\"children\":\"objc_sync_enter\"}]}],[\"$\",\"$23\",\"6\",{\"children\":\") when inside a write transaction when possible. Because write transactions run exclusively, they effectively acquire a write lock internally. As with all locks, you need to pay close attention when multiple locks are involved. Always obtain locks in the same order to avoid deadlocks. If you acquire a lock “X” inside a transaction, you must ensure that your code does not start another write transaction while having the lock “X”.\"}]]]}]}]]}]]}]\n"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"2a:I[22833,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"4012\",\"static/chunks/4012-d5519c7c19347ff0.js\",\"5542\",\"static/chunks/app/(space)/~gitbook/pdf/layout-8b38eddf87d0e8b6.js\"],\"Link\"]\n2b:I[17370,[\"2634\",\"static/chunks/b5d5b83b-3d9186fb60556c53.js\",\"7609\",\"static/chunks/7609-ae1015bd89577747.js\",\"1281\",\"static/chunks/1281-411df876b32e19c2.js\",\"9505\",\"static/chunks/9505-a8f112b566ef7f41.js\",\"6150\",\"static/chunks/6150-57a79db9099e4be8.js\",\"8510\",\"static/chunks/8510-2f41b25832a6d317.js\",\"1285\",\"static/chunks/1285-2b0f91300e0c0b9a.js\",\"3902\",\"static/chunks/3902-19c217a299034164.js\",\"9028\",\"static/chunks/9028-bdf215f649fe02e9.js\",\"3350\",\"static/chunks/app/(space)/~gitbook/pdf/page-76eab181be4c30d4.js\"],\"CopyCodeButton\"]\n24:[\"$\",\"$L2a\",null,{\"href\":\"https://en.wikipedia.org/wiki/Database_transaction\",\"className\":\"underline underline-offset-2 text-primary hover:text-primary-700 transition-colors \",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"database transactions\"}]]]}]\n25:[\"$\",\"$L2a\",null,{\"href\":\"https://objectbox.io/docfiles/swift/current/Classes/Store.html\",\"className\":\"underline underline-offset-2 text-primary hover:text-primary-700 transition-colors \",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Store\"}]]]}]\n29:[\"$\",\"$L2a\",null,{\"href\":\"https://en.wikipedia.org/wiki/Multiversion_concurrency_control\",\"className\":\"underline underline-offset-2 text-primary hover:text-primary-700 transition-colors \",\"children\":[[[\"$\",\"$23\",\"0\",{\"children\":\"Multiversion concurrency control (MVCC)\"}]]]}]\n"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"26:[\"$\",\"div\",null,{\"className\":\"group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"flex items-center justify-start [grid-area:1/1] text-sm gap-2\",\"children\":null}],[\"$\",\"$L2b\",null,{\"codeId\":\"7276abad27114ae89ea6b3a75d1276c9\",\"style\":[\"group-hover/codeblock:opacity-[1]\",\"transition-opacity\",\"duration-75\",\"opacity-0\",\"text-xs\",\"[grid-area:2/1]\",\"z-[2]\",\"justify-self-end\",\"backdrop-blur-md\",\"leading-none\",\"self-start\",\"ring-1\",\"ring-dark/2\",\"text-dark/7\",\"bg-transparent\",\"rounded-md\",\"mr-2\",\"mt-2\",\"p-1\",\"hover:ring-dark/3\",\"dark:ring-light/2\",\"dark:text-light/7\",\"dark:hover:ring-light/3\"]}],[\"$\",\"pre\",null,{\"className\":\"[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm\",\"children\":[\"$\",\"code\",null,{\"id\":\"7276abad27114ae89ea6b3a75d1276c9\",\"className\":\"min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]\",\"children\":[[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" store.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"runInTransaction\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" {\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" allUsers.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"forEach\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" { user \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"in\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\""])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"if\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"modify\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"))\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" {\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" box.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"put\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" } \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"else\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" {\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"childr"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"en\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" box.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"remove\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" }\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" }\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\"}\"}]],null]}]]}]]}]}]]}]\n27:[\"$\",\"div\",null,{\"className\":\"group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"flex items-center justify-start [grid-area:1/1] text-sm gap-2\",\"children\":null}],[\"$\",\"$L2b\",null,{\"codeId\":\"238ea954e3cf493fbba3db48e92635b9\",\"style\":[\"group-hover/codeblock:opacity-[1]\",\"transition-opacity\",\"duration-75\",\"opacity-0\",\"text-xs\",\"[grid-area:2/1]\",\"z-[2]\",\"justify-self-end\",\"backdrop-blur-md\",\"leading-none\",\"self-start\",\"ring-1\",\"ring-dark/2\",\"text-dark/7\",\"bg-transparent\",\"rounded-md\",\"mr-2\",\"mt-2\",\"p-1\",\"hover:ring-dark/3\",\"dark:ring-light/2\",\"dark:text-light/7\",\"dark:hover:ring-light/3\"]}],[\"$\",\"pre\",null,{\"className\":\"[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm\",\"children\":[\"$\",\"code\",null,{\"id\":\"238ea954e3cf493fbba3db48e92635b9\",\"className\":\"min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]\",\"children\":[[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 rel"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"ative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" allUsers.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"forEach\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" { user \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"in\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"modify\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-comment)\"},\"children\":\"// modifies properties of given user\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" box.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"put\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.hig"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"hlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\"}\"}]],null]}]]}]]}]}]]}]\n28:[\"$\",\"div\",null,{\"className\":\"group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full\",\"children\":[[\"$\",\"div\",null,{\"className\":\"flex items-center justify-start [grid-area:1/1] text-sm gap-2\",\"children\":null}],[\"$\",\"$L2b\",null,{\"codeId\":\"5cb53639380448ddb08b50c0f0eb3848\",\"style\":[\"group-hover/codeblock:opacity-[1]\",\"transition-opacity\",\"duration-75\",\"opacity-0\",\"text-xs\",\"[grid-area:2/1]\",\"z-[2]\",\"justify-self-end\",\"backdrop-blur-md\",\"leading-none\",\"self-start\",\"ring-1\",\"ring-dark/2\",\"text-dark/7\",\"bg-transparent\",\"rounded-md\",\"mr-2\",\"mt-2\",\"p-1\",\"hover:ring-dark/3\",\"dark:ring-light/2\",\"dark:text-light/7\",\"dark:hover:ring-light/3\"]}],[\"$\",\"pre\",null,{\"className\":\"[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm\",\"children\":[\"$\",\"code\",null,{\"id\":\"5cb53639380448ddb08b50c0f0eb3848\",\"className\":\"min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]\",\"children\":[[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" allUsers.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"forEach\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" { user \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"in\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"modify\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"user\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" \"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"v"])</script><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">self.__next_f.push([1,"ar(--shiki-token-comment)\"},\"children\":\"// modifies properties of given user\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\"}\"}]],\"\\n\"]}]]}],[\"$\",\"span\",null,{\"className\":\"grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [\u0026.highlighted:first-child]:rounded-t-md [\u0026.highlighted:first-child\u003e*]:mt-1 [\u0026.highlighted:last-child]:rounded-b-md [\u0026.highlighted:last-child\u003e*]:mb-1 [\u0026:only-child]:hover:ring-transparent [\u0026.highlighted]:rounded-none [\u0026:not(.highlighted)_+_.highlighted]:rounded-t-md [\u0026:not(.highlighted)_+_.highlighted\u003e*]:mt-1 [\u0026.highlighted:has(+:not(.highlighted))]:rounded-b-md [\u0026.highlighted:has(+:not(.highlighted))\u003e*]:mb-1 [\u0026:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md\",\"children\":[null,[\"$\",\"span\",null,{\"className\":\"ml-3 block text-sm\",\"children\":[[[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-keyword)\"},\"children\":\"try\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-foreground)\"},\"children\":\" box.\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"put\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\"(\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-function)\"},\"children\":\"allUsers\"}],[\"$\",\"span\",null,{\"style\":{\"color\":\"var(--shiki-token-punctuation)\"},\"children\":\")\"}]],null]}]]}]]}]}]]}]\n"])</script><div hidden id="S:0"><div id="pdf-page--LRIJnzhhl3cynIFNMlD" class="my-11 print:my-0 mx-auto max-w-4xl w-full p-12 print:p-0 shadow-xl print:shadow-none rounded-sm bg-white min-h-[29.7cm] print:min-h-0 break-before-page break-anywhere"><h1 class="text-4xl font-bold">Transactions</h1><p class="decoration-primary/6 mt-2 mb-3">ObjectBox for Swift is a fully transactional NoSQL database and ACID compliant. Learn here how database transactions work. Also, how does multiversion concurrency work?</p><div class="mt-6 space-y-6 whitespace-pre-wrap"><h2 id="pdf-page--LRIJnzhhl3cynIFNMlD-what-are-objectbox-transactions" class="text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-what-are-objectbox-transactions" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[1em]">What are ObjectBox Transactions?</div></h2><p class="w-full mx-auto decoration-primary/6 max-w-full">A database transaction groups several operations into a single unit of work that either executes completely or not at all. If you are looking for a more detailed introduction to transactions in general, check out this Wikipedia article on <a class="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors " href="https://en.wikipedia.org/wiki/Database_transaction">database transactions</a>.</p><p class="w-full mx-auto decoration-primary/6 max-w-full">You may not notice it, but almost all interactions with ObjectBox involve transactions. For example, if you call <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">put</code> a write transaction is used. Also if you <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">get</code> an object or query for objects, a read transaction is used. All of this is done under the hood and transparent to you. It may be fine to completely ignore transactions in your app without running into any problems. With more complex apps however, it’s usually worth learning transaction basics to make your app more consistent and efficient.</p><h2 id="pdf-page--LRIJnzhhl3cynIFNMlD-explicit-transactions" class="text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-explicit-transactions" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[1em]">Explicit transactions</div></h2><p class="w-full mx-auto decoration-primary/6 max-w-full">All ObjectBox operations run in implicit transactions – unless an explicit transaction is in progress. In the latter case, multiple operations share the (explicit) transaction. In other words, with explicit transactions you control the transaction boundary. Doing so can greatly improve efficiency and consistency in your app.</p><p class="w-full mx-auto decoration-primary/6 max-w-full">The class <a class="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors " href="https://objectbox.io/docfiles/swift/current/Classes/Store.html">Store</a> offers the following methods to perform explicit transactions:</p><ul class="space-y-2 w-full mx-auto decoration-primary/6 max-w-full"><li class="leading-normal flex items-start"><div class="text-base leading-normal flex items-center justify-center mr-1 min-h-[1lh] min-w-6 text-dark/6 dark:text-light/5"><div class="before:font-var before:content-[--pseudoBefore--content]" style="--pseudoBefore--content:&#x27;•&#x27;;--font-family:Arial;font-size:min(1.5em, 24px);line-height:1"></div></div><div class="space-y-2 flex flex-col flex-1"><p class="w-full mx-auto decoration-primary/6 max-w-3xl min-h-[1lh] flip-heading-hash [&amp;:is(h2)&gt;div]:mt-0 [&amp;:is(h3)&gt;div]:mt-0 [&amp;:is(h4)&gt;div]:mt-0"><code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">runInTransaction</code><strong class="font-bold">:</strong> Runs the given closure inside a transaction (comes in result-forwarding and/or throwing variants).</p></div></li><li class="leading-normal flex items-start"><div class="text-base leading-normal flex items-center justify-center mr-1 min-h-[1lh] min-w-6 text-dark/6 dark:text-light/5"><div class="before:font-var before:content-[--pseudoBefore--content]" style="--pseudoBefore--content:&#x27;•&#x27;;--font-family:Arial;font-size:min(1.5em, 24px);line-height:1"></div></div><div class="space-y-2 flex flex-col flex-1"><p class="w-full mx-auto decoration-primary/6 max-w-3xl min-h-[1lh] flip-heading-hash [&amp;:is(h2)&gt;div]:mt-0 [&amp;:is(h3)&gt;div]:mt-0 [&amp;:is(h4)&gt;div]:mt-0"><code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">runInReadOnlyTransaction</code><strong class="font-bold">:</strong> Runs the given closure inside a read(-only) transaction. Unlike write transactions, multiple read transactions can run at the same time.</p></div></li></ul><p class="w-full mx-auto decoration-primary/6 max-w-full">The advantage of explicit transactions over the bulk put operations is that you can perform any number of operations and use objects of multiple boxes. In addition, you get a consistent (transactional) view on your data while the transaction is in progress.</p><p class="w-full mx-auto decoration-primary/6 max-w-full">Example for a write transaction:</p><div class="group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2"></div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button><pre class="[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm"><code id="7276abad27114ae89ea6b3a75d1276c9" class="min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]"><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> store.</span><span style="color:var(--shiki-token-function)">runInTransaction</span><span style="color:var(--shiki-foreground)"> {</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> allUsers.</span><span style="color:var(--shiki-token-function)">forEach</span><span style="color:var(--shiki-foreground)"> { user </span><span style="color:var(--shiki-token-keyword)">in</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-keyword)">if</span><span style="color:var(--shiki-token-function)"> </span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">modify</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">))</span><span style="color:var(--shiki-foreground)"> {</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> box.</span><span style="color:var(--shiki-token-function)">put</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">)</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> } </span><span style="color:var(--shiki-token-keyword)">else</span><span style="color:var(--shiki-foreground)"> {</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> box.</span><span style="color:var(--shiki-token-function)">remove</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">)</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> }</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> }</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)">}</span></span></span></code></pre></div><!--$--><h2 id="pdf-page--LRIJnzhhl3cynIFNMlD-transaction-costs" class="text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-transaction-costs" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[1em]">Transaction Costs</div></h2><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Understanding transactions is essential to master database performance. If you just remember one sentence on this topic, it should be this one: a write transaction has its price.</p><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Committing a transaction involves syncing data to the physical storage, which is a relatively expensive operation for databases. Only when the file system confirms that all data has been stored in a durable manner (not just memory cached), the transaction can be considered successful. This file sync required by a transaction may take a couple of milliseconds. Keep this in mind and try to group several operations (e.g.<code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">put</code>calls) in one transaction.</p><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Consider this example:</p><!--/$--><!--$--><div class="group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2"></div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button><pre class="[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm"><code id="238ea954e3cf493fbba3db48e92635b9" class="min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]"><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> allUsers.</span><span style="color:var(--shiki-token-function)">forEach</span><span style="color:var(--shiki-foreground)"> { user </span><span style="color:var(--shiki-token-keyword)">in</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-function)">modify</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">)</span><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-comment)">// modifies properties of given user</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> box.</span><span style="color:var(--shiki-token-function)">put</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">)</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)">}</span></span></span></code></pre></div><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Do you see what’s wrong with that code? There is an implicit transaction for each user which is very inefficient especially for a high number of objects. It is much more efficient to use of of the put overloads to store all users at once:</p><!--/$--><!--$--><div class="group/codeblock grid grid-flow-col w-full mx-auto decoration-primary/6 max-w-full"><div class="flex items-center justify-start [grid-area:1/1] text-sm gap-2"></div><button class="group-hover/codeblock:opacity-[1] transition-opacity duration-75 opacity-0 text-xs [grid-area:2/1] z-[2] justify-self-end backdrop-blur-md leading-none self-start ring-1 ring-dark/2 text-dark/7 bg-transparent rounded-md mr-2 mt-2 p-1 hover:ring-dark/3 dark:ring-light/2 dark:text-light/7 dark:hover:ring-light/3 print:hidden">Copy</button><pre class="[grid-area:2/1] relative overflow-auto bg-light-2 dark:bg-dark-2 border-light-4 dark:border-dark-4 hide-scroll rounded-md straight-corners:rounded-sm"><code id="5cb53639380448ddb08b50c0f0eb3848" class="min-w-full inline-grid [grid-template-columns:auto_1fr] py-2 px-2 [counter-reset:line]"><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> allUsers.</span><span style="color:var(--shiki-token-function)">forEach</span><span style="color:var(--shiki-foreground)"> { user </span><span style="color:var(--shiki-token-keyword)">in</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-function)">modify</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">user</span><span style="color:var(--shiki-token-punctuation)">)</span><span style="color:var(--shiki-foreground)"> </span><span style="color:var(--shiki-token-comment)">// modifies properties of given user</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-foreground)">}</span> </span></span><span class="grid [grid-template-columns:subgrid] col-span-2 relative ring-1 ring-transparent hover:ring-dark-4/5 hover:z-[1] dark:hover:ring-light-4/4 rounded [&amp;.highlighted:first-child]:rounded-t-md [&amp;.highlighted:first-child&gt;*]:mt-1 [&amp;.highlighted:last-child]:rounded-b-md [&amp;.highlighted:last-child&gt;*]:mb-1 [&amp;:only-child]:hover:ring-transparent [&amp;.highlighted]:rounded-none [&amp;:not(.highlighted)_+_.highlighted]:rounded-t-md [&amp;:not(.highlighted)_+_.highlighted&gt;*]:mt-1 [&amp;.highlighted:has(+:not(.highlighted))]:rounded-b-md [&amp;.highlighted:has(+:not(.highlighted))&gt;*]:mb-1 [&amp;:not(.highlighted)_+_.highlighted:has(+:not(.highlighted))]:rounded-md"><span class="ml-3 block text-sm"><span style="color:var(--shiki-token-keyword)">try</span><span style="color:var(--shiki-foreground)"> box.</span><span style="color:var(--shiki-token-function)">put</span><span style="color:var(--shiki-token-punctuation)">(</span><span style="color:var(--shiki-token-function)">allUsers</span><span style="color:var(--shiki-token-punctuation)">)</span></span></span></code></pre></div><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Much better! If you have 1,000 users, the latter example uses a single transaction to store all users. The first code example uses 1,000 (!) implicit transactions causing a massive slow down.</p><!--/$--><!--$--><h2 id="pdf-page--LRIJnzhhl3cynIFNMlD-read-transactions" class="text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-read-transactions" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[1em]">Read Transactions</div></h2><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">In ObjectBox, read transactions are cheap. In contrast to write transactions, there is no commit and thus no expensive sync to the file system. Operations like <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">get</code> , <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">count</code> , and queries run inside an implicit read transaction if they are not called when already inside an explicit transaction (read or write). Note that it is illegal to <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">put</code> when inside a read transaction: an exception will be thrown.</p><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">While read transactions are much cheaper than write transactions, there is still some overhead to starting a read transaction. Thus, for a high number of reads (e.g. hundreds, in a loop), you can improve performance by grouping those reads in a single read transaction (see explicit transactions below).</p><!--/$--><!--$--><h2 id="pdf-page--LRIJnzhhl3cynIFNMlD-multiversion-concurrency" class="text-3xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[1em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-multiversion-concurrency" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-tight"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[1em]">Multiversion concurrency</div></h2><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">ObjectBox gives developers <a class="underline underline-offset-2 text-primary hover:text-primary-700 transition-colors " href="https://en.wikipedia.org/wiki/Multiversion_concurrency_control">Multiversion concurrency control (MVCC)</a> semantics. This allows multiple concurrent readers (read transactions) which can execute immediately without blocking or waiting. This is guaranteed by storing multiple versions of (committed) data. Even if a write transaction is in progress, a read transaction can read the last consistent state immediately. Write transactions are executed sequentially to ensure a consistent state. Thus, it is advised to keep write transactions short to avoid blocking other pending write transactions. For example, it is usually a bad idea to do networking or complex calculations while inside a write transaction. Instead, do any expensive operation and prepare objects before entering a write transaction.</p><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Note that you do not have to worry about making write transactions sequential yourself. If multiple threads want to write at the same time (e.g. via <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">put</code> or <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">runInTransaction</code>), one of the threads will be selected to go first, while the other threads have to wait. It works just like a lock.</p><!--/$--><!--$--><h3 id="pdf-page--LRIJnzhhl3cynIFNMlD-locking-inside-a-write-transaction" class="text-2xl font-semibold group relative grid w-full mx-auto decoration-primary/6 max-w-full"><div class="grid grid-area-1-1 relative -ml-6 w-7 border-0 opacity-0 group-hover:opacity-[0] group-focus:opacity-[0] md:group-hover:md:opacity-[1] md:group-focus:md:opacity-[1] mt-[0.75em]"><a href="#pdf-page--LRIJnzhhl3cynIFNMlD-locking-inside-a-write-transaction" aria-label="Direct link to heading" class="inline-flex h-full items-start dark:text-light/3 dark:shadow-none dark:ring-0 leading-snug"><svg style="mask-image:url(https://ka-p.fontawesome.com/releases/v6.6.0/svgs/regular/hashtag.svg?v=2&amp;token=a463935e93);mask-repeat:no-repeat;mask-position:center" class="gb-icon w-3.5 h-[1lh] transition-colors text-transparent group-hover:text-dark/6 dark:group-hover:text-light/5 lg:w-4"></svg></a></div><div class="grid-area-1-1 z-[1] mt-[0.75em]">Locking inside a Write Transaction</div></h3><!--/$--><!--$--><p class="w-full mx-auto decoration-primary/6 max-w-full">Avoid locking (even implicitly by e.g. calling <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">DispatchQueue.sync</code>or explicitly using <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">NSLock</code> or <code class="py-[1px] px-1.5 min-w-[1.625rem] inline-flex justify-center items-center ring-1 ring-inset ring-dark/1 bg-dark/[0.06] rounded text-dark/8 dark:ring-light/1 dark:bg-light/1 dark:text-light/7 text-[.875em] leading-[calc(max(1.20em,1.25rem))]">objc_sync_enter</code>) when inside a write transaction when possible. Because write transactions run exclusively, they effectively acquire a write lock internally. As with all locks, you need to pay close attention when multiple locks are involved. Always obtain locks in the same order to avoid deadlocks. If you acquire a lock “X” inside a transaction, you must ensure that your code does not start another write transaction while having the lock “X”.</p><!--/$--></div></div></div><script nonce="YTRjMDUwMGYtZjUzNi00ZDE5LWI1ZjAtM2I0NTY1NmY4ZTNh">$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};$RC("B:0","S:0")</script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10