diff --git a/404.html b/404.html index 05f5f9a60..052367602 100644 --- a/404.html +++ b/404.html @@ -2,7 +2,7 @@ - + TinyORM @@ -13,9 +13,9 @@ - - - + + +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/assets/css/styles.2550f915.css b/assets/css/styles.9d71b6ff.css similarity index 53% rename from assets/css/styles.2550f915.css rename to assets/css/styles.9d71b6ff.css index 9cb321518..5ee107e76 100644 --- a/assets/css/styles.2550f915.css +++ b/assets/css/styles.9d71b6ff.css @@ -1 +1 @@ -.col,.container{padding:0 var(--ifm-spacing-horizontal);width:100%}.markdown>h2,.markdown>h3,.markdown>h4,.markdown>h5,.markdown>h6{margin-bottom:calc(var(--ifm-heading-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown li,body{word-wrap:break-word}body,ol ol,ol ul,ul ol,ul ul{margin:0}pre,table{overflow:auto}blockquote,pre{margin:0 0 var(--ifm-spacing-vertical)}.breadcrumbs__link,.button{transition-timing-function:var(--ifm-transition-timing-default)}.button--outline.button--active,.button--outline:active,.button--outline:hover,:root{--ifm-button-color:var(--ifm-font-color-base-inverse)}.menu__link:hover,a{transition:color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.navbar--dark,:root{--ifm-navbar-link-hover-color:var(--ifm-color-primary)}.menu,.navbar-sidebar{overflow-x:hidden}:root,html[data-theme=dark]{--ifm-color-emphasis-500:var(--ifm-color-gray-500)}#apitable-sponsors table,pre code{font-size:100%}#tinyorm-configuration input,.button,code{vertical-align:middle}*,.DocSearch-Container,.DocSearch-Container *{box-sizing:border-box}.toggleButton_gllP,html{-webkit-tap-highlight-color:transparent}:root{--ifm-color-scheme:light;--ifm-dark-value:10%;--ifm-darker-value:15%;--ifm-darkest-value:30%;--ifm-light-value:15%;--ifm-lighter-value:30%;--ifm-lightest-value:50%;--ifm-contrast-background-value:90%;--ifm-contrast-foreground-value:70%;--ifm-contrast-background-dark-value:70%;--ifm-contrast-foreground-dark-value:90%;--ifm-color-primary:#3578e5;--ifm-color-secondary:#ebedf0;--ifm-color-success:#00a400;--ifm-color-info:#54c7ec;--ifm-color-warning:#ffba00;--ifm-color-danger:#fa383e;--ifm-color-primary-dark:#306cce;--ifm-color-primary-darker:#2d66c3;--ifm-color-primary-darkest:#2554a0;--ifm-color-primary-light:#538ce9;--ifm-color-primary-lighter:#72a1ed;--ifm-color-primary-lightest:#9abcf2;--ifm-color-primary-contrast-background:#ebf2fc;--ifm-color-primary-contrast-foreground:#102445;--ifm-color-secondary-dark:#d4d5d8;--ifm-color-secondary-darker:#c8c9cc;--ifm-color-secondary-darkest:#a4a6a8;--ifm-color-secondary-light:#eef0f2;--ifm-color-secondary-lighter:#f1f2f5;--ifm-color-secondary-lightest:#f5f6f8;--ifm-color-secondary-contrast-background:#fdfdfe;--ifm-color-secondary-contrast-foreground:#474748;--ifm-color-success-dark:#009400;--ifm-color-success-darker:#008b00;--ifm-color-success-darkest:#007300;--ifm-color-success-light:#26b226;--ifm-color-success-lighter:#4dbf4d;--ifm-color-success-lightest:#80d280;--ifm-color-success-contrast-background:#e6f6e6;--ifm-color-success-contrast-foreground:#003100;--ifm-color-info-dark:#4cb3d4;--ifm-color-info-darker:#47a9c9;--ifm-color-info-darkest:#3b8ba5;--ifm-color-info-light:#6ecfef;--ifm-color-info-lighter:#87d8f2;--ifm-color-info-lightest:#aae3f6;--ifm-color-info-contrast-background:#eef9fd;--ifm-color-info-contrast-foreground:#193c47;--ifm-color-warning-dark:#e6a700;--ifm-color-warning-darker:#d99e00;--ifm-color-warning-darkest:#b38200;--ifm-color-warning-light:#ffc426;--ifm-color-warning-lighter:#ffcf4d;--ifm-color-warning-lightest:#ffdd80;--ifm-color-warning-contrast-background:#fff8e6;--ifm-color-warning-contrast-foreground:#4d3800;--ifm-color-danger-dark:#e13238;--ifm-color-danger-darker:#d53035;--ifm-color-danger-darkest:#af272b;--ifm-color-danger-light:#fb565b;--ifm-color-danger-lighter:#fb7478;--ifm-color-danger-lightest:#fd9c9f;--ifm-color-danger-contrast-background:#ffebec;--ifm-color-danger-contrast-foreground:#4b1113;--ifm-color-white:#fff;--ifm-color-black:#000;--ifm-color-gray-0:var(--ifm-color-white);--ifm-color-gray-100:#f5f6f7;--ifm-color-gray-200:#ebedf0;--ifm-color-gray-300:#dadde1;--ifm-color-gray-400:#ccd0d5;--ifm-color-gray-500:#bec3c9;--ifm-color-gray-600:#8d949e;--ifm-color-gray-700:#606770;--ifm-color-gray-800:#444950;--ifm-color-gray-900:#1c1e21;--ifm-color-gray-1000:var(--ifm-color-black);--ifm-color-emphasis-0:var(--ifm-color-gray-0);--ifm-color-emphasis-100:var(--ifm-color-gray-100);--ifm-color-emphasis-200:var(--ifm-color-gray-200);--ifm-color-emphasis-300:var(--ifm-color-gray-300);--ifm-color-emphasis-400:var(--ifm-color-gray-400);--ifm-color-emphasis-600:var(--ifm-color-gray-600);--ifm-color-emphasis-700:var(--ifm-color-gray-700);--ifm-color-emphasis-800:var(--ifm-color-gray-800);--ifm-color-emphasis-900:var(--ifm-color-gray-900);--ifm-color-emphasis-1000:var(--ifm-color-gray-1000);--ifm-color-content:var(--ifm-color-emphasis-900);--ifm-color-content-inverse:var(--ifm-color-emphasis-0);--ifm-color-content-secondary:#525860;--ifm-background-color:#0000;--ifm-background-surface-color:var(--ifm-color-content-inverse);--ifm-global-border-width:1px;--ifm-global-radius:0.4rem;--ifm-hover-overlay:#0000000d;--ifm-font-color-base:var(--ifm-color-content);--ifm-font-color-base-inverse:var(--ifm-color-content-inverse);--ifm-font-color-secondary:var(--ifm-color-content-secondary);--ifm-font-family-base:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";--ifm-font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ifm-font-size-base:100%;--ifm-font-weight-light:300;--ifm-font-weight-normal:400;--ifm-font-weight-semibold:500;--ifm-font-weight-bold:700;--ifm-font-weight-base:var(--ifm-font-weight-normal);--ifm-line-height-base:1.65;--ifm-global-spacing:1rem;--ifm-spacing-vertical:var(--ifm-global-spacing);--ifm-spacing-horizontal:var(--ifm-global-spacing);--ifm-transition-fast:200ms;--ifm-transition-slow:400ms;--ifm-transition-timing-default:cubic-bezier(0.08,0.52,0.52,1);--ifm-global-shadow-lw:0 1px 2px 0 #0000001a;--ifm-global-shadow-md:0 5px 40px #0003;--ifm-global-shadow-tl:0 12px 28px 0 #0003,0 2px 4px 0 #0000001a;--ifm-z-index-dropdown:100;--ifm-z-index-fixed:200;--ifm-z-index-overlay:400;--ifm-container-width:1140px;--ifm-container-width-xl:1320px;--ifm-code-background:#f6f7f8;--ifm-code-border-radius:var(--ifm-global-radius);--ifm-code-font-size:90%;--ifm-code-padding-horizontal:0.1rem;--ifm-code-padding-vertical:0.1rem;--ifm-pre-background:var(--ifm-code-background);--ifm-pre-border-radius:var(--ifm-code-border-radius);--ifm-pre-color:inherit;--ifm-pre-line-height:1.45;--ifm-pre-padding:1rem;--ifm-heading-color:inherit;--ifm-heading-margin-top:0;--ifm-heading-margin-bottom:var(--ifm-spacing-vertical);--ifm-heading-font-family:var(--ifm-font-family-base);--ifm-heading-font-weight:var(--ifm-font-weight-bold);--ifm-heading-line-height:1.25;--ifm-h1-font-size:2rem;--ifm-h2-font-size:1.5rem;--ifm-h3-font-size:1.25rem;--ifm-h4-font-size:1rem;--ifm-h5-font-size:0.875rem;--ifm-h6-font-size:0.85rem;--ifm-image-alignment-padding:1.25rem;--ifm-leading-desktop:1.25;--ifm-leading:calc(var(--ifm-leading-desktop)*1rem);--ifm-list-left-padding:2rem;--ifm-list-margin:1rem;--ifm-list-item-margin:0.25rem;--ifm-list-paragraph-margin:1rem;--ifm-table-cell-padding:0.75rem;--ifm-table-background:#0000;--ifm-table-stripe-background:#00000008;--ifm-table-border-width:1px;--ifm-table-border-color:var(--ifm-color-emphasis-300);--ifm-table-head-background:inherit;--ifm-table-head-color:inherit;--ifm-table-head-font-weight:var(--ifm-font-weight-bold);--ifm-table-cell-color:inherit;--ifm-link-color:var(--ifm-color-primary);--ifm-link-decoration:none;--ifm-link-hover-color:var(--ifm-link-color);--ifm-link-hover-decoration:underline;--ifm-paragraph-margin-bottom:var(--ifm-leading);--ifm-blockquote-font-size:var(--ifm-font-size-base);--ifm-blockquote-border-left-width:2px;--ifm-blockquote-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-blockquote-padding-vertical:0;--ifm-blockquote-shadow:none;--ifm-blockquote-color:var(--ifm-color-emphasis-800);--ifm-blockquote-border-color:var(--ifm-color-emphasis-300);--ifm-hr-background-color:var(--ifm-color-emphasis-500);--ifm-hr-height:1px;--ifm-hr-margin-vertical:1.5rem;--ifm-scrollbar-size:7px;--ifm-scrollbar-track-background-color:#f1f1f1;--ifm-scrollbar-thumb-background-color:silver;--ifm-scrollbar-thumb-hover-background-color:#a7a7a7;--ifm-alert-background-color:inherit;--ifm-alert-border-color:inherit;--ifm-alert-border-radius:var(--ifm-global-radius);--ifm-alert-border-width:0px;--ifm-alert-border-left-width:5px;--ifm-alert-color:var(--ifm-font-color-base);--ifm-alert-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-alert-padding-vertical:var(--ifm-spacing-vertical);--ifm-alert-shadow:var(--ifm-global-shadow-lw);--ifm-avatar-intro-margin:1rem;--ifm-avatar-intro-alignment:inherit;--ifm-avatar-photo-size:3rem;--ifm-badge-background-color:inherit;--ifm-badge-border-color:inherit;--ifm-badge-border-radius:var(--ifm-global-radius);--ifm-badge-border-width:var(--ifm-global-border-width);--ifm-badge-color:var(--ifm-color-white);--ifm-badge-padding-horizontal:calc(var(--ifm-spacing-horizontal)*0.5);--ifm-badge-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-breadcrumb-border-radius:1.5rem;--ifm-breadcrumb-spacing:0.5rem;--ifm-breadcrumb-color-active:var(--ifm-color-primary);--ifm-breadcrumb-item-background-active:var(--ifm-hover-overlay);--ifm-breadcrumb-padding-horizontal:0.8rem;--ifm-breadcrumb-padding-vertical:0.4rem;--ifm-breadcrumb-size-multiplier:1;--ifm-breadcrumb-separator:url('data:image/svg+xml;utf8,');--ifm-breadcrumb-separator-filter:none;--ifm-breadcrumb-separator-size:0.5rem;--ifm-breadcrumb-separator-size-multiplier:1.25;--ifm-button-background-color:inherit;--ifm-button-border-color:var(--ifm-button-background-color);--ifm-button-border-width:var(--ifm-global-border-width);--ifm-button-font-weight:var(--ifm-font-weight-bold);--ifm-button-padding-horizontal:1.5rem;--ifm-button-padding-vertical:0.375rem;--ifm-button-size-multiplier:1;--ifm-button-transition-duration:var(--ifm-transition-fast);--ifm-button-border-radius:calc(var(--ifm-global-radius)*var(--ifm-button-size-multiplier));--ifm-button-group-spacing:2px;--ifm-card-background-color:var(--ifm-background-surface-color);--ifm-card-border-radius:calc(var(--ifm-global-radius)*2);--ifm-card-horizontal-spacing:var(--ifm-global-spacing);--ifm-card-vertical-spacing:var(--ifm-global-spacing);--ifm-toc-border-color:var(--ifm-color-emphasis-300);--ifm-toc-link-color:var(--ifm-color-content-secondary);--ifm-toc-padding-vertical:0.5rem;--ifm-toc-padding-horizontal:0.5rem;--ifm-dropdown-background-color:var(--ifm-background-surface-color);--ifm-dropdown-font-weight:var(--ifm-font-weight-semibold);--ifm-dropdown-link-color:var(--ifm-font-color-base);--ifm-dropdown-hover-background-color:var(--ifm-hover-overlay);--ifm-footer-background-color:var(--ifm-color-emphasis-100);--ifm-footer-color:inherit;--ifm-footer-link-color:var(--ifm-color-emphasis-700);--ifm-footer-link-hover-color:var(--ifm-color-primary);--ifm-footer-link-horizontal-spacing:0.5rem;--ifm-footer-padding-horizontal:calc(var(--ifm-spacing-horizontal)*2);--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*2);--ifm-footer-title-color:inherit;--ifm-footer-logo-max-width:min(30rem,90vw);--ifm-hero-background-color:var(--ifm-background-surface-color);--ifm-hero-text-color:var(--ifm-color-emphasis-800);--ifm-menu-color:var(--ifm-color-emphasis-700);--ifm-menu-color-active:var(--ifm-color-primary);--ifm-menu-color-background-active:var(--ifm-hover-overlay);--ifm-menu-color-background-hover:var(--ifm-hover-overlay);--ifm-menu-link-padding-horizontal:0.75rem;--ifm-menu-link-padding-vertical:0.375rem;--ifm-menu-link-sublist-icon:url('data:image/svg+xml;utf8,');--ifm-menu-link-sublist-icon-filter:none;--ifm-navbar-background-color:var(--ifm-background-surface-color);--ifm-navbar-height:3.75rem;--ifm-navbar-item-padding-horizontal:0.75rem;--ifm-navbar-item-padding-vertical:0.25rem;--ifm-navbar-link-color:var(--ifm-font-color-base);--ifm-navbar-link-active-color:var(--ifm-link-color);--ifm-navbar-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-navbar-padding-vertical:calc(var(--ifm-spacing-vertical)*0.5);--ifm-navbar-shadow:var(--ifm-global-shadow-lw);--ifm-navbar-search-input-background-color:var(--ifm-color-emphasis-200);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-800);--ifm-navbar-search-input-placeholder-color:var(--ifm-color-emphasis-500);--ifm-navbar-search-input-icon:url('data:image/svg+xml;utf8,');--ifm-navbar-sidebar-width:83vw;--ifm-pagination-border-radius:var(--ifm-global-radius);--ifm-pagination-color-active:var(--ifm-color-primary);--ifm-pagination-font-size:1rem;--ifm-pagination-item-active-background:var(--ifm-hover-overlay);--ifm-pagination-page-spacing:0.2em;--ifm-pagination-padding-horizontal:calc(var(--ifm-spacing-horizontal)*1);--ifm-pagination-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-pagination-nav-border-radius:var(--ifm-global-radius);--ifm-pagination-nav-color-hover:var(--ifm-color-primary);--ifm-pills-color-active:var(--ifm-color-primary);--ifm-pills-color-background-active:var(--ifm-hover-overlay);--ifm-pills-spacing:0.125rem;--ifm-tabs-color:var(--ifm-font-color-secondary);--ifm-tabs-color-active:var(--ifm-color-primary);--ifm-tabs-color-active-border:var(--ifm-tabs-color-active);--ifm-tabs-padding-horizontal:1rem;--ifm-tabs-padding-vertical:1rem;--docusaurus-progress-bar-color:var(--ifm-color-primary);--ifm-color-primary:#25c2a0;--ifm-color-primary-dark:#21af90;--ifm-color-primary-darker:#1fa588;--ifm-color-primary-darkest:#1a8870;--ifm-color-primary-light:#46cbae;--ifm-color-primary-lighter:#66d4bd;--ifm-color-primary-lightest:#92e0d0;--ifm-font-size-base:1.1rem;--ifm-code-font-size:86%;--ifm-pre-line-height:var(--ifm-line-height-base);--doc-sidebar-width:14rem!important;--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*1.4);--docusaurus-tag-list-border:var(--ifm-color-emphasis-300);--docsearch-primary-color:#5468ff;--docsearch-text-color:#1c1e21;--docsearch-spacing:12px;--docsearch-icon-stroke-width:1.4;--docsearch-highlight-color:var(--docsearch-primary-color);--docsearch-muted-color:#969faf;--docsearch-container-background:#656c85cc;--docsearch-logo-color:#5468ff;--docsearch-modal-width:560px;--docsearch-modal-height:600px;--docsearch-modal-background:#f5f6f7;--docsearch-modal-shadow:inset 1px 1px 0 0 #ffffff80,0 3px 8px 0 #555a64;--docsearch-searchbox-height:56px;--docsearch-searchbox-background:#ebedf0;--docsearch-searchbox-focus-background:#fff;--docsearch-searchbox-shadow:inset 0 0 0 2px var(--docsearch-primary-color);--docsearch-hit-height:56px;--docsearch-hit-color:#444950;--docsearch-hit-active-color:#fff;--docsearch-hit-background:#fff;--docsearch-hit-shadow:0 1px 3px 0 #d4d9e1;--docsearch-key-gradient:linear-gradient(-225deg,#d5dbe4,#f8f8f8);--docsearch-key-shadow:inset 0 -2px 0 0 #cdcde6,inset 0 0 1px 1px #fff,0 1px 2px 1px #1e235a66;--docsearch-key-pressed-shadow:inset 0 -2px 0 0 #cdcde6,inset 0 0 1px 1px #fff,0 1px 1px 0 #1e235a66;--docsearch-footer-height:44px;--docsearch-footer-background:#fff;--docsearch-footer-shadow:0 -1px 0 0 #e0e3e8,0 -3px 6px 0 #45629b1f;--docsearch-primary-color:var(--ifm-color-primary);--docsearch-text-color:var(--ifm-font-color-base);--docusaurus-announcement-bar-height:auto;--docusaurus-collapse-button-bg:#0000;--docusaurus-collapse-button-bg-hover:#0000001a;--doc-sidebar-width:300px;--doc-sidebar-hidden-width:30px}.badge--danger,.badge--info,.badge--primary,.badge--secondary,.badge--success,.badge--warning{--ifm-badge-border-color:var(--ifm-badge-background-color)}.button--link,.button--outline{--ifm-button-background-color:#0000}html{background-color:var(--ifm-background-color);color:var(--ifm-font-color-base);color-scheme:var(--ifm-color-scheme);font:var(--ifm-font-size-base)/var(--ifm-line-height-base) var(--ifm-font-family-base);-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;-webkit-text-size-adjust:100%;text-size-adjust:100%}iframe{border:0;color-scheme:auto}.container{margin:0 auto;max-width:var(--ifm-container-width)}.container--fluid{max-width:inherit}.row{display:flex;flex-wrap:wrap;margin:0 calc(var(--ifm-spacing-horizontal)*-1)}.margin-bottom--none,.margin-vert--none,.markdown>:last-child{margin-bottom:0!important}.margin-top--none,.margin-vert--none,.tabItem_LNqP{margin-top:0!important}.row--no-gutters{margin-left:0;margin-right:0}.margin-horiz--none,.margin-right--none{margin-right:0!important}.row--no-gutters>.col{padding-left:0;padding-right:0}.row--align-top{align-items:flex-start}.row--align-bottom{align-items:flex-end}.menuExternalLink_NmtK,.row--align-center{align-items:center}.row--align-stretch{align-items:stretch}.row--align-baseline{align-items:baseline}.col{--ifm-col-width:100%;flex:1 0;margin-left:0;max-width:var(--ifm-col-width)}.padding-bottom--none,.padding-vert--none{padding-bottom:0!important}.padding-top--none,.padding-vert--none{padding-top:0!important}.padding-horiz--none,.padding-left--none{padding-left:0!important}.padding-horiz--none,.padding-right--none{padding-right:0!important}.col[class*=col--]{flex:0 0 var(--ifm-col-width)}.col--1{--ifm-col-width:8.33333%}.col--offset-1{margin-left:8.33333%}.col--2{--ifm-col-width:16.66667%}.col--offset-2{margin-left:16.66667%}.col--3{--ifm-col-width:25%}.col--offset-3{margin-left:25%}.col--4{--ifm-col-width:33.33333%}.col--offset-4{margin-left:33.33333%}.col--5{--ifm-col-width:41.66667%}.col--offset-5{margin-left:41.66667%}.col--6{--ifm-col-width:50%}.col--offset-6{margin-left:50%}.col--7{--ifm-col-width:58.33333%}.col--offset-7{margin-left:58.33333%}.col--8{--ifm-col-width:66.66667%}.col--offset-8{margin-left:66.66667%}.col--9{--ifm-col-width:75%}.col--offset-9{margin-left:75%}.col--10{--ifm-col-width:83.33333%}.col--offset-10{margin-left:83.33333%}.col--11{--ifm-col-width:91.66667%}.col--offset-11{margin-left:91.66667%}.col--12{--ifm-col-width:100%}.col--offset-12{margin-left:100%}.margin-horiz--none,.margin-left--none{margin-left:0!important}.margin--none{margin:0!important}.margin-bottom--xs,.margin-vert--xs{margin-bottom:.25rem!important}.margin-top--xs,.margin-vert--xs{margin-top:.25rem!important}.margin-horiz--xs,.margin-left--xs{margin-left:.25rem!important}.margin-horiz--xs,.margin-right--xs{margin-right:.25rem!important}.margin--xs{margin:.25rem!important}.margin-bottom--sm,.margin-vert--sm{margin-bottom:.5rem!important}.margin-top--sm,.margin-vert--sm{margin-top:.5rem!important}.margin-horiz--sm,.margin-left--sm{margin-left:.5rem!important}.margin-horiz--sm,.margin-right--sm{margin-right:.5rem!important}.margin--sm{margin:.5rem!important}.margin-bottom--md,.margin-vert--md{margin-bottom:1rem!important}.margin-top--md,.margin-vert--md{margin-top:1rem!important}.margin-horiz--md,.margin-left--md{margin-left:1rem!important}.margin-horiz--md,.margin-right--md{margin-right:1rem!important}.margin--md{margin:1rem!important}.margin-bottom--lg,.margin-vert--lg{margin-bottom:2rem!important}.margin-top--lg,.margin-vert--lg{margin-top:2rem!important}.margin-horiz--lg,.margin-left--lg{margin-left:2rem!important}.margin-horiz--lg,.margin-right--lg{margin-right:2rem!important}.margin--lg{margin:2rem!important}.margin-bottom--xl,.margin-vert--xl{margin-bottom:5rem!important}.margin-top--xl,.margin-vert--xl{margin-top:5rem!important}.margin-horiz--xl,.margin-left--xl{margin-left:5rem!important}.margin-horiz--xl,.margin-right--xl{margin-right:5rem!important}.margin--xl{margin:5rem!important}.padding--none{padding:0!important}.padding-bottom--xs,.padding-vert--xs{padding-bottom:.25rem!important}.padding-top--xs,.padding-vert--xs{padding-top:.25rem!important}.padding-horiz--xs,.padding-left--xs{padding-left:.25rem!important}.padding-horiz--xs,.padding-right--xs{padding-right:.25rem!important}.padding--xs{padding:.25rem!important}.padding-bottom--sm,.padding-vert--sm{padding-bottom:.5rem!important}.padding-top--sm,.padding-vert--sm{padding-top:.5rem!important}.padding-horiz--sm,.padding-left--sm{padding-left:.5rem!important}.padding-horiz--sm,.padding-right--sm{padding-right:.5rem!important}.padding--sm{padding:.5rem!important}.padding-bottom--md,.padding-vert--md{padding-bottom:1rem!important}.padding-top--md,.padding-vert--md{padding-top:1rem!important}.padding-horiz--md,.padding-left--md{padding-left:1rem!important}.padding-horiz--md,.padding-right--md{padding-right:1rem!important}.padding--md{padding:1rem!important}.padding-bottom--lg,.padding-vert--lg{padding-bottom:2rem!important}.padding-top--lg,.padding-vert--lg{padding-top:2rem!important}.padding-horiz--lg,.padding-left--lg{padding-left:2rem!important}.padding-horiz--lg,.padding-right--lg{padding-right:2rem!important}.padding--lg{padding:2rem!important}.padding-bottom--xl,.padding-vert--xl{padding-bottom:5rem!important}.padding-top--xl,.padding-vert--xl{padding-top:5rem!important}.padding-horiz--xl,.padding-left--xl{padding-left:5rem!important}.padding-horiz--xl,.padding-right--xl{padding-right:5rem!important}.padding--xl{padding:5rem!important}code{background-color:var(--ifm-code-background);border:.1rem solid #0000001a;border-radius:var(--ifm-code-border-radius);font-family:var(--ifm-font-family-monospace);font-size:var(--ifm-code-font-size);padding:var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal)}a code{color:inherit}pre{background-color:var(--ifm-pre-background);border-radius:var(--ifm-pre-border-radius);color:var(--ifm-pre-color);font:var(--ifm-code-font-size)/var(--ifm-pre-line-height) var(--ifm-font-family-monospace);padding:var(--ifm-pre-padding)}pre code{background-color:initial;border:none;line-height:inherit;padding:0}kbd{background-color:var(--ifm-color-emphasis-0);border:1px solid var(--ifm-color-emphasis-400);border-radius:.2rem;box-shadow:inset 0 -1px 0 var(--ifm-color-emphasis-400);color:var(--ifm-color-emphasis-800);font:80% var(--ifm-font-family-monospace);padding:.15rem .3rem}h1,h2,h3,h4,h5,h6{color:var(--ifm-heading-color);font-family:var(--ifm-heading-font-family);font-weight:var(--ifm-heading-font-weight);line-height:var(--ifm-heading-line-height);margin:var(--ifm-heading-margin-top) 0 var(--ifm-heading-margin-bottom) 0}h2{font-size:var(--ifm-h2-font-size)}h3{font-size:var(--ifm-h3-font-size)}h4{font-size:var(--ifm-h4-font-size)}h5{font-size:var(--ifm-h5-font-size)}h6{font-size:var(--ifm-h6-font-size)}img{max-width:100%}img[align=right]{padding-left:var(--image-alignment-padding)}img[align=left]{padding-right:var(--image-alignment-padding)}.markdown{--ifm-h1-vertical-rhythm-top:3;--ifm-h2-vertical-rhythm-top:2;--ifm-h3-vertical-rhythm-top:1.5;--ifm-heading-vertical-rhythm-top:1.25;--ifm-h1-vertical-rhythm-bottom:1.25;--ifm-heading-vertical-rhythm-bottom:1}.markdown:after,.markdown:before{content:"";display:table}.markdown:after{clear:both}.markdown h1:first-child{--ifm-h1-font-size:3rem;margin-bottom:calc(var(--ifm-h1-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown>h2{--ifm-h2-font-size:2rem;margin-top:calc(var(--ifm-h2-vertical-rhythm-top)*var(--ifm-leading));--ifm-h2-font-size:1.8rem}.markdown>h3{--ifm-h3-font-size:1.5rem;margin-top:calc(var(--ifm-h3-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h4,.markdown>h5,.markdown>h6{margin-top:calc(var(--ifm-heading-vertical-rhythm-top)*var(--ifm-leading))}.markdown>p,.markdown>pre,.markdown>ul,.tabList__CuJ{margin-bottom:var(--ifm-leading)}.markdown li>p{margin-top:var(--ifm-list-paragraph-margin)}.markdown li+li{margin-top:var(--ifm-list-item-margin)}ol,ul{margin:0 0 var(--ifm-list-margin);padding-left:var(--ifm-list-left-padding)}ol ol,ul ol{list-style-type:lower-roman}ol ol ol,ol ul ol,ul ol ol,ul ul ol{list-style-type:lower-alpha}table{border-collapse:collapse;display:block;margin-bottom:var(--ifm-spacing-vertical)}table thead tr{border-bottom:2px solid var(--ifm-table-border-color)}table thead,table tr:nth-child(2n){background-color:var(--ifm-table-stripe-background)}table tr{background-color:var(--ifm-table-background);border-top:var(--ifm-table-border-width) solid var(--ifm-table-border-color)}table td,table th{border:var(--ifm-table-border-width) solid var(--ifm-table-border-color);padding:var(--ifm-table-cell-padding)}table th{background-color:var(--ifm-table-head-background);color:var(--ifm-table-head-color);font-weight:var(--ifm-table-head-font-weight)}table td{color:var(--ifm-table-cell-color)}strong{font-weight:var(--ifm-font-weight-bold)}a{color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}a:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.button:hover,.text--no-decoration,.text--no-decoration:hover,a:not([href]){-webkit-text-decoration:none;text-decoration:none}p{margin:0 0 var(--ifm-paragraph-margin-bottom)}blockquote{border-left:var(--ifm-blockquote-border-left-width) solid var(--ifm-blockquote-border-color);box-shadow:var(--ifm-blockquote-shadow);color:var(--ifm-blockquote-color);font-size:var(--ifm-blockquote-font-size);padding:var(--ifm-blockquote-padding-vertical) var(--ifm-blockquote-padding-horizontal)}blockquote>:first-child{margin-top:0}blockquote>:last-child{margin-bottom:0}hr{background-color:var(--ifm-hr-background-color);border:0;height:var(--ifm-hr-height);margin:var(--ifm-hr-margin-vertical) 0}.shadow--lw{box-shadow:var(--ifm-global-shadow-lw)!important}.shadow--md{box-shadow:var(--ifm-global-shadow-md)!important}.shadow--tl{box-shadow:var(--ifm-global-shadow-tl)!important}.text--primary,.wordWrapButtonEnabled_EoeP .wordWrapButtonIcon_Bwma{color:var(--ifm-color-primary)}.text--secondary{color:var(--ifm-color-secondary)}.text--success{color:var(--ifm-color-success)}.text--info{color:var(--ifm-color-info)}.text--warning{color:var(--ifm-color-warning)}.text--danger{color:var(--ifm-color-danger)}.apitable-build-options td:nth-child(2),.text--center{text-align:center}.text--left{text-align:left}.text--justify{text-align:justify}#tinyorm-configuration .tinyorm-configuration-row,.text--right{text-align:right}.text--capitalize{text-transform:capitalize}.text--lowercase{text-transform:lowercase}.admonitionHeading_Gvgb,.alert__heading,.text--uppercase{text-transform:uppercase}.text--light{font-weight:var(--ifm-font-weight-light)}.text--normal{font-weight:var(--ifm-font-weight-normal)}.text--semibold{font-weight:var(--ifm-font-weight-semibold)}.text--bold{font-weight:var(--ifm-font-weight-bold)}.text--italic{font-style:italic}.text--truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text--break{word-wrap:break-word!important;word-break:break-word!important}.clean-btn{background:none;border:none;color:inherit;cursor:pointer;font-family:inherit;padding:0}.alert,.alert .close{color:var(--ifm-alert-foreground-color)}.clean-list{list-style:none;padding-left:0}.alert--primary{--ifm-alert-background-color:var(--ifm-color-primary-contrast-background);--ifm-alert-background-color-highlight:#3578e526;--ifm-alert-foreground-color:var(--ifm-color-primary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-primary-dark)}.alert--secondary{--ifm-alert-background-color:var(--ifm-color-secondary-contrast-background);--ifm-alert-background-color-highlight:#ebedf026;--ifm-alert-foreground-color:var(--ifm-color-secondary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-secondary-dark)}.alert--success{--ifm-alert-background-color:var(--ifm-color-success-contrast-background);--ifm-alert-background-color-highlight:#00a40026;--ifm-alert-foreground-color:var(--ifm-color-success-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-success-dark)}.alert--info{--ifm-alert-background-color:var(--ifm-color-info-contrast-background);--ifm-alert-background-color-highlight:#54c7ec26;--ifm-alert-foreground-color:var(--ifm-color-info-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-info-dark)}.alert--warning{--ifm-alert-background-color:var(--ifm-color-warning-contrast-background);--ifm-alert-background-color-highlight:#ffba0026;--ifm-alert-foreground-color:var(--ifm-color-warning-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-warning-dark)}.alert--danger{--ifm-alert-background-color:var(--ifm-color-danger-contrast-background);--ifm-alert-background-color-highlight:#fa383e26;--ifm-alert-foreground-color:var(--ifm-color-danger-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-danger-dark)}.alert{--ifm-code-background:var(--ifm-alert-background-color-highlight);--ifm-link-color:var(--ifm-alert-foreground-color);--ifm-link-hover-color:var(--ifm-alert-foreground-color);--ifm-link-decoration:underline;--ifm-tabs-color:var(--ifm-alert-foreground-color);--ifm-tabs-color-active:var(--ifm-alert-foreground-color);--ifm-tabs-color-active-border:var(--ifm-alert-border-color);background-color:var(--ifm-alert-background-color);border:var(--ifm-alert-border-width) solid var(--ifm-alert-border-color);border-left-width:var(--ifm-alert-border-left-width);border-radius:var(--ifm-alert-border-radius);box-shadow:var(--ifm-alert-shadow);padding:var(--ifm-alert-padding-vertical) var(--ifm-alert-padding-horizontal)}.alert__heading{align-items:center;display:flex;font:700 var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);margin-bottom:.5rem}.alert__icon{display:inline-flex;margin-right:.4em}.alert__icon svg{fill:var(--ifm-alert-foreground-color);stroke:var(--ifm-alert-foreground-color);stroke-width:0}.alert .close{margin:calc(var(--ifm-alert-padding-vertical)*-1) calc(var(--ifm-alert-padding-horizontal)*-1) 0 0;opacity:.75}.alert .close:focus,.alert .close:hover{opacity:1}.alert a{text-decoration-color:var(--ifm-alert-border-color)}.alert a:hover{text-decoration-thickness:2px}.avatar{column-gap:var(--ifm-avatar-intro-margin);display:flex}.avatar__photo{border-radius:50%;display:block;height:var(--ifm-avatar-photo-size);overflow:hidden;width:var(--ifm-avatar-photo-size)}.card--full-height,.navbar__logo img,body,html{height:100%}.avatar__photo--sm{--ifm-avatar-photo-size:2rem}.avatar__photo--lg{--ifm-avatar-photo-size:4rem}.avatar__photo--xl{--ifm-avatar-photo-size:6rem}.avatar__intro{display:flex;flex:1 1;flex-direction:column;justify-content:center;text-align:var(--ifm-avatar-intro-alignment)}.badge,.breadcrumbs__item,.breadcrumbs__link,.button,.dropdown>.navbar__link:after{display:inline-block}.avatar__name{font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base)}.badge,.markdown h1+ul li li li a:before{font-size:75%}.avatar__subtitle{margin-top:.25rem}.avatar--vertical{--ifm-avatar-intro-alignment:center;--ifm-avatar-intro-margin:0.5rem;align-items:center;flex-direction:column}.badge{background-color:var(--ifm-badge-background-color);border:var(--ifm-badge-border-width) solid var(--ifm-badge-border-color);border-radius:var(--ifm-badge-border-radius);color:var(--ifm-badge-color);font-weight:var(--ifm-font-weight-bold);line-height:1;padding:var(--ifm-badge-padding-vertical) var(--ifm-badge-padding-horizontal)}.badge--primary{--ifm-badge-background-color:var(--ifm-color-primary)}.badge--secondary{--ifm-badge-background-color:var(--ifm-color-secondary);color:var(--ifm-color-black)}.breadcrumbs__link,.button.button--secondary.button--outline:not(.button--active):not(:hover){color:var(--ifm-font-color-base)}.badge--success{--ifm-badge-background-color:var(--ifm-color-success)}.badge--info{--ifm-badge-background-color:var(--ifm-color-info)}.badge--warning{--ifm-badge-background-color:var(--ifm-color-warning)}.badge--danger{--ifm-badge-background-color:var(--ifm-color-danger)}.breadcrumbs{margin-bottom:0;padding-left:0}.breadcrumbs__item:not(:last-child):after{background:var(--ifm-breadcrumb-separator) center;content:" ";display:inline-block;filter:var(--ifm-breadcrumb-separator-filter);height:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier));margin:0 var(--ifm-breadcrumb-spacing);opacity:.5;width:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier))}.breadcrumbs__item--active .breadcrumbs__link{background:var(--ifm-breadcrumb-item-background-active);color:var(--ifm-breadcrumb-color-active)}.breadcrumbs__link{border-radius:var(--ifm-breadcrumb-border-radius);font-size:calc(1rem*var(--ifm-breadcrumb-size-multiplier));padding:calc(var(--ifm-breadcrumb-padding-vertical)*var(--ifm-breadcrumb-size-multiplier)) calc(var(--ifm-breadcrumb-padding-horizontal)*var(--ifm-breadcrumb-size-multiplier));transition-duration:var(--ifm-transition-fast);transition-property:background,color}.breadcrumbs__link:any-link:hover,.breadcrumbs__link:link:hover,.breadcrumbs__link:visited:hover,area[href].breadcrumbs__link:hover{background:var(--ifm-breadcrumb-item-background-active);-webkit-text-decoration:none;text-decoration:none}.breadcrumbs--sm{--ifm-breadcrumb-size-multiplier:0.8}.breadcrumbs--lg{--ifm-breadcrumb-size-multiplier:1.2}.button{background-color:var(--ifm-button-background-color);border:var(--ifm-button-border-width) solid var(--ifm-button-border-color);border-radius:var(--ifm-button-border-radius);cursor:pointer;font-size:calc(.875rem*var(--ifm-button-size-multiplier));font-weight:var(--ifm-button-font-weight);line-height:1.5;padding:calc(var(--ifm-button-padding-vertical)*var(--ifm-button-size-multiplier)) calc(var(--ifm-button-padding-horizontal)*var(--ifm-button-size-multiplier));text-align:center;transition-duration:var(--ifm-button-transition-duration);transition-property:color,background,border-color;-webkit-user-select:none;user-select:none;white-space:nowrap}#apitable-c-macros td:first-child,.apitable-build-environment-variables td:nth-child(-n+2),.apitable-build-options td:nth-child(-n+2),.dropdown{vertical-align:top}.button,.button:hover{color:var(--ifm-button-color)}#casts-types-list li>code,#supported-compilers>h4>code,.button--link,.collection-methods>h4>code,.tom-column-types>h4>code{color:var(--ifm-link-color)}.button--outline{--ifm-button-color:var(--ifm-button-border-color)}.button--outline:hover{--ifm-button-background-color:var(--ifm-button-border-color)}.button--link{--ifm-button-border-color:#0000;text-decoration:var(--ifm-link-decoration)}.button--link.button--active,.button--link:active,.button--link:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.DocSearch-Container a,.dropdown__link--active,.dropdown__link:hover,.hash-link:active,.hash-link:hover,.menu__link:hover,.navbar__brand:hover,.navbar__link--active,.navbar__link:hover,.pagination-nav__link:hover,.pagination__link:hover,.tag_zVej:hover{-webkit-text-decoration:none;text-decoration:none}.button.disabled,.button:disabled,.button[disabled]{opacity:.65;pointer-events:none}.button--sm{--ifm-button-size-multiplier:0.8}.button--lg{--ifm-button-size-multiplier:1.35}.button--block{display:block;width:100%}.button.button--secondary{color:var(--ifm-color-gray-900)}:where(.button--primary){--ifm-button-background-color:var(--ifm-color-primary);--ifm-button-border-color:var(--ifm-color-primary)}:where(.button--primary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-primary-dark);--ifm-button-border-color:var(--ifm-color-primary-dark)}.button--primary.button--active,.button--primary:active{--ifm-button-background-color:var(--ifm-color-primary-darker);--ifm-button-border-color:var(--ifm-color-primary-darker)}:where(.button--secondary){--ifm-button-background-color:var(--ifm-color-secondary);--ifm-button-border-color:var(--ifm-color-secondary)}:where(.button--secondary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-secondary-dark);--ifm-button-border-color:var(--ifm-color-secondary-dark)}.button--secondary.button--active,.button--secondary:active{--ifm-button-background-color:var(--ifm-color-secondary-darker);--ifm-button-border-color:var(--ifm-color-secondary-darker)}:where(.button--success){--ifm-button-background-color:var(--ifm-color-success);--ifm-button-border-color:var(--ifm-color-success)}:where(.button--success):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-success-dark);--ifm-button-border-color:var(--ifm-color-success-dark)}.button--success.button--active,.button--success:active{--ifm-button-background-color:var(--ifm-color-success-darker);--ifm-button-border-color:var(--ifm-color-success-darker)}:where(.button--info){--ifm-button-background-color:var(--ifm-color-info);--ifm-button-border-color:var(--ifm-color-info)}:where(.button--info):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-info-dark);--ifm-button-border-color:var(--ifm-color-info-dark)}.button--info.button--active,.button--info:active{--ifm-button-background-color:var(--ifm-color-info-darker);--ifm-button-border-color:var(--ifm-color-info-darker)}:where(.button--warning){--ifm-button-background-color:var(--ifm-color-warning);--ifm-button-border-color:var(--ifm-color-warning)}:where(.button--warning):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-warning-dark);--ifm-button-border-color:var(--ifm-color-warning-dark)}.button--warning.button--active,.button--warning:active{--ifm-button-background-color:var(--ifm-color-warning-darker);--ifm-button-border-color:var(--ifm-color-warning-darker)}:where(.button--danger){--ifm-button-background-color:var(--ifm-color-danger);--ifm-button-border-color:var(--ifm-color-danger)}:where(.button--danger):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-danger-dark);--ifm-button-border-color:var(--ifm-color-danger-dark)}.button--danger.button--active,.button--danger:active{--ifm-button-background-color:var(--ifm-color-danger-darker);--ifm-button-border-color:var(--ifm-color-danger-darker)}.button-group{display:inline-flex;gap:var(--ifm-button-group-spacing)}.button-group>.button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.button-group>.button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.button-group--block{display:flex;justify-content:stretch}.button-group--block>.button{flex-grow:1}.card{background-color:var(--ifm-card-background-color);border-radius:var(--ifm-card-border-radius);box-shadow:var(--ifm-global-shadow-lw);display:flex;flex-direction:column;overflow:hidden}.card__image{padding-top:var(--ifm-card-vertical-spacing)}.card__image:first-child{padding-top:0}.card__body,.card__footer,.card__header{padding:var(--ifm-card-vertical-spacing) var(--ifm-card-horizontal-spacing)}.card__body:not(:last-child),.card__footer:not(:last-child),.card__header:not(:last-child){padding-bottom:0}.card__body>:last-child,.card__footer>:last-child,.card__header>:last-child{margin-bottom:0}.card__footer{margin-top:auto}#databases-supported-versions ul ul,.dropdown__link{margin-top:.2rem}.table-of-contents{margin-bottom:0;padding:var(--ifm-toc-padding-vertical) 0}.table-of-contents,.table-of-contents ul{list-style:none;padding-left:var(--ifm-toc-padding-horizontal)}.table-of-contents li{margin:var(--ifm-toc-padding-vertical) var(--ifm-toc-padding-horizontal)}.table-of-contents__left-border{border-left:1px solid var(--ifm-toc-border-color)}.table-of-contents__link{color:var(--ifm-toc-link-color);display:block}.table-of-contents__link--active,.table-of-contents__link--active code,.table-of-contents__link:hover,.table-of-contents__link:hover code{color:var(--ifm-color-primary);-webkit-text-decoration:none;text-decoration:none}.close{color:var(--ifm-color-black);float:right;font-size:1.5rem;font-weight:var(--ifm-font-weight-bold);line-height:1;opacity:.5;padding:1rem;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.close:hover{opacity:.7}.close:focus,.theme-code-block-highlighted-line .codeLineNumber_Tfdd:before{opacity:.8}.dropdown{display:inline-flex;font-weight:var(--ifm-dropdown-font-weight);position:relative}.dropdown--hoverable:hover .dropdown__menu,.dropdown--show .dropdown__menu{opacity:1;pointer-events:all;transform:translateY(-1px);visibility:visible}#nprogress,.dropdown__menu,.navbar__item.dropdown .navbar__link:not([href]){pointer-events:none}.dropdown--right .dropdown__menu{left:inherit;right:0}.dropdown--nocaret .navbar__link:after{content:none!important}.dropdown__menu{background-color:var(--ifm-dropdown-background-color);border-radius:var(--ifm-global-radius);box-shadow:var(--ifm-global-shadow-md);left:0;list-style:none;max-height:80vh;min-width:10rem;opacity:0;overflow-y:auto;padding:.5rem;position:absolute;top:calc(100% - var(--ifm-navbar-item-padding-vertical) + .3rem);transform:translateY(-.625rem);transition-duration:var(--ifm-transition-fast);transition-property:opacity,transform,visibility;transition-timing-function:var(--ifm-transition-timing-default);visibility:hidden;z-index:var(--ifm-z-index-dropdown)}.menu__caret,.menu__link,.menu__list-item-collapsible{border-radius:.25rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.dropdown__link{border-radius:.25rem;color:var(--ifm-dropdown-link-color);display:block;font-size:.875rem;padding:.25rem .5rem;white-space:nowrap}.dropdown__link--active,.dropdown__link:hover{background-color:var(--ifm-dropdown-hover-background-color);color:var(--ifm-dropdown-link-color)}.dropdown__link--active,.dropdown__link--active:hover{--ifm-dropdown-link-color:var(--ifm-link-color)}.dropdown>.navbar__link:after{border-color:currentcolor #0000;border-style:solid;border-width:.4em .4em 0;content:"";margin-left:.3em;position:relative;top:2px;transform:translateY(-50%)}.footer{background-color:var(--ifm-footer-background-color);color:var(--ifm-footer-color);padding:var(--ifm-footer-padding-vertical) var(--ifm-footer-padding-horizontal)}.footer--dark{--ifm-footer-background-color:#303846;--ifm-footer-color:var(--ifm-footer-link-color);--ifm-footer-link-color:var(--ifm-color-secondary);--ifm-footer-title-color:var(--ifm-color-white)}.footer__links{margin-bottom:1rem}.footer__link-item{color:var(--ifm-footer-link-color);line-height:2}.footer__link-item:hover{color:var(--ifm-footer-link-hover-color)}.footer__link-separator{margin:0 var(--ifm-footer-link-horizontal-spacing)}.footer__logo{margin-top:1rem;max-width:var(--ifm-footer-logo-max-width)}.footer__title{color:var(--ifm-footer-title-color);font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base);margin-bottom:var(--ifm-heading-margin-bottom)}.menu,.navbar__link{font-weight:var(--ifm-font-weight-semibold)}.docItemContainer_Djhp article>:first-child,.docItemContainer_Djhp header+*,.footer__item{margin-top:0}.admonitionContent_BuS1>:last-child,.api-stability p,.collapsibleContent_i85q p:last-child,.details_lb9f>summary>p:last-child,.footer__items,.markdown h1+ul li li:last-child ul,.tabItem_Ymn6>:last-child{margin-bottom:0}.codeBlockStandalone_MEMb,[type=checkbox]{padding:0}.hero{align-items:center;background-color:var(--ifm-hero-background-color);color:var(--ifm-hero-text-color);display:flex;padding:4rem 2rem}.hero--primary{--ifm-hero-background-color:var(--ifm-color-primary);--ifm-hero-text-color:var(--ifm-font-color-base-inverse)}.hero--dark{--ifm-hero-background-color:#303846;--ifm-hero-text-color:var(--ifm-color-white)}.hero__title{font-size:3rem}.hero__subtitle{font-size:1.5rem}.menu__list{list-style:none;margin:0;padding-left:0}.menu__caret,.menu__link{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu__list .menu__list{flex:0 0 100%;margin-top:.25rem;padding-left:var(--ifm-menu-link-padding-horizontal)}.menu__list-item:not(:first-child){margin-top:.25rem}.menu__list-item--collapsed .menu__list{height:0;overflow:hidden}.details_lb9f[data-collapsed=false].isBrowser_bmU9>summary:before,.details_lb9f[open]:not(.isBrowser_bmU9)>summary:before,.menu__list-item--collapsed .menu__caret:before,.menu__list-item--collapsed .menu__link--sublist:after{transform:rotate(90deg)}.menu__list-item-collapsible{display:flex;flex-wrap:wrap;position:relative}.menu__caret:hover,.menu__link:hover,.menu__list-item-collapsible--active,.menu__list-item-collapsible:hover{background:var(--ifm-menu-color-background-hover)}.menu__list-item-collapsible .menu__link--active,.menu__list-item-collapsible .menu__link:hover{background:none!important}.menu__caret,.menu__link{align-items:center;display:flex}.navbar-sidebar,.navbar-sidebar__backdrop{bottom:0;opacity:0;transition-duration:var(--ifm-transition-fast);transition-timing-function:ease-in-out;left:0;top:0;visibility:hidden}.menu__link{color:var(--ifm-menu-color);flex:1;line-height:1.25}.menu__link:hover{color:var(--ifm-menu-color)}.menu__caret:before,.menu__link--sublist-caret:after{height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast) linear;width:1.25rem;filter:var(--ifm-menu-link-sublist-icon-filter);content:""}.menu__link--sublist-caret:after{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem;margin-left:auto;min-width:1.25rem}.menu__link--active,.menu__link--active:hover{color:var(--ifm-menu-color-active)}.navbar__brand,.navbar__link{color:var(--ifm-navbar-link-color)}.menu__link--active:not(.menu__link--sublist){background-color:var(--ifm-menu-color-background-active)}.menu__caret:before{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem}.navbar--dark,html[data-theme=dark]{--ifm-menu-link-sublist-icon-filter:invert(100%) sepia(94%) saturate(17%) hue-rotate(223deg) brightness(104%) contrast(98%)}.navbar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-navbar-shadow);height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar,.navbar>.container,.navbar>.container-fluid{display:flex}.navbar--fixed-top{position:sticky;top:0;z-index:var(--ifm-z-index-fixed)}.navbar__inner{display:flex;flex-wrap:wrap;justify-content:space-between;width:100%}.navbar__brand{align-items:center;display:flex;margin-right:1rem;min-width:0}.navbar__brand:hover{color:var(--ifm-navbar-link-hover-color)}.announcementBarContent_xLdY,.navbar__title{flex:1 1 auto}.navbar__toggle{display:none;margin-right:.5rem}.navbar__logo{flex:0 0 auto;height:2rem;margin-right:.5rem}.navbar__items{align-items:center;display:flex;flex:1;min-width:0}.navbar__items--center{flex:0 0 auto}.navbar__items--center .navbar__brand{margin:0}.navbar__items--center+.navbar__items--right{flex:1}.navbar__items--right{flex:0 0 auto;justify-content:flex-end}.navbar__items--right>:last-child{padding-right:0}.navbar__item{display:inline-block;padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.navbar__link--active,.navbar__link:hover{color:var(--ifm-navbar-link-hover-color)}.navbar--dark,.navbar--primary{--ifm-menu-color:var(--ifm-color-gray-300);--ifm-navbar-link-color:var(--ifm-color-gray-100);--ifm-navbar-search-input-background-color:#ffffff1a;--ifm-navbar-search-input-placeholder-color:#ffffff80;color:var(--ifm-color-white)}.navbar--dark{--ifm-navbar-background-color:#242526;--ifm-menu-color-background-active:#ffffff0d;--ifm-navbar-search-input-color:var(--ifm-color-white)}.navbar--primary{--ifm-navbar-background-color:var(--ifm-color-primary);--ifm-navbar-link-hover-color:var(--ifm-color-white);--ifm-menu-color-active:var(--ifm-color-white);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-500)}.navbar__search-input{appearance:none;background:var(--ifm-navbar-search-input-background-color) var(--ifm-navbar-search-input-icon) no-repeat .75rem center/1rem 1rem;border:none;border-radius:2rem;color:var(--ifm-navbar-search-input-color);cursor:text;display:inline-block;font-size:.9rem;height:2rem;padding:0 .5rem 0 2.25rem;width:12.5rem}.navbar__search-input::placeholder{color:var(--ifm-navbar-search-input-placeholder-color)}.navbar-sidebar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-global-shadow-md);position:fixed;transform:translate3d(-100%,0,0);transition-property:opacity,visibility,transform;width:var(--ifm-navbar-sidebar-width)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar__items{transform:translateZ(0)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar--show .navbar-sidebar__backdrop{opacity:1;visibility:visible}.navbar-sidebar__backdrop{background-color:#0009;position:fixed;right:0;transition-property:opacity,visibility}.navbar-sidebar__brand{align-items:center;box-shadow:var(--ifm-navbar-shadow);display:flex;flex:1;height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar-sidebar__items{display:flex;height:calc(100% - var(--ifm-navbar-height));transition:transform var(--ifm-transition-fast) ease-in-out}.navbar-sidebar__items--show-secondary{transform:translate3d(calc((var(--ifm-navbar-sidebar-width))*-1),0,0)}.navbar-sidebar__item{flex-shrink:0;padding:.5rem;width:calc(var(--ifm-navbar-sidebar-width))}.navbar-sidebar__back{background:var(--ifm-menu-color-background-active);font-size:15px;font-weight:var(--ifm-button-font-weight);margin:0 0 .2rem -.5rem;padding:.6rem 1.5rem;position:relative;text-align:left;top:-.5rem;width:calc(100% + 1rem)}.navbar-sidebar__close{display:flex;margin-left:auto}.pagination{column-gap:var(--ifm-pagination-page-spacing);display:flex;font-size:var(--ifm-pagination-font-size);padding-left:0}.pagination--sm{--ifm-pagination-font-size:0.8rem;--ifm-pagination-padding-horizontal:0.8rem;--ifm-pagination-padding-vertical:0.2rem}.pagination--lg{--ifm-pagination-font-size:1.2rem;--ifm-pagination-padding-horizontal:1.2rem;--ifm-pagination-padding-vertical:0.3rem}.pagination__item{display:inline-flex}.pagination__item>span{padding:var(--ifm-pagination-padding-vertical)}.pagination__item--active .pagination__link{color:var(--ifm-pagination-color-active)}.hash-link:link,.hash-link:visited,.markdown h1+ul li a:before{color:var(--ifm-color-info-darker)}.pagination__item--active .pagination__link,.pagination__item:not(.pagination__item--active):hover .pagination__link{background:var(--ifm-pagination-item-active-background)}.pagination__item--disabled,.pagination__item[disabled]{opacity:.25;pointer-events:none}.pagination__link{border-radius:var(--ifm-pagination-border-radius);color:var(--ifm-font-color-base);display:inline-block;padding:var(--ifm-pagination-padding-vertical) var(--ifm-pagination-padding-horizontal);transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav{display:grid;grid-gap:var(--ifm-spacing-horizontal);gap:var(--ifm-spacing-horizontal);grid-template-columns:repeat(2,1fr)}.pagination-nav__link{border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-pagination-nav-border-radius);display:block;height:100%;line-height:var(--ifm-heading-line-height);padding:var(--ifm-global-spacing);transition:border-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav__link:hover{border-color:var(--ifm-pagination-nav-color-hover)}.pagination-nav__link--next{grid-column:2/3;text-align:right}.pagination-nav__label{font-size:var(--ifm-h4-font-size);font-weight:var(--ifm-heading-font-weight);word-break:break-word}.pagination-nav__link--prev .pagination-nav__label:before{content:"« "}.pagination-nav__link--next .pagination-nav__label:after{content:" »"}.pagination-nav__sublabel{color:var(--ifm-color-content-secondary);font-size:var(--ifm-h5-font-size);font-weight:var(--ifm-font-weight-semibold);margin-bottom:.25rem}.pills__item,.tabs{font-weight:var(--ifm-font-weight-bold)}.pills{display:flex;gap:var(--ifm-pills-spacing);padding-left:0}.pills__item{border-radius:.5rem;cursor:pointer;display:inline-block;padding:.25rem 1rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs,:not(.containsTaskList_mC6p>li)>.containsTaskList_mC6p{padding-left:0}.pills__item--active{color:var(--ifm-pills-color-active)}.pills__item--active,.pills__item:not(.pills__item--active):hover{background:var(--ifm-pills-color-background-active)}.pills--block{justify-content:stretch}.pills--block .pills__item{flex-grow:1;text-align:center}.tabs{color:var(--ifm-tabs-color);display:flex;margin-bottom:0;overflow-x:auto}.tabs__item{border-bottom:3px solid #0000;border-radius:var(--ifm-global-radius);cursor:pointer;display:inline-flex;padding:var(--ifm-tabs-padding-vertical) var(--ifm-tabs-padding-horizontal);transition:background-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs__item--active{border-bottom-color:var(--ifm-tabs-color-active-border);border-bottom-left-radius:0;border-bottom-right-radius:0;color:var(--ifm-tabs-color-active)}.tabs__item:hover{background-color:var(--ifm-hover-overlay)}.tabs--block{justify-content:stretch}.tabs--block .tabs__item{flex-grow:1;justify-content:center}html[data-theme=dark]{--ifm-color-scheme:dark;--ifm-color-emphasis-0:var(--ifm-color-gray-1000);--ifm-color-emphasis-100:var(--ifm-color-gray-900);--ifm-color-emphasis-200:var(--ifm-color-gray-800);--ifm-color-emphasis-300:var(--ifm-color-gray-700);--ifm-color-emphasis-400:var(--ifm-color-gray-600);--ifm-color-emphasis-600:var(--ifm-color-gray-400);--ifm-color-emphasis-700:var(--ifm-color-gray-300);--ifm-color-emphasis-800:var(--ifm-color-gray-200);--ifm-color-emphasis-900:var(--ifm-color-gray-100);--ifm-color-emphasis-1000:var(--ifm-color-gray-0);--ifm-background-color:#1b1b1d;--ifm-background-surface-color:#242526;--ifm-hover-overlay:#ffffff0d;--ifm-color-content:#e3e3e3;--ifm-color-content-secondary:#fff;--ifm-breadcrumb-separator-filter:invert(64%) sepia(11%) saturate(0%) hue-rotate(149deg) brightness(99%) contrast(95%);--ifm-code-background:#ffffff1a;--ifm-scrollbar-track-background-color:#444;--ifm-scrollbar-thumb-background-color:#686868;--ifm-scrollbar-thumb-hover-background-color:#7a7a7a;--ifm-table-stripe-background:#ffffff12;--ifm-toc-border-color:var(--ifm-color-emphasis-200);--ifm-color-primary-contrast-background:#102445;--ifm-color-primary-contrast-foreground:#ebf2fc;--ifm-color-secondary-contrast-background:#474748;--ifm-color-secondary-contrast-foreground:#fdfdfe;--ifm-color-success-contrast-background:#003100;--ifm-color-success-contrast-foreground:#e6f6e6;--ifm-color-info-contrast-background:#193c47;--ifm-color-info-contrast-foreground:#eef9fd;--ifm-color-warning-contrast-background:#4d3800;--ifm-color-warning-contrast-foreground:#fff8e6;--ifm-color-danger-contrast-background:#4b1113;--ifm-color-danger-contrast-foreground:#ffebec;--docsearch-text-color:#f5f6f7;--docsearch-container-background:#090a11cc;--docsearch-modal-background:#15172a;--docsearch-modal-shadow:inset 1px 1px 0 0 #2c2e40,0 3px 8px 0 #000309;--docsearch-searchbox-background:#090a11;--docsearch-searchbox-focus-background:#000;--docsearch-hit-color:#bec3c9;--docsearch-hit-shadow:none;--docsearch-hit-background:#090a11;--docsearch-key-gradient:linear-gradient(-26.5deg,#565872,#31355b);--docsearch-key-shadow:inset 0 -2px 0 0 #282d55,inset 0 0 1px 1px #51577d,0 2px 2px 0 #0304094d;--docsearch-key-pressed-shadow:inset 0 -2px 0 0 #282d55,inset 0 0 1px 1px #51577d,0 1px 1px 0 rgba(3,4,9,.302);--docsearch-footer-background:#1e2136;--docsearch-footer-shadow:inset 0 1px 0 0 #494c6a80,0 -4px 8px 0 #0003;--docsearch-logo-color:#fff;--docsearch-muted-color:#7f8497}#nprogress .bar{background:var(--docusaurus-progress-bar-color);height:2px;left:0;position:fixed;top:0;width:100%;z-index:1031}#nprogress .peg{box-shadow:0 0 10px var(--docusaurus-progress-bar-color),0 0 5px var(--docusaurus-progress-bar-color);height:100%;opacity:1;position:absolute;right:0;transform:rotate(3deg) translateY(-4px);width:100px}[data-theme=dark]:root{--ifm-background-color:#0d1117;--ifm-background-surface-color:#161b22;--ifm-toc-border-color:#30363d;--ifm-code-background:#ffffff26;--docusaurus-highlighted-code-line-bg:#30323f;--ifm-footer-background-color:var(--ifm-background-color);--docsearch-key-gradient:linear-gradient(-26.5deg,var(--ifm-color-emphasis-200) 0%,var(--ifm-color-emphasis-100) 100%);--docsearch-text-color:var(--ifm-color-emphasis-700);--docusaurus-collapse-button-bg:#ffffff0d;--docusaurus-collapse-button-bg-hover:#ffffff1a}.darker{color:#888}[data-theme=dark] ::-webkit-scrollbar{background-color:#222526;height:14px;width:14px}[data-theme=dark] ::-webkit-scrollbar-thumb{background-color:#555;border-radius:2px}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background-color:#777}[data-theme=dark] body{scrollbar-color:#777 #222526!important;scrollbar-width:14px}h1{--ifm-h1-font-size:2.1rem!important;font-size:var(--ifm-h1-font-size)}.header-github-link:before{background:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E") no-repeat;content:"";display:flex;height:24px;width:24px}[data-theme=dark] .header-github-link:before{background:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E") no-repeat}.menu__link{font-size:.9rem}.menu__list-item .menu__list-item{padding-left:1.3rem}.markdown h1+ul,.markdown h1+ul ul{list-style-type:none}.markdown h1+ul li a{font-weight:700}.markdown h1+ul li li a{font-weight:400}.markdown h1+ul li a:before{content:"# ";font-size:90%}.markdown h1+ul li li a:before{font-size:80%}.markdown h1+ul ul ul{margin-bottom:-.25rem;padding-left:1rem}#databases-supported-versions ul ul li a,.markdown h1+ul li li li a{font-size:95%}.footer{padding-bottom:.8rem;padding-top:.4rem}#databases-supported-versions ul ul li{font-size:90%;line-height:1.35}.docusaurus-highlight-code-line{background-color:#0000001a;display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}html[data-theme=dark] .docusaurus-highlight-code-line{background-color:#0000004d}html[data-theme=dark] .prism-code{background-color:#20222b!important}img.no-blurry{will-change:transform}.prism-code .token{font-style:inherit!important}.table-of-contents{font-size:.7rem}main>.container>.row>.col:last-child>div[class^=tableOfContents_]{transition:top .2s}nav[class*=navbarHidden_]~.main-wrapper main>.container>.row>.col:last-child>div[class^=tableOfContents_]{top:1rem}#apitable-dropping-indexes th:last-child{width:50%}#apitable-dropping-indexes td:first-child{font-size:90%;overflow-wrap:anywhere}#tinyorm-configuration,.tiny-tree{position:relative}.tiny-root-folder-info-wrapper{left:15px;position:absolute;top:13px;z-index:10}.tiny-root-folder-info-wrapper .tiny-root-folder-info-prefix{color:var(--ifm-color-warning-lighter)}html[data-theme=dark] .tiny-root-folder-info-wrapper .tiny-root-folder-info-prefix{color:var(--ifm-color-warning-lightest)}.api-stability{margin:0 0 1rem}.collection-methods-list>p,.tom-column-types-list>p{column-count:3;column-gap:2em}.collection-methods-list a,.tom-column-types-list a{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#supported-compilers>h4,.collection-methods>h4,.loader_vvXV,.tom-column-types>h4{margin-top:2rem}#supported-compilers{margin-bottom:2rem}#casts-types-list{font-size:92%}#tinyorm-configuration form{position:absolute;right:0;top:1em}#tinyorm-configuration label{color:#bbb;font-family:var(--ifm-font-family-base);font-size:.7rem;vertical-align:text-bottom}#tinyorm-configuration>div:last-child{display:none}.apiTable_flxF{font-size:94%}.apiTable_flxF tbody tr{transition:box-shadow .2s}.apiTable_flxF tbody tr:focus,.apiTable_flxF tbody tr:hover{box-shadow:0 0 4.5px 0 inset var(--ifm-color-warning);cursor:pointer;outline:0;transition:box-shadow .1s}.tag_zVej{border:1px solid var(--docusaurus-tag-list-border);transition:border var(--ifm-transition-fast)}.tag_zVej:hover{--docusaurus-tag-list-border:var(--ifm-link-color)}.tagRegular_sFm0{border-radius:var(--ifm-global-radius);font-size:90%;padding:.2rem .5rem .3rem}.tagWithCount_h2kH{align-items:center;border-left:0;display:flex;padding:0 .5rem 0 1rem;position:relative}.tagWithCount_h2kH:after,.tagWithCount_h2kH:before{border:1px solid var(--docusaurus-tag-list-border);content:"";position:absolute;top:50%;transition:inherit}.tagWithCount_h2kH:before{border-bottom:0;border-right:0;height:1.18rem;right:100%;transform:translate(50%,-50%) rotate(-45deg);width:1.18rem}.tagWithCount_h2kH:after{border-radius:50%;height:.5rem;left:0;transform:translateY(-50%);width:.5rem}.tagWithCount_h2kH span{background:var(--ifm-color-secondary);border-radius:var(--ifm-global-radius);color:var(--ifm-color-black);font-size:.7rem;line-height:1.2;margin-left:.3rem;padding:.1rem .4rem}.tags_jXut{display:inline}.tag_QGVx{display:inline-block;margin:0 .4rem .5rem 0}.iconEdit_Z9Sw{margin-right:.3em;vertical-align:sub}.lastUpdated_JAkA{font-size:smaller;font-style:italic;margin-top:.2rem}.tocCollapsibleButton_TO0P{align-items:center;display:flex;font-size:inherit;justify-content:space-between;padding:.4rem .8rem;width:100%}.DocSearch-Button,.DocSearch-Button-Container{align-items:center;display:flex}.tocCollapsibleButton_TO0P:after{background:var(--ifm-menu-link-sublist-icon) 50% 50%/2rem 2rem no-repeat;content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast);width:1.25rem}.tocCollapsibleButtonExpanded_MG3E:after,.tocCollapsibleExpanded_sAul{transform:none}.tocCollapsible_ETCw{background-color:var(--ifm-menu-color-background-active);border-radius:var(--ifm-global-radius);margin:1rem 0}.tocCollapsibleContent_vkbj>ul{border-left:none;border-top:1px solid var(--ifm-color-emphasis-300);font-size:15px;padding:.2rem 0}.tocCollapsibleContent_vkbj ul li{margin:.4rem .8rem}.tocCollapsibleContent_vkbj a{display:block}.tableOfContents_bqdL{max-height:calc(100vh - var(--ifm-navbar-height) - 2rem);overflow-y:auto;position:sticky;top:calc(var(--ifm-navbar-height) + 1rem)}.backToTopButton_sjWU{background-color:var(--ifm-color-emphasis-200);border-radius:50%;bottom:1.3rem;box-shadow:var(--ifm-global-shadow-lw);height:3rem;opacity:0;position:fixed;right:1.3rem;transform:scale(0);transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default);visibility:hidden;width:3rem;z-index:calc(var(--ifm-z-index-fixed) - 1)}.backToTopButton_sjWU:after{background-color:var(--ifm-color-emphasis-1000);content:" ";display:inline-block;height:100%;-webkit-mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;width:100%}.backToTopButtonShow_xfvO{opacity:1;transform:scale(1);visibility:visible}.DocSearch-Button{background:var(--docsearch-searchbox-background);border:0;border-radius:40px;color:var(--docsearch-muted-color);cursor:pointer;font-weight:500;height:36px;justify-content:space-between;padding:0 8px;-webkit-user-select:none;user-select:none}.DocSearch-Button:active,.DocSearch-Button:focus,.DocSearch-Button:hover{background:var(--docsearch-searchbox-focus-background);box-shadow:var(--docsearch-searchbox-shadow);color:var(--docsearch-text-color);outline:0}.DocSearch-Search-Icon{stroke-width:1.6}.DocSearch-Hit-Tree,.DocSearch-Hit-action,.DocSearch-Hit-icon,.DocSearch-Reset{stroke-width:var(--docsearch-icon-stroke-width)}.DocSearch-Button .DocSearch-Search-Icon{color:var(--docsearch-text-color)}.DocSearch-Button-Placeholder{font-size:1rem;padding:0 12px 0 6px}.DocSearch-Button-Keys{display:flex;min-width:calc(40px + .8em)}.DocSearch-Button-Key{align-items:center;background:var(--docsearch-key-gradient);border:0;border-radius:3px;box-shadow:var(--docsearch-key-shadow);color:var(--docsearch-muted-color);display:flex;height:18px;justify-content:center;margin-right:.4em;padding:0 0 2px;position:relative;top:-1px;width:20px}.DocSearch-Button-Key--pressed{box-shadow:var(--docsearch-key-pressed-shadow);transform:translate3d(0,1px,0)}.DocSearch--active{overflow:hidden!important}.DocSearch-Container{background-color:var(--docsearch-container-background);height:100vh;left:0;position:fixed;top:0;width:100vw;z-index:200}.DocSearch-Hit[aria-selected=true] mark,.DocSearch-Prefill:focus,.DocSearch-Prefill:hover,.content_knG7 a{-webkit-text-decoration:underline;text-decoration:underline}.DocSearch-Link{appearance:none;background:none;border:0;color:var(--docsearch-highlight-color);cursor:pointer;font:inherit;margin:0;padding:0}.DocSearch-Modal{background:var(--docsearch-modal-background);border-radius:6px;box-shadow:var(--docsearch-modal-shadow);flex-direction:column;margin:60px auto auto;max-width:var(--docsearch-modal-width);position:relative}.DocSearch-SearchBar{display:flex;padding:var(--docsearch-spacing) var(--docsearch-spacing) 0}.DocSearch-Form{align-items:center;background:var(--docsearch-searchbox-focus-background);border-radius:4px;box-shadow:var(--docsearch-searchbox-shadow);display:flex;height:var(--docsearch-searchbox-height);margin:0;padding:0 var(--docsearch-spacing);position:relative;width:100%}.DocSearch-Input{appearance:none;background:#0000;border:0;color:var(--docsearch-text-color);flex:1;font:inherit;font-size:1.2em;height:100%;outline:0;padding:0 0 0 8px;width:80%}.DocSearch-Input::placeholder{color:var(--docsearch-muted-color);opacity:1}.DocSearch-Input::-webkit-search-cancel-button,.DocSearch-Input::-webkit-search-decoration,.DocSearch-Input::-webkit-search-results-button,.DocSearch-Input::-webkit-search-results-decoration{display:none}.DocSearch-LoadingIndicator,.DocSearch-MagnifierLabel,.DocSearch-Reset{margin:0;padding:0}.DocSearch-Container--Stalled .DocSearch-LoadingIndicator,.DocSearch-MagnifierLabel,.DocSearch-Reset{align-items:center;color:var(--docsearch-highlight-color);display:flex;justify-content:center}.DocSearch-Cancel,.DocSearch-Container--Stalled .DocSearch-MagnifierLabel,.DocSearch-LoadingIndicator,.DocSearch-Reset[hidden]{display:none}.DocSearch-Reset{animation:.1s ease-in forwards a;appearance:none;background:none;border:0;border-radius:50%;color:var(--docsearch-icon-color);cursor:pointer;padding:2px;right:0}.DocSearch-Help,.DocSearch-HitsFooter,.DocSearch-Label{color:var(--docsearch-muted-color)}.DocSearch-Reset:hover{color:var(--docsearch-highlight-color)}.DocSearch-LoadingIndicator svg,.DocSearch-MagnifierLabel svg{height:24px;width:24px}.DocSearch-Dropdown{max-height:calc(var(--docsearch-modal-height) - var(--docsearch-searchbox-height) - var(--docsearch-spacing) - var(--docsearch-footer-height));min-height:var(--docsearch-spacing);overflow-y:auto;overflow-y:overlay;padding:0 var(--docsearch-spacing);scrollbar-color:var(--docsearch-muted-color) var(--docsearch-modal-background);scrollbar-width:thin}.DocSearch-Dropdown::-webkit-scrollbar{width:12px}.DocSearch-Dropdown::-webkit-scrollbar-track{background:#0000}.DocSearch-Dropdown::-webkit-scrollbar-thumb{background-color:var(--docsearch-muted-color);border:3px solid var(--docsearch-modal-background);border-radius:20px}.DocSearch-Dropdown ul{list-style:none;margin:0;padding:0}.DocSearch-Label{font-size:.75em;line-height:1.6em}.DocSearch-Help{font-size:.9em;margin:0;-webkit-user-select:none;user-select:none}.DocSearch-Title{font-size:1.2em}.DocSearch-Logo a{display:flex}.DocSearch-Logo svg{color:var(--docsearch-logo-color);margin-left:8px}.DocSearch-Hits:last-of-type{margin-bottom:24px}.DocSearch-Hits mark{background:none;color:var(--docsearch-highlight-color)}.DocSearch-HitsFooter{display:flex;font-size:.85em;justify-content:center;margin-bottom:var(--docsearch-spacing);padding:var(--docsearch-spacing)}.DocSearch-HitsFooter a{border-bottom:1px solid;color:inherit}.DocSearch-Hit{border-radius:4px;display:flex;padding-bottom:4px;position:relative}.DocSearch-Hit--deleting{opacity:0;transition:.25s linear}.DocSearch-Hit--favoriting{transform:scale(0);transform-origin:top center;transition:.25s linear .25s}.DocSearch-Hit a{background:var(--docsearch-hit-background);border-radius:4px;box-shadow:var(--docsearch-hit-shadow);display:block;padding-left:var(--docsearch-spacing);width:100%}.DocSearch-Hit-source{background:var(--docsearch-modal-background);color:var(--docsearch-highlight-color);font-size:.85em;font-weight:600;line-height:32px;margin:0 -4px;padding:8px 4px 0;position:sticky;top:0;z-index:10}.DocSearch-Hit-Tree{color:var(--docsearch-muted-color);height:var(--docsearch-hit-height);opacity:.5;width:24px}.DocSearch-Hit[aria-selected=true] a{background-color:var(--docsearch-highlight-color)}.DocSearch-Hit-Container{align-items:center;color:var(--docsearch-hit-color);display:flex;flex-direction:row;height:var(--docsearch-hit-height);padding:0 var(--docsearch-spacing) 0 0}.DocSearch-Hit-icon{height:20px;width:20px}.DocSearch-Hit-action,.DocSearch-Hit-icon{color:var(--docsearch-muted-color)}.DocSearch-Hit-action{align-items:center;display:flex;height:22px;width:22px}.DocSearch-Hit-action svg{display:block;height:18px;width:18px}.DocSearch-Hit-action+.DocSearch-Hit-action{margin-left:6px}.DocSearch-Hit-action-button{appearance:none;background:none;border:0;border-radius:50%;color:inherit;cursor:pointer;padding:2px}#__docusaurus-base-url-issue-banner-container,.docSidebarContainer_YfHR,.navbarSearchContainer_Bca1:empty,.sidebarLogo_isFc,.themedComponent_mlkZ,[data-theme=dark] .lightToggleIcon_pyhR,[data-theme=light] .darkToggleIcon_wfgR,html[data-announcement-bar-initially-dismissed=true] .announcementBar_mb4j,svg.DocSearch-Hit-Select-Icon{display:none}.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-Select-Icon{display:block}.DocSearch-Hit-action-button:focus,.DocSearch-Hit-action-button:hover{background:#0003;transition:background-color .1s ease-in}.DocSearch-Hit-action-button:focus path,.DocSearch-Hit-action-button:hover path{fill:#fff}.DocSearch-Hit-content-wrapper{display:flex;flex:1 1 auto;flex-direction:column;font-weight:500;justify-content:center;line-height:1.2em;margin:0 8px;overflow-x:hidden;position:relative;text-overflow:ellipsis;white-space:nowrap;width:80%}.DocSearch-Hit-title{font-size:.9em}.DocSearch-Hit-path{color:var(--docsearch-muted-color);font-size:.75em}.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-Tree,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-action,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-icon,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-path,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-text,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-title,.DocSearch-Hit[aria-selected=true] mark{color:var(--docsearch-hit-active-color)!important}.DocSearch-ErrorScreen,.DocSearch-NoResults,.DocSearch-StartScreen{font-size:.9em;margin:0 auto;padding:36px 0;text-align:center;width:80%}.DocSearch-Screen-Icon{color:var(--docsearch-muted-color);padding-bottom:12px}.DocSearch-NoResults-Prefill-List{display:inline-block;padding-bottom:24px;text-align:left}.DocSearch-NoResults-Prefill-List ul{display:inline-block;padding:8px 0 0}.DocSearch-NoResults-Prefill-List li{list-style-position:inside;list-style-type:"» "}.DocSearch-Prefill{appearance:none;background:none;border:0;border-radius:1em;color:var(--docsearch-highlight-color);cursor:pointer;display:inline-block;font-size:1em;font-weight:700;padding:0}.DocSearch-Prefill:focus,.DocSearch-Prefill:hover{outline:0}.DocSearch-Footer{align-items:center;background:var(--docsearch-footer-background);border-radius:0 0 8px 8px;box-shadow:var(--docsearch-footer-shadow);display:flex;flex-direction:row-reverse;flex-shrink:0;height:var(--docsearch-footer-height);justify-content:space-between;padding:0 var(--docsearch-spacing);position:relative;-webkit-user-select:none;user-select:none;width:100%;z-index:300}.DocSearch-Commands{color:var(--docsearch-muted-color);display:flex;list-style:none;margin:0;padding:0}.DocSearch-Commands li{align-items:center;display:flex}.DocSearch-Commands li:not(:last-of-type){margin-right:.8em}.DocSearch-Commands-Key{align-items:center;background:var(--docsearch-key-gradient);border:0;border-radius:2px;box-shadow:var(--docsearch-key-shadow);color:var(--docsearch-muted-color);display:flex;height:18px;justify-content:center;margin-right:.4em;padding:0 0 1px;width:20px}.buttonGroup__atx button,.codeBlockContainer_Ckt0{background:var(--prism-background-color);color:var(--prism-color)}.DocSearch-VisuallyHiddenForAccessibility{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}@keyframes a{0%{opacity:0}to{opacity:1}}.DocSearch-Button{margin:0;transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.DocSearch-Container{z-index:calc(var(--ifm-z-index-fixed) + 1)}.codeBlockContainer_Ckt0{border-radius:var(--ifm-code-border-radius);box-shadow:var(--ifm-global-shadow-lw);margin-bottom:var(--ifm-leading)}.codeBlockContent_biex{border-radius:inherit;direction:ltr;position:relative}.codeBlockTitle_Ktv7{border-bottom:1px solid var(--ifm-color-emphasis-300);border-top-left-radius:inherit;border-top-right-radius:inherit;font-size:var(--ifm-code-font-size);font-weight:500;padding:.75rem var(--ifm-pre-padding)}.codeBlock_bY9V{--ifm-pre-background:var(--prism-background-color);margin:0;padding:0}.codeBlockTitle_Ktv7+.codeBlockContent_biex .codeBlock_bY9V{border-top-left-radius:0;border-top-right-radius:0}.codeBlockLines_e6Vv{float:left;font:inherit;min-width:100%;padding:var(--ifm-pre-padding)}.codeBlockLinesWithNumbering_o6Pm{display:table;padding:var(--ifm-pre-padding) 0}.buttonGroup__atx{column-gap:.2rem;display:flex;position:absolute;right:calc(var(--ifm-pre-padding)/2);top:calc(var(--ifm-pre-padding)/2)}.buttonGroup__atx button{align-items:center;border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-global-radius);display:flex;line-height:0;opacity:0;padding:.4rem;transition:opacity var(--ifm-transition-fast) ease-in-out}.buttonGroup__atx button:focus-visible,.buttonGroup__atx button:hover{opacity:1!important}.theme-code-block:hover .buttonGroup__atx button{opacity:.4}:where(:root){--docusaurus-highlighted-code-line-bg:#484d5b}:where([data-theme=dark]){--docusaurus-highlighted-code-line-bg:#646464}.theme-code-block-highlighted-line{background-color:var(--docusaurus-highlighted-code-line-bg);display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}.codeLine_lJS_{counter-increment:a;display:table-row}.codeLineNumber_Tfdd{background:var(--ifm-pre-background);display:table-cell;left:0;overflow-wrap:normal;padding:0 var(--ifm-pre-padding);position:sticky;text-align:right;width:1%}.codeLineNumber_Tfdd:before{content:counter(a);opacity:.4}.codeLineContent_feaV{padding-right:var(--ifm-pre-padding)}.theme-code-block:hover .copyButtonCopied_obH4{opacity:1!important}.copyButtonIcons_eSgA{height:1.125rem;position:relative;width:1.125rem}.copyButtonIcon_y97N,.copyButtonSuccessIcon_LjdS{left:0;position:absolute;top:0;fill:currentColor;height:inherit;opacity:inherit;transition:all var(--ifm-transition-fast) ease;width:inherit}.copyButtonSuccessIcon_LjdS{color:#00d600;left:50%;opacity:0;top:50%;transform:translate(-50%,-50%) scale(.33)}.copyButtonCopied_obH4 .copyButtonIcon_y97N{opacity:0;transform:scale(.33)}.copyButtonCopied_obH4 .copyButtonSuccessIcon_LjdS{opacity:1;transform:translate(-50%,-50%) scale(1);transition-delay:75ms}.wordWrapButtonIcon_Bwma{height:1.2rem;width:1.2rem}.rootFolderInput_ottS{left:13px;position:absolute;top:56px;z-index:10}.rootFolderInput_ottS .input_OR7e{background-color:#ffffff1f;border-color:#303436;width:16rem}.rootFolderInput_ottS.application_fjej{left:48px;top:87px}.input_OR7e{border-color:var(--ifm-color-content-secondary);border-radius:2px;border-style:solid;border-width:var(--ifm-global-border-width);font-size:calc(var(--ifm-font-size-base)/1.1);padding:.2rem .4rem}.input_OR7e.application_fjej{width:14rem}.skipToContent_fXgn{background-color:var(--ifm-background-surface-color);color:var(--ifm-color-emphasis-900);left:100%;padding:calc(var(--ifm-global-spacing)/2) var(--ifm-global-spacing);position:fixed;top:1rem;z-index:calc(var(--ifm-z-index-fixed) + 1)}.skipToContent_fXgn:focus{box-shadow:var(--ifm-global-shadow-md);left:1rem}.closeButton_CVFx{line-height:0;padding:0}.content_knG7{font-size:85%;padding:5px 0;text-align:center}.content_knG7 a{color:inherit}.announcementBar_mb4j{align-items:center;background-color:var(--ifm-color-white);border-bottom:1px solid var(--ifm-color-emphasis-100);color:var(--ifm-color-black);display:flex;height:var(--docusaurus-announcement-bar-height)}.announcementBarPlaceholder_vyr4{flex:0 0 10px}.announcementBarClose_gvF7{align-self:stretch;flex:0 0 30px}.toggle_vylO{height:2rem;width:2rem}.toggleButton_gllP{align-items:center;border-radius:50%;display:flex;height:100%;justify-content:center;transition:background var(--ifm-transition-fast);width:100%}.toggleButton_gllP:hover{background:var(--ifm-color-emphasis-200)}.toggleButtonDisabled_aARS{cursor:not-allowed}.darkNavbarColorModeToggle_X3D1:hover{background:var(--ifm-color-gray-800)}[data-theme=dark] .themedComponent--dark_xIcU,[data-theme=light] .themedComponent--light_NVdE,html:not([data-theme]) .themedComponent--light_NVdE{display:initial}.collapseSidebarButton_PEFL{display:none;margin:0}.iconExternalLink_nPIU{margin-left:.3rem}.docMainContainer_TBSr,.docRoot_UBD9{display:flex;width:100%}.docsWrapper_hBAB{display:flex;flex:1 0 auto}.dropdownNavbarItemMobile_S0Fm{cursor:pointer}.iconLanguage_nlXk{margin-right:5px;vertical-align:text-bottom}.navbarHideable_m1mJ{transition:transform var(--ifm-transition-fast) ease}.navbarHidden_jGov{transform:translate3d(0,calc(-100% - 2px),0)}.errorBoundaryError_a6uf{color:red;white-space:pre-wrap}.errorBoundaryFallback_VBag{color:red;padding:.55rem}.footerLogoLink_BH7S{opacity:.5;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.footerLogoLink_BH7S:hover,.hash-link:focus,:hover>.hash-link{opacity:1}body:not(.navigation-with-keyboard) :not(input):focus{outline:0}.anchorWithStickyNavbar_LWe7{scroll-margin-top:calc(var(--ifm-navbar-height) + .5rem)}.anchorWithHideOnScrollNavbar_WYt5{scroll-margin-top:.5rem}.hash-link{opacity:0;padding-left:.5rem;transition:opacity var(--ifm-transition-fast);-webkit-user-select:none;user-select:none}.hash-link:before{content:"#"}.mainWrapper_z2l0{display:flex;flex:1 0 auto;flex-direction:column}.docusaurus-mt-lg{margin-top:3rem}#__docusaurus{display:flex;flex-direction:column;min-height:100%}.details_lb9f{--docusaurus-details-summary-arrow-size:0.38rem;--docusaurus-details-transition:transform 200ms ease;--docusaurus-details-decoration-color:grey}.details_lb9f>summary{cursor:pointer;list-style:none;padding-left:1rem;position:relative}.details_lb9f>summary::-webkit-details-marker{display:none}.details_lb9f>summary:before{border-color:#0000 #0000 #0000 var(--docusaurus-details-decoration-color);border-style:solid;border-width:var(--docusaurus-details-summary-arrow-size);content:"";left:0;position:absolute;top:.45rem;transform:rotate(0);transform-origin:calc(var(--docusaurus-details-summary-arrow-size)/2) 50%;transition:var(--docusaurus-details-transition)}.collapsibleContent_i85q{border-top:1px solid var(--docusaurus-details-decoration-color);margin-top:1rem;padding-top:1rem}.details_b_Ee{--docusaurus-details-decoration-color:var(--ifm-alert-border-color);--docusaurus-details-transition:transform var(--ifm-transition-fast) ease;border:1px solid var(--ifm-alert-border-color);margin:0 0 var(--ifm-spacing-vertical)}.containsTaskList_mC6p{list-style:none}.img_ev3q{height:auto}.admonition_xJq3{margin-bottom:1em}.admonitionHeading_Gvgb{font:var(--ifm-heading-font-weight) var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family)}.admonitionHeading_Gvgb:not(:last-child){margin-bottom:.3rem}.admonitionHeading_Gvgb code{text-transform:none}.admonitionIcon_Rf37{display:inline-block;margin-right:.4em;vertical-align:middle}.admonitionIcon_Rf37 svg{display:inline-block;height:1.6em;width:1.6em;fill:var(--ifm-alert-foreground-color)}.breadcrumbHomeIcon_YNFT{height:1.1rem;position:relative;top:1px;vertical-align:top;width:1.1rem}.breadcrumbsContainer_Z_bl{--ifm-breadcrumb-size-multiplier:0.8;margin-bottom:.8rem}.searchQueryInput_u2C7,.searchVersionInput_m0Ui{background:var(--docsearch-searchbox-focus-background);border:2px solid var(--ifm-toc-border-color);border-radius:var(--ifm-global-radius);color:var(--docsearch-text-color);font:var(--ifm-font-size-base) var(--ifm-font-family-base);margin-bottom:.5rem;padding:.8rem;transition:border var(--ifm-transition-fast) ease;width:100%}.searchQueryInput_u2C7:focus,.searchVersionInput_m0Ui:focus{border-color:var(--docsearch-primary-color);outline:0}.searchQueryInput_u2C7::placeholder{color:var(--docsearch-muted-color)}.searchResultsColumn_JPFH{font-size:.9rem;font-weight:700}.algoliaLogo_rT1R{max-width:150px}.algoliaLogoPathFill_WdUC{fill:var(--ifm-font-color-base)}.searchResultItem_Tv2o{border-bottom:1px solid var(--ifm-toc-border-color);padding:1rem 0}.searchResultItemHeading_KbCB{font-weight:400;margin-bottom:0}.searchResultItemPath_lhe1{color:var(--ifm-color-content-secondary);font-size:.8rem;--ifm-breadcrumb-separator-size-multiplier:1}.searchResultItemSummary_AEaO{font-style:italic;margin:.5rem 0 0}.loadingSpinner_XVxU{animation:1s linear infinite b;border:.4em solid #eee;border-radius:50%;border-top:.4em solid var(--ifm-color-primary);height:3rem;margin:0 auto;width:3rem}@keyframes b{to{transform:rotate(1turn)}}.search-result-match{background:#ffd78e40;color:var(--docsearch-hit-color);padding:.09em 0}@media (min-width:997px){.collapseSidebarButton_PEFL,.expandButton_TmdG{background-color:var(--docusaurus-collapse-button-bg)}.lastUpdated_JAkA{text-align:right}.tocMobile_ITEo{display:none}:root{--docusaurus-announcement-bar-height:30px}.announcementBarClose_gvF7,.announcementBarPlaceholder_vyr4{flex-basis:50px}.collapseSidebarButton_PEFL{border:1px solid var(--ifm-toc-border-color);border-radius:0;bottom:0;display:block!important;height:40px;position:sticky}.collapseSidebarButtonIcon_kv0_{margin-top:4px;transform:rotate(180deg)}.expandButtonIcon_i1dp,[dir=rtl] .collapseSidebarButtonIcon_kv0_{transform:rotate(0)}.collapseSidebarButton_PEFL:focus,.collapseSidebarButton_PEFL:hover,.expandButton_TmdG:focus,.expandButton_TmdG:hover{background-color:var(--docusaurus-collapse-button-bg-hover)}.menuHtmlItem_M9Kj{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu_SIkG{flex-grow:1;padding:.5rem}@supports (scrollbar-gutter:stable){.menu_SIkG{padding:.5rem 0 .5rem .5rem;scrollbar-gutter:stable}}.menuWithAnnouncementBar_GW3s{margin-bottom:var(--docusaurus-announcement-bar-height)}.sidebar_njMd{display:flex;flex-direction:column;height:100%;padding-top:var(--ifm-navbar-height);width:var(--doc-sidebar-width)}.sidebarWithHideableNavbar_wUlq{padding-top:0}.sidebarHidden_VK0M{opacity:0;visibility:hidden}.sidebarLogo_isFc{align-items:center;color:inherit!important;display:flex!important;margin:0 var(--ifm-navbar-padding-horizontal);max-height:var(--ifm-navbar-height);min-height:var(--ifm-navbar-height);-webkit-text-decoration:none!important;text-decoration:none!important}.sidebarLogo_isFc img{height:2rem;margin-right:.5rem}.expandButton_TmdG{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;transition:background-color var(--ifm-transition-fast) ease;width:100%}[dir=rtl] .expandButtonIcon_i1dp{transform:rotate(180deg)}.docSidebarContainer_YfHR{border-right:1px solid var(--ifm-toc-border-color);clip-path:inset(0);display:block;margin-top:calc(var(--ifm-navbar-height)*-1);transition:width var(--ifm-transition-fast) ease;width:var(--doc-sidebar-width);will-change:width}.docSidebarContainerHidden_DPk8{cursor:pointer;width:var(--doc-sidebar-hidden-width)}.sidebarViewport_aRkj{height:100%;max-height:100vh;position:sticky;top:0}.docMainContainer_TBSr{flex-grow:1;max-width:calc(100% - var(--doc-sidebar-width))}.docMainContainerEnhanced_lQrH{max-width:calc(100% - var(--doc-sidebar-hidden-width))}.docItemWrapperEnhanced_JWYK{max-width:calc(var(--ifm-container-width) + var(--doc-sidebar-width))!important}.navbarSearchContainer_Bca1{padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.docItemCol_VOVn{max-width:75%!important}}@media (min-width:1440px){.container{max-width:var(--ifm-container-width-xl)}}@media (max-width:996px){.col{--ifm-col-width:100%;flex-basis:var(--ifm-col-width);margin-left:0}.footer{--ifm-footer-padding-horizontal:0}.colorModeToggle_DEke,.footer__link-separator,.navbar__item,.tableOfContents_bqdL{display:none}.footer__col{margin-bottom:calc(var(--ifm-spacing-vertical)*3)}.footer__link-item{display:block}.hero{padding-left:0;padding-right:0}.navbar>.container,.navbar>.container-fluid{padding:0}.navbar__toggle{display:inherit}.navbar__search-input{width:9rem}.pills--block,.tabs--block{flex-direction:column}.docItemContainer_F8PC{padding:0 .3rem}.navbarSearchContainer_Bca1{position:absolute;right:var(--ifm-navbar-padding-horizontal)}}@media only screen and (max-width:996px){.searchQueryColumn_RTkw,.searchResultsColumn_JPFH{max-width:60%!important}.searchLogoColumn_rJIA,.searchVersionColumn_ypXd{max-width:40%!important}.searchLogoColumn_rJIA{padding-left:0!important}}@media (max-width:768px){.DocSearch-Button-Keys,.DocSearch-Button-Placeholder,.DocSearch-Commands,.DocSearch-Hit-Tree{display:none}:root{--docsearch-spacing:10px;--docsearch-footer-height:40px}.DocSearch-Dropdown{height:100%;max-height:calc(var(--docsearch-vh,1vh)*100 - var(--docsearch-searchbox-height) - var(--docsearch-spacing) - var(--docsearch-footer-height))}.DocSearch-Container{height:100vh;height:-webkit-fill-available;height:calc(var(--docsearch-vh,1vh)*100);position:absolute}.DocSearch-Footer{border-radius:0;bottom:0;position:absolute}.DocSearch-Hit-content-wrapper{display:flex;position:relative;width:80%}.DocSearch-Modal{border-radius:0;box-shadow:none;height:100vh;height:-webkit-fill-available;height:calc(var(--docsearch-vh,1vh)*100);margin:0;max-width:100%;width:100%}.DocSearch-Cancel{appearance:none;background:none;border:0;color:var(--docsearch-highlight-color);cursor:pointer;display:inline-block;flex:none;font:inherit;font-size:1em;font-weight:500;margin-left:var(--docsearch-spacing);outline:0;overflow:hidden;padding:0;-webkit-user-select:none;user-select:none;white-space:nowrap}}@media screen and (max-width:768px){:root{--ifm-menu-link-padding-vertical:0.5rem;--ifm-list-item-margin:0.5rem}.menu__link{font-size:1.1rem}.markdown h1+ul li:first-child{margin-top:.25rem}.markdown h1+ul ul ul{margin-bottom:0}.markdown h1+ul li li li:first-child{margin-top:.5rem}}@media (max-width:576px){.markdown h1:first-child{--ifm-h1-font-size:2rem}.markdown>h2{--ifm-h2-font-size:1.5rem}.markdown>h3{--ifm-h3-font-size:1.25rem}}@media screen and (max-width:576px){.searchQueryColumn_RTkw{max-width:100%!important}.searchVersionColumn_ypXd{max-width:100%!important;padding-left:var(--ifm-spacing-horizontal)!important}}@media screen and (max-width:480px){.collection-methods-list>p,.tom-column-types-list>p{column-count:2}}@media (hover:hover){.backToTopButton_sjWU:hover{background-color:var(--ifm-color-emphasis-300)}}@media (pointer:fine){.thin-scrollbar,[data-theme=dark] .thin-scrollbar{scrollbar-width:thin}.thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}.thin-scrollbar::-webkit-scrollbar-track{background:var(--ifm-scrollbar-track-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb{background:var(--ifm-scrollbar-thumb-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb:hover{background:var(--ifm-scrollbar-thumb-hover-background-color)}[data-theme=dark] .thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}}@media (prefers-reduced-motion:reduce){:root{--ifm-transition-fast:0ms;--ifm-transition-slow:0ms}}@media screen and (prefers-reduced-motion:reduce){.DocSearch-Reset{animation:none;appearance:none;background:none;border:0;border-radius:50%;color:var(--docsearch-icon-color);cursor:pointer;right:0;stroke-width:var(--docsearch-icon-stroke-width)}.DocSearch-Hit--deleting,.DocSearch-Hit--favoriting{transition:none}.DocSearch-Hit-action-button:focus,.DocSearch-Hit-action-button:hover{background:#0003;transition:none}}@media print{.announcementBar_mb4j,.footer,.menu,.navbar,.pagination-nav,.table-of-contents,.tocMobile_ITEo{display:none}.tabs{page-break-inside:avoid}.codeBlockLines_e6Vv{white-space:pre-wrap}} \ No newline at end of file +.col,.container{padding:0 var(--ifm-spacing-horizontal);width:100%}.markdown>h2,.markdown>h3,.markdown>h4,.markdown>h5,.markdown>h6{margin-bottom:calc(var(--ifm-heading-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown li,body{word-wrap:break-word}body,ol ol,ol ul,ul ol,ul ul{margin:0}pre,table{overflow:auto}blockquote,pre{margin:0 0 var(--ifm-spacing-vertical)}.breadcrumbs__link,.button{transition-timing-function:var(--ifm-transition-timing-default)}.button--outline.button--active,.button--outline:active,.button--outline:hover,:root{--ifm-button-color:var(--ifm-font-color-base-inverse)}.menu__link:hover,a{transition:color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.navbar--dark,:root{--ifm-navbar-link-hover-color:var(--ifm-color-primary)}.menu,.navbar-sidebar{overflow-x:hidden}:root,html[data-theme=dark]{--ifm-color-emphasis-500:var(--ifm-color-gray-500)}#apitable-sponsors table,pre code{font-size:100%}#tinyorm-configuration input,.button,code{vertical-align:middle}*,.DocSearch-Container,.DocSearch-Container *{box-sizing:border-box}.toggleButton_gllP,html{-webkit-tap-highlight-color:transparent}:root{--ifm-color-scheme:light;--ifm-dark-value:10%;--ifm-darker-value:15%;--ifm-darkest-value:30%;--ifm-light-value:15%;--ifm-lighter-value:30%;--ifm-lightest-value:50%;--ifm-contrast-background-value:90%;--ifm-contrast-foreground-value:70%;--ifm-contrast-background-dark-value:70%;--ifm-contrast-foreground-dark-value:90%;--ifm-color-primary:#3578e5;--ifm-color-secondary:#ebedf0;--ifm-color-success:#00a400;--ifm-color-info:#54c7ec;--ifm-color-warning:#ffba00;--ifm-color-danger:#fa383e;--ifm-color-primary-dark:#306cce;--ifm-color-primary-darker:#2d66c3;--ifm-color-primary-darkest:#2554a0;--ifm-color-primary-light:#538ce9;--ifm-color-primary-lighter:#72a1ed;--ifm-color-primary-lightest:#9abcf2;--ifm-color-primary-contrast-background:#ebf2fc;--ifm-color-primary-contrast-foreground:#102445;--ifm-color-secondary-dark:#d4d5d8;--ifm-color-secondary-darker:#c8c9cc;--ifm-color-secondary-darkest:#a4a6a8;--ifm-color-secondary-light:#eef0f2;--ifm-color-secondary-lighter:#f1f2f5;--ifm-color-secondary-lightest:#f5f6f8;--ifm-color-secondary-contrast-background:#fdfdfe;--ifm-color-secondary-contrast-foreground:#474748;--ifm-color-success-dark:#009400;--ifm-color-success-darker:#008b00;--ifm-color-success-darkest:#007300;--ifm-color-success-light:#26b226;--ifm-color-success-lighter:#4dbf4d;--ifm-color-success-lightest:#80d280;--ifm-color-success-contrast-background:#e6f6e6;--ifm-color-success-contrast-foreground:#003100;--ifm-color-info-dark:#4cb3d4;--ifm-color-info-darker:#47a9c9;--ifm-color-info-darkest:#3b8ba5;--ifm-color-info-light:#6ecfef;--ifm-color-info-lighter:#87d8f2;--ifm-color-info-lightest:#aae3f6;--ifm-color-info-contrast-background:#eef9fd;--ifm-color-info-contrast-foreground:#193c47;--ifm-color-warning-dark:#e6a700;--ifm-color-warning-darker:#d99e00;--ifm-color-warning-darkest:#b38200;--ifm-color-warning-light:#ffc426;--ifm-color-warning-lighter:#ffcf4d;--ifm-color-warning-lightest:#ffdd80;--ifm-color-warning-contrast-background:#fff8e6;--ifm-color-warning-contrast-foreground:#4d3800;--ifm-color-danger-dark:#e13238;--ifm-color-danger-darker:#d53035;--ifm-color-danger-darkest:#af272b;--ifm-color-danger-light:#fb565b;--ifm-color-danger-lighter:#fb7478;--ifm-color-danger-lightest:#fd9c9f;--ifm-color-danger-contrast-background:#ffebec;--ifm-color-danger-contrast-foreground:#4b1113;--ifm-color-white:#fff;--ifm-color-black:#000;--ifm-color-gray-0:var(--ifm-color-white);--ifm-color-gray-100:#f5f6f7;--ifm-color-gray-200:#ebedf0;--ifm-color-gray-300:#dadde1;--ifm-color-gray-400:#ccd0d5;--ifm-color-gray-500:#bec3c9;--ifm-color-gray-600:#8d949e;--ifm-color-gray-700:#606770;--ifm-color-gray-800:#444950;--ifm-color-gray-900:#1c1e21;--ifm-color-gray-1000:var(--ifm-color-black);--ifm-color-emphasis-0:var(--ifm-color-gray-0);--ifm-color-emphasis-100:var(--ifm-color-gray-100);--ifm-color-emphasis-200:var(--ifm-color-gray-200);--ifm-color-emphasis-300:var(--ifm-color-gray-300);--ifm-color-emphasis-400:var(--ifm-color-gray-400);--ifm-color-emphasis-600:var(--ifm-color-gray-600);--ifm-color-emphasis-700:var(--ifm-color-gray-700);--ifm-color-emphasis-800:var(--ifm-color-gray-800);--ifm-color-emphasis-900:var(--ifm-color-gray-900);--ifm-color-emphasis-1000:var(--ifm-color-gray-1000);--ifm-color-content:var(--ifm-color-emphasis-900);--ifm-color-content-inverse:var(--ifm-color-emphasis-0);--ifm-color-content-secondary:#525860;--ifm-background-color:#0000;--ifm-background-surface-color:var(--ifm-color-content-inverse);--ifm-global-border-width:1px;--ifm-global-radius:0.4rem;--ifm-hover-overlay:#0000000d;--ifm-font-color-base:var(--ifm-color-content);--ifm-font-color-base-inverse:var(--ifm-color-content-inverse);--ifm-font-color-secondary:var(--ifm-color-content-secondary);--ifm-font-family-base:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";--ifm-font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ifm-font-size-base:100%;--ifm-font-weight-light:300;--ifm-font-weight-normal:400;--ifm-font-weight-semibold:500;--ifm-font-weight-bold:700;--ifm-font-weight-base:var(--ifm-font-weight-normal);--ifm-line-height-base:1.65;--ifm-global-spacing:1rem;--ifm-spacing-vertical:var(--ifm-global-spacing);--ifm-spacing-horizontal:var(--ifm-global-spacing);--ifm-transition-fast:200ms;--ifm-transition-slow:400ms;--ifm-transition-timing-default:cubic-bezier(0.08,0.52,0.52,1);--ifm-global-shadow-lw:0 1px 2px 0 #0000001a;--ifm-global-shadow-md:0 5px 40px #0003;--ifm-global-shadow-tl:0 12px 28px 0 #0003,0 2px 4px 0 #0000001a;--ifm-z-index-dropdown:100;--ifm-z-index-fixed:200;--ifm-z-index-overlay:400;--ifm-container-width:1140px;--ifm-container-width-xl:1320px;--ifm-code-background:#f6f7f8;--ifm-code-border-radius:var(--ifm-global-radius);--ifm-code-font-size:90%;--ifm-code-padding-horizontal:0.1rem;--ifm-code-padding-vertical:0.1rem;--ifm-pre-background:var(--ifm-code-background);--ifm-pre-border-radius:var(--ifm-code-border-radius);--ifm-pre-color:inherit;--ifm-pre-line-height:1.45;--ifm-pre-padding:1rem;--ifm-heading-color:inherit;--ifm-heading-margin-top:0;--ifm-heading-margin-bottom:var(--ifm-spacing-vertical);--ifm-heading-font-family:var(--ifm-font-family-base);--ifm-heading-font-weight:var(--ifm-font-weight-bold);--ifm-heading-line-height:1.25;--ifm-h1-font-size:2rem;--ifm-h2-font-size:1.5rem;--ifm-h3-font-size:1.25rem;--ifm-h4-font-size:1rem;--ifm-h5-font-size:0.875rem;--ifm-h6-font-size:0.85rem;--ifm-image-alignment-padding:1.25rem;--ifm-leading-desktop:1.25;--ifm-leading:calc(var(--ifm-leading-desktop)*1rem);--ifm-list-left-padding:2rem;--ifm-list-margin:1rem;--ifm-list-item-margin:0.25rem;--ifm-list-paragraph-margin:1rem;--ifm-table-cell-padding:0.75rem;--ifm-table-background:#0000;--ifm-table-stripe-background:#00000008;--ifm-table-border-width:1px;--ifm-table-border-color:var(--ifm-color-emphasis-300);--ifm-table-head-background:inherit;--ifm-table-head-color:inherit;--ifm-table-head-font-weight:var(--ifm-font-weight-bold);--ifm-table-cell-color:inherit;--ifm-link-color:var(--ifm-color-primary);--ifm-link-decoration:none;--ifm-link-hover-color:var(--ifm-link-color);--ifm-link-hover-decoration:underline;--ifm-paragraph-margin-bottom:var(--ifm-leading);--ifm-blockquote-font-size:var(--ifm-font-size-base);--ifm-blockquote-border-left-width:2px;--ifm-blockquote-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-blockquote-padding-vertical:0;--ifm-blockquote-shadow:none;--ifm-blockquote-color:var(--ifm-color-emphasis-800);--ifm-blockquote-border-color:var(--ifm-color-emphasis-300);--ifm-hr-background-color:var(--ifm-color-emphasis-500);--ifm-hr-height:1px;--ifm-hr-margin-vertical:1.5rem;--ifm-scrollbar-size:7px;--ifm-scrollbar-track-background-color:#f1f1f1;--ifm-scrollbar-thumb-background-color:silver;--ifm-scrollbar-thumb-hover-background-color:#a7a7a7;--ifm-alert-background-color:inherit;--ifm-alert-border-color:inherit;--ifm-alert-border-radius:var(--ifm-global-radius);--ifm-alert-border-width:0px;--ifm-alert-border-left-width:5px;--ifm-alert-color:var(--ifm-font-color-base);--ifm-alert-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-alert-padding-vertical:var(--ifm-spacing-vertical);--ifm-alert-shadow:var(--ifm-global-shadow-lw);--ifm-avatar-intro-margin:1rem;--ifm-avatar-intro-alignment:inherit;--ifm-avatar-photo-size:3rem;--ifm-badge-background-color:inherit;--ifm-badge-border-color:inherit;--ifm-badge-border-radius:var(--ifm-global-radius);--ifm-badge-border-width:var(--ifm-global-border-width);--ifm-badge-color:var(--ifm-color-white);--ifm-badge-padding-horizontal:calc(var(--ifm-spacing-horizontal)*0.5);--ifm-badge-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-breadcrumb-border-radius:1.5rem;--ifm-breadcrumb-spacing:0.5rem;--ifm-breadcrumb-color-active:var(--ifm-color-primary);--ifm-breadcrumb-item-background-active:var(--ifm-hover-overlay);--ifm-breadcrumb-padding-horizontal:0.8rem;--ifm-breadcrumb-padding-vertical:0.4rem;--ifm-breadcrumb-size-multiplier:1;--ifm-breadcrumb-separator:url('data:image/svg+xml;utf8,');--ifm-breadcrumb-separator-filter:none;--ifm-breadcrumb-separator-size:0.5rem;--ifm-breadcrumb-separator-size-multiplier:1.25;--ifm-button-background-color:inherit;--ifm-button-border-color:var(--ifm-button-background-color);--ifm-button-border-width:var(--ifm-global-border-width);--ifm-button-font-weight:var(--ifm-font-weight-bold);--ifm-button-padding-horizontal:1.5rem;--ifm-button-padding-vertical:0.375rem;--ifm-button-size-multiplier:1;--ifm-button-transition-duration:var(--ifm-transition-fast);--ifm-button-border-radius:calc(var(--ifm-global-radius)*var(--ifm-button-size-multiplier));--ifm-button-group-spacing:2px;--ifm-card-background-color:var(--ifm-background-surface-color);--ifm-card-border-radius:calc(var(--ifm-global-radius)*2);--ifm-card-horizontal-spacing:var(--ifm-global-spacing);--ifm-card-vertical-spacing:var(--ifm-global-spacing);--ifm-toc-border-color:var(--ifm-color-emphasis-300);--ifm-toc-link-color:var(--ifm-color-content-secondary);--ifm-toc-padding-vertical:0.5rem;--ifm-toc-padding-horizontal:0.5rem;--ifm-dropdown-background-color:var(--ifm-background-surface-color);--ifm-dropdown-font-weight:var(--ifm-font-weight-semibold);--ifm-dropdown-link-color:var(--ifm-font-color-base);--ifm-dropdown-hover-background-color:var(--ifm-hover-overlay);--ifm-footer-background-color:var(--ifm-color-emphasis-100);--ifm-footer-color:inherit;--ifm-footer-link-color:var(--ifm-color-emphasis-700);--ifm-footer-link-hover-color:var(--ifm-color-primary);--ifm-footer-link-horizontal-spacing:0.5rem;--ifm-footer-padding-horizontal:calc(var(--ifm-spacing-horizontal)*2);--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*2);--ifm-footer-title-color:inherit;--ifm-footer-logo-max-width:min(30rem,90vw);--ifm-hero-background-color:var(--ifm-background-surface-color);--ifm-hero-text-color:var(--ifm-color-emphasis-800);--ifm-menu-color:var(--ifm-color-emphasis-700);--ifm-menu-color-active:var(--ifm-color-primary);--ifm-menu-color-background-active:var(--ifm-hover-overlay);--ifm-menu-color-background-hover:var(--ifm-hover-overlay);--ifm-menu-link-padding-horizontal:0.75rem;--ifm-menu-link-padding-vertical:0.375rem;--ifm-menu-link-sublist-icon:url('data:image/svg+xml;utf8,');--ifm-menu-link-sublist-icon-filter:none;--ifm-navbar-background-color:var(--ifm-background-surface-color);--ifm-navbar-height:3.75rem;--ifm-navbar-item-padding-horizontal:0.75rem;--ifm-navbar-item-padding-vertical:0.25rem;--ifm-navbar-link-color:var(--ifm-font-color-base);--ifm-navbar-link-active-color:var(--ifm-link-color);--ifm-navbar-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-navbar-padding-vertical:calc(var(--ifm-spacing-vertical)*0.5);--ifm-navbar-shadow:var(--ifm-global-shadow-lw);--ifm-navbar-search-input-background-color:var(--ifm-color-emphasis-200);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-800);--ifm-navbar-search-input-placeholder-color:var(--ifm-color-emphasis-500);--ifm-navbar-search-input-icon:url('data:image/svg+xml;utf8,');--ifm-navbar-sidebar-width:83vw;--ifm-pagination-border-radius:var(--ifm-global-radius);--ifm-pagination-color-active:var(--ifm-color-primary);--ifm-pagination-font-size:1rem;--ifm-pagination-item-active-background:var(--ifm-hover-overlay);--ifm-pagination-page-spacing:0.2em;--ifm-pagination-padding-horizontal:calc(var(--ifm-spacing-horizontal)*1);--ifm-pagination-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-pagination-nav-border-radius:var(--ifm-global-radius);--ifm-pagination-nav-color-hover:var(--ifm-color-primary);--ifm-pills-color-active:var(--ifm-color-primary);--ifm-pills-color-background-active:var(--ifm-hover-overlay);--ifm-pills-spacing:0.125rem;--ifm-tabs-color:var(--ifm-font-color-secondary);--ifm-tabs-color-active:var(--ifm-color-primary);--ifm-tabs-color-active-border:var(--ifm-tabs-color-active);--ifm-tabs-padding-horizontal:1rem;--ifm-tabs-padding-vertical:1rem;--docusaurus-progress-bar-color:var(--ifm-color-primary);--ifm-color-primary:#25c2a0;--ifm-color-primary-dark:#21af90;--ifm-color-primary-darker:#1fa588;--ifm-color-primary-darkest:#1a8870;--ifm-color-primary-light:#46cbae;--ifm-color-primary-lighter:#66d4bd;--ifm-color-primary-lightest:#92e0d0;--ifm-font-size-base:1.1rem;--ifm-code-font-size:86%;--ifm-pre-line-height:var(--ifm-line-height-base);--doc-sidebar-width:14rem!important;--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*1.4);--docusaurus-tag-list-border:var(--ifm-color-emphasis-300);--docsearch-primary-color:#5468ff;--docsearch-text-color:#1c1e21;--docsearch-spacing:12px;--docsearch-icon-stroke-width:1.4;--docsearch-highlight-color:var(--docsearch-primary-color);--docsearch-muted-color:#969faf;--docsearch-container-background:#656c85cc;--docsearch-logo-color:#5468ff;--docsearch-modal-width:560px;--docsearch-modal-height:600px;--docsearch-modal-background:#f5f6f7;--docsearch-modal-shadow:inset 1px 1px 0 0 #ffffff80,0 3px 8px 0 #555a64;--docsearch-searchbox-height:56px;--docsearch-searchbox-background:#ebedf0;--docsearch-searchbox-focus-background:#fff;--docsearch-searchbox-shadow:inset 0 0 0 2px var(--docsearch-primary-color);--docsearch-hit-height:56px;--docsearch-hit-color:#444950;--docsearch-hit-active-color:#fff;--docsearch-hit-background:#fff;--docsearch-hit-shadow:0 1px 3px 0 #d4d9e1;--docsearch-key-gradient:linear-gradient(-225deg,#d5dbe4,#f8f8f8);--docsearch-key-shadow:inset 0 -2px 0 0 #cdcde6,inset 0 0 1px 1px #fff,0 1px 2px 1px #1e235a66;--docsearch-key-pressed-shadow:inset 0 -2px 0 0 #cdcde6,inset 0 0 1px 1px #fff,0 1px 1px 0 #1e235a66;--docsearch-footer-height:44px;--docsearch-footer-background:#fff;--docsearch-footer-shadow:0 -1px 0 0 #e0e3e8,0 -3px 6px 0 #45629b1f;--docsearch-primary-color:var(--ifm-color-primary);--docsearch-text-color:var(--ifm-font-color-base);--docusaurus-announcement-bar-height:auto;--docusaurus-collapse-button-bg:#0000;--docusaurus-collapse-button-bg-hover:#0000001a;--doc-sidebar-width:300px;--doc-sidebar-hidden-width:30px}.badge--danger,.badge--info,.badge--primary,.badge--secondary,.badge--success,.badge--warning{--ifm-badge-border-color:var(--ifm-badge-background-color)}.button--link,.button--outline{--ifm-button-background-color:#0000}html{background-color:var(--ifm-background-color);color:var(--ifm-font-color-base);color-scheme:var(--ifm-color-scheme);font:var(--ifm-font-size-base)/var(--ifm-line-height-base) var(--ifm-font-family-base);-webkit-font-smoothing:antialiased;text-rendering:optimizelegibility;-webkit-text-size-adjust:100%;text-size-adjust:100%}iframe{border:0;color-scheme:auto}.container{margin:0 auto;max-width:var(--ifm-container-width)}.container--fluid{max-width:inherit}.row{display:flex;flex-wrap:wrap;margin:0 calc(var(--ifm-spacing-horizontal)*-1)}.margin-bottom--none,.margin-vert--none,.markdown>:last-child{margin-bottom:0!important}.margin-top--none,.margin-vert--none,.tabItem_LNqP{margin-top:0!important}.row--no-gutters{margin-left:0;margin-right:0}.margin-horiz--none,.margin-right--none{margin-right:0!important}.row--no-gutters>.col{padding-left:0;padding-right:0}.row--align-top{align-items:flex-start}.row--align-bottom{align-items:flex-end}.menuExternalLink_NmtK,.row--align-center{align-items:center}.row--align-stretch{align-items:stretch}.row--align-baseline{align-items:baseline}.col{--ifm-col-width:100%;flex:1 0;margin-left:0;max-width:var(--ifm-col-width)}.padding-bottom--none,.padding-vert--none{padding-bottom:0!important}.padding-top--none,.padding-vert--none{padding-top:0!important}.padding-horiz--none,.padding-left--none{padding-left:0!important}.padding-horiz--none,.padding-right--none{padding-right:0!important}.col[class*=col--]{flex:0 0 var(--ifm-col-width)}.col--1{--ifm-col-width:8.33333%}.col--offset-1{margin-left:8.33333%}.col--2{--ifm-col-width:16.66667%}.col--offset-2{margin-left:16.66667%}.col--3{--ifm-col-width:25%}.col--offset-3{margin-left:25%}.col--4{--ifm-col-width:33.33333%}.col--offset-4{margin-left:33.33333%}.col--5{--ifm-col-width:41.66667%}.col--offset-5{margin-left:41.66667%}.col--6{--ifm-col-width:50%}.col--offset-6{margin-left:50%}.col--7{--ifm-col-width:58.33333%}.col--offset-7{margin-left:58.33333%}.col--8{--ifm-col-width:66.66667%}.col--offset-8{margin-left:66.66667%}.col--9{--ifm-col-width:75%}.col--offset-9{margin-left:75%}.col--10{--ifm-col-width:83.33333%}.col--offset-10{margin-left:83.33333%}.col--11{--ifm-col-width:91.66667%}.col--offset-11{margin-left:91.66667%}.col--12{--ifm-col-width:100%}.col--offset-12{margin-left:100%}.margin-horiz--none,.margin-left--none{margin-left:0!important}.margin--none{margin:0!important}.margin-bottom--xs,.margin-vert--xs{margin-bottom:.25rem!important}.margin-top--xs,.margin-vert--xs{margin-top:.25rem!important}.margin-horiz--xs,.margin-left--xs{margin-left:.25rem!important}.margin-horiz--xs,.margin-right--xs{margin-right:.25rem!important}.margin--xs{margin:.25rem!important}.margin-bottom--sm,.margin-vert--sm{margin-bottom:.5rem!important}.margin-top--sm,.margin-vert--sm{margin-top:.5rem!important}.margin-horiz--sm,.margin-left--sm{margin-left:.5rem!important}.margin-horiz--sm,.margin-right--sm{margin-right:.5rem!important}.margin--sm{margin:.5rem!important}.margin-bottom--md,.margin-vert--md{margin-bottom:1rem!important}.margin-top--md,.margin-vert--md{margin-top:1rem!important}.margin-horiz--md,.margin-left--md{margin-left:1rem!important}.margin-horiz--md,.margin-right--md{margin-right:1rem!important}.margin--md{margin:1rem!important}.margin-bottom--lg,.margin-vert--lg{margin-bottom:2rem!important}.margin-top--lg,.margin-vert--lg{margin-top:2rem!important}.margin-horiz--lg,.margin-left--lg{margin-left:2rem!important}.margin-horiz--lg,.margin-right--lg{margin-right:2rem!important}.margin--lg{margin:2rem!important}.margin-bottom--xl,.margin-vert--xl{margin-bottom:5rem!important}.margin-top--xl,.margin-vert--xl{margin-top:5rem!important}.margin-horiz--xl,.margin-left--xl{margin-left:5rem!important}.margin-horiz--xl,.margin-right--xl{margin-right:5rem!important}.margin--xl{margin:5rem!important}.padding--none{padding:0!important}.padding-bottom--xs,.padding-vert--xs{padding-bottom:.25rem!important}.padding-top--xs,.padding-vert--xs{padding-top:.25rem!important}.padding-horiz--xs,.padding-left--xs{padding-left:.25rem!important}.padding-horiz--xs,.padding-right--xs{padding-right:.25rem!important}.padding--xs{padding:.25rem!important}.padding-bottom--sm,.padding-vert--sm{padding-bottom:.5rem!important}.padding-top--sm,.padding-vert--sm{padding-top:.5rem!important}.padding-horiz--sm,.padding-left--sm{padding-left:.5rem!important}.padding-horiz--sm,.padding-right--sm{padding-right:.5rem!important}.padding--sm{padding:.5rem!important}.padding-bottom--md,.padding-vert--md{padding-bottom:1rem!important}.padding-top--md,.padding-vert--md{padding-top:1rem!important}.padding-horiz--md,.padding-left--md{padding-left:1rem!important}.padding-horiz--md,.padding-right--md{padding-right:1rem!important}.padding--md{padding:1rem!important}.padding-bottom--lg,.padding-vert--lg{padding-bottom:2rem!important}.padding-top--lg,.padding-vert--lg{padding-top:2rem!important}.padding-horiz--lg,.padding-left--lg{padding-left:2rem!important}.padding-horiz--lg,.padding-right--lg{padding-right:2rem!important}.padding--lg{padding:2rem!important}.padding-bottom--xl,.padding-vert--xl{padding-bottom:5rem!important}.padding-top--xl,.padding-vert--xl{padding-top:5rem!important}.padding-horiz--xl,.padding-left--xl{padding-left:5rem!important}.padding-horiz--xl,.padding-right--xl{padding-right:5rem!important}.padding--xl{padding:5rem!important}code{background-color:var(--ifm-code-background);border:.1rem solid #0000001a;border-radius:var(--ifm-code-border-radius);font-family:var(--ifm-font-family-monospace);font-size:var(--ifm-code-font-size);padding:var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal)}a code{color:inherit}pre{background-color:var(--ifm-pre-background);border-radius:var(--ifm-pre-border-radius);color:var(--ifm-pre-color);font:var(--ifm-code-font-size)/var(--ifm-pre-line-height) var(--ifm-font-family-monospace);padding:var(--ifm-pre-padding)}pre code{background-color:initial;border:none;line-height:inherit;padding:0}kbd{background-color:var(--ifm-color-emphasis-0);border:1px solid var(--ifm-color-emphasis-400);border-radius:.2rem;box-shadow:inset 0 -1px 0 var(--ifm-color-emphasis-400);color:var(--ifm-color-emphasis-800);font:80% var(--ifm-font-family-monospace);padding:.15rem .3rem}h1,h2,h3,h4,h5,h6{color:var(--ifm-heading-color);font-family:var(--ifm-heading-font-family);font-weight:var(--ifm-heading-font-weight);line-height:var(--ifm-heading-line-height);margin:var(--ifm-heading-margin-top) 0 var(--ifm-heading-margin-bottom) 0}h2{font-size:var(--ifm-h2-font-size)}h3{font-size:var(--ifm-h3-font-size)}h4{font-size:var(--ifm-h4-font-size)}h5{font-size:var(--ifm-h5-font-size)}h6{font-size:var(--ifm-h6-font-size)}img{max-width:100%}img[align=right]{padding-left:var(--image-alignment-padding)}img[align=left]{padding-right:var(--image-alignment-padding)}.markdown{--ifm-h1-vertical-rhythm-top:3;--ifm-h2-vertical-rhythm-top:2;--ifm-h3-vertical-rhythm-top:1.5;--ifm-heading-vertical-rhythm-top:1.25;--ifm-h1-vertical-rhythm-bottom:1.25;--ifm-heading-vertical-rhythm-bottom:1}.markdown:after,.markdown:before{content:"";display:table}.markdown:after{clear:both}.markdown h1:first-child{--ifm-h1-font-size:3rem;margin-bottom:calc(var(--ifm-h1-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown>h2{--ifm-h2-font-size:2rem;margin-top:calc(var(--ifm-h2-vertical-rhythm-top)*var(--ifm-leading));--ifm-h2-font-size:1.8rem}.markdown>h3{--ifm-h3-font-size:1.5rem;margin-top:calc(var(--ifm-h3-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h4,.markdown>h5,.markdown>h6{margin-top:calc(var(--ifm-heading-vertical-rhythm-top)*var(--ifm-leading))}.markdown>p,.markdown>pre,.markdown>ul,.tabList__CuJ{margin-bottom:var(--ifm-leading)}.markdown li>p{margin-top:var(--ifm-list-paragraph-margin)}.markdown li+li{margin-top:var(--ifm-list-item-margin)}ol,ul{margin:0 0 var(--ifm-list-margin);padding-left:var(--ifm-list-left-padding)}ol ol,ul ol{list-style-type:lower-roman}ol ol ol,ol ul ol,ul ol ol,ul ul ol{list-style-type:lower-alpha}table{border-collapse:collapse;display:block;margin-bottom:var(--ifm-spacing-vertical)}table thead tr{border-bottom:2px solid var(--ifm-table-border-color)}table thead,table tr:nth-child(2n){background-color:var(--ifm-table-stripe-background)}table tr{background-color:var(--ifm-table-background);border-top:var(--ifm-table-border-width) solid var(--ifm-table-border-color)}table td,table th{border:var(--ifm-table-border-width) solid var(--ifm-table-border-color);padding:var(--ifm-table-cell-padding)}table th{background-color:var(--ifm-table-head-background);color:var(--ifm-table-head-color);font-weight:var(--ifm-table-head-font-weight)}table td{color:var(--ifm-table-cell-color)}strong{font-weight:var(--ifm-font-weight-bold)}a{color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}a:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.button:hover,.text--no-decoration,.text--no-decoration:hover,a:not([href]){-webkit-text-decoration:none;text-decoration:none}p{margin:0 0 var(--ifm-paragraph-margin-bottom)}blockquote{border-left:var(--ifm-blockquote-border-left-width) solid var(--ifm-blockquote-border-color);box-shadow:var(--ifm-blockquote-shadow);color:var(--ifm-blockquote-color);font-size:var(--ifm-blockquote-font-size);padding:var(--ifm-blockquote-padding-vertical) var(--ifm-blockquote-padding-horizontal)}blockquote>:first-child{margin-top:0}blockquote>:last-child{margin-bottom:0}hr{background-color:var(--ifm-hr-background-color);border:0;height:var(--ifm-hr-height);margin:var(--ifm-hr-margin-vertical) 0}.shadow--lw{box-shadow:var(--ifm-global-shadow-lw)!important}.shadow--md{box-shadow:var(--ifm-global-shadow-md)!important}.shadow--tl{box-shadow:var(--ifm-global-shadow-tl)!important}.text--primary,.wordWrapButtonEnabled_EoeP .wordWrapButtonIcon_Bwma{color:var(--ifm-color-primary)}.text--secondary{color:var(--ifm-color-secondary)}.text--success{color:var(--ifm-color-success)}.text--info{color:var(--ifm-color-info)}.text--warning{color:var(--ifm-color-warning)}.text--danger{color:var(--ifm-color-danger)}.apitable-build-options td:nth-child(2),.text--center{text-align:center}.text--left{text-align:left}.text--justify{text-align:justify}#tinyorm-configuration .tinyorm-configuration-row,.text--right{text-align:right}.text--capitalize{text-transform:capitalize}.text--lowercase{text-transform:lowercase}.admonitionHeading_Gvgb,.alert__heading,.text--uppercase{text-transform:uppercase}.text--light{font-weight:var(--ifm-font-weight-light)}.text--normal{font-weight:var(--ifm-font-weight-normal)}.text--semibold{font-weight:var(--ifm-font-weight-semibold)}.text--bold{font-weight:var(--ifm-font-weight-bold)}.text--italic{font-style:italic}.text--truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text--break{word-wrap:break-word!important;word-break:break-word!important}.clean-btn{background:none;border:none;color:inherit;cursor:pointer;font-family:inherit;padding:0}.alert,.alert .close{color:var(--ifm-alert-foreground-color)}.clean-list{list-style:none;padding-left:0}.alert--primary{--ifm-alert-background-color:var(--ifm-color-primary-contrast-background);--ifm-alert-background-color-highlight:#3578e526;--ifm-alert-foreground-color:var(--ifm-color-primary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-primary-dark)}.alert--secondary{--ifm-alert-background-color:var(--ifm-color-secondary-contrast-background);--ifm-alert-background-color-highlight:#ebedf026;--ifm-alert-foreground-color:var(--ifm-color-secondary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-secondary-dark)}.alert--success{--ifm-alert-background-color:var(--ifm-color-success-contrast-background);--ifm-alert-background-color-highlight:#00a40026;--ifm-alert-foreground-color:var(--ifm-color-success-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-success-dark)}.alert--info{--ifm-alert-background-color:var(--ifm-color-info-contrast-background);--ifm-alert-background-color-highlight:#54c7ec26;--ifm-alert-foreground-color:var(--ifm-color-info-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-info-dark)}.alert--warning{--ifm-alert-background-color:var(--ifm-color-warning-contrast-background);--ifm-alert-background-color-highlight:#ffba0026;--ifm-alert-foreground-color:var(--ifm-color-warning-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-warning-dark)}.alert--danger{--ifm-alert-background-color:var(--ifm-color-danger-contrast-background);--ifm-alert-background-color-highlight:#fa383e26;--ifm-alert-foreground-color:var(--ifm-color-danger-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-danger-dark)}.alert{--ifm-code-background:var(--ifm-alert-background-color-highlight);--ifm-link-color:var(--ifm-alert-foreground-color);--ifm-link-hover-color:var(--ifm-alert-foreground-color);--ifm-link-decoration:underline;--ifm-tabs-color:var(--ifm-alert-foreground-color);--ifm-tabs-color-active:var(--ifm-alert-foreground-color);--ifm-tabs-color-active-border:var(--ifm-alert-border-color);background-color:var(--ifm-alert-background-color);border:var(--ifm-alert-border-width) solid var(--ifm-alert-border-color);border-left-width:var(--ifm-alert-border-left-width);border-radius:var(--ifm-alert-border-radius);box-shadow:var(--ifm-alert-shadow);padding:var(--ifm-alert-padding-vertical) var(--ifm-alert-padding-horizontal)}.alert__heading{align-items:center;display:flex;font:700 var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);margin-bottom:.5rem}.alert__icon{display:inline-flex;margin-right:.4em}.alert__icon svg{fill:var(--ifm-alert-foreground-color);stroke:var(--ifm-alert-foreground-color);stroke-width:0}.alert .close{margin:calc(var(--ifm-alert-padding-vertical)*-1) calc(var(--ifm-alert-padding-horizontal)*-1) 0 0;opacity:.75}.alert .close:focus,.alert .close:hover{opacity:1}.alert a{text-decoration-color:var(--ifm-alert-border-color)}.alert a:hover{text-decoration-thickness:2px}.avatar{column-gap:var(--ifm-avatar-intro-margin);display:flex}.avatar__photo{border-radius:50%;display:block;height:var(--ifm-avatar-photo-size);overflow:hidden;width:var(--ifm-avatar-photo-size)}.card--full-height,.navbar__logo img,body,html{height:100%}.avatar__photo--sm{--ifm-avatar-photo-size:2rem}.avatar__photo--lg{--ifm-avatar-photo-size:4rem}.avatar__photo--xl{--ifm-avatar-photo-size:6rem}.avatar__intro{display:flex;flex:1 1;flex-direction:column;justify-content:center;text-align:var(--ifm-avatar-intro-alignment)}.badge,.breadcrumbs__item,.breadcrumbs__link,.button,.dropdown>.navbar__link:after{display:inline-block}.avatar__name{font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base)}.badge,.markdown h1+ul li li li a:before{font-size:75%}.avatar__subtitle{margin-top:.25rem}.avatar--vertical{--ifm-avatar-intro-alignment:center;--ifm-avatar-intro-margin:0.5rem;align-items:center;flex-direction:column}.badge{background-color:var(--ifm-badge-background-color);border:var(--ifm-badge-border-width) solid var(--ifm-badge-border-color);border-radius:var(--ifm-badge-border-radius);color:var(--ifm-badge-color);font-weight:var(--ifm-font-weight-bold);line-height:1;padding:var(--ifm-badge-padding-vertical) var(--ifm-badge-padding-horizontal)}.badge--primary{--ifm-badge-background-color:var(--ifm-color-primary)}.badge--secondary{--ifm-badge-background-color:var(--ifm-color-secondary);color:var(--ifm-color-black)}.breadcrumbs__link,.button.button--secondary.button--outline:not(.button--active):not(:hover){color:var(--ifm-font-color-base)}.badge--success{--ifm-badge-background-color:var(--ifm-color-success)}.badge--info{--ifm-badge-background-color:var(--ifm-color-info)}.badge--warning{--ifm-badge-background-color:var(--ifm-color-warning)}.badge--danger{--ifm-badge-background-color:var(--ifm-color-danger)}.breadcrumbs{margin-bottom:0;padding-left:0}.breadcrumbs__item:not(:last-child):after{background:var(--ifm-breadcrumb-separator) center;content:" ";display:inline-block;filter:var(--ifm-breadcrumb-separator-filter);height:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier));margin:0 var(--ifm-breadcrumb-spacing);opacity:.5;width:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier))}.breadcrumbs__item--active .breadcrumbs__link{background:var(--ifm-breadcrumb-item-background-active);color:var(--ifm-breadcrumb-color-active)}.breadcrumbs__link{border-radius:var(--ifm-breadcrumb-border-radius);font-size:calc(1rem*var(--ifm-breadcrumb-size-multiplier));padding:calc(var(--ifm-breadcrumb-padding-vertical)*var(--ifm-breadcrumb-size-multiplier)) calc(var(--ifm-breadcrumb-padding-horizontal)*var(--ifm-breadcrumb-size-multiplier));transition-duration:var(--ifm-transition-fast);transition-property:background,color}.breadcrumbs__link:any-link:hover,.breadcrumbs__link:link:hover,.breadcrumbs__link:visited:hover,area[href].breadcrumbs__link:hover{background:var(--ifm-breadcrumb-item-background-active);-webkit-text-decoration:none;text-decoration:none}.breadcrumbs--sm{--ifm-breadcrumb-size-multiplier:0.8}.breadcrumbs--lg{--ifm-breadcrumb-size-multiplier:1.2}.button{background-color:var(--ifm-button-background-color);border:var(--ifm-button-border-width) solid var(--ifm-button-border-color);border-radius:var(--ifm-button-border-radius);cursor:pointer;font-size:calc(.875rem*var(--ifm-button-size-multiplier));font-weight:var(--ifm-button-font-weight);line-height:1.5;padding:calc(var(--ifm-button-padding-vertical)*var(--ifm-button-size-multiplier)) calc(var(--ifm-button-padding-horizontal)*var(--ifm-button-size-multiplier));text-align:center;transition-duration:var(--ifm-button-transition-duration);transition-property:color,background,border-color;-webkit-user-select:none;user-select:none;white-space:nowrap}#apitable-c-macros td:first-child,.apitable-build-environment-variables td:nth-child(-n+2),.apitable-build-options td:nth-child(-n+2),.dropdown{vertical-align:top}.button,.button:hover{color:var(--ifm-button-color)}#casts-types-list li>code,#supported-compilers>h4>code,.button--link,.collection-methods>h4>code,.tom-column-types>h4>code{color:var(--ifm-link-color)}.button--outline{--ifm-button-color:var(--ifm-button-border-color)}.button--outline:hover{--ifm-button-background-color:var(--ifm-button-border-color)}.button--link{--ifm-button-border-color:#0000;text-decoration:var(--ifm-link-decoration)}.button--link.button--active,.button--link:active,.button--link:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.DocSearch-Container a,.dropdown__link--active,.dropdown__link:hover,.hash-link:active,.hash-link:hover,.menu__link:hover,.navbar__brand:hover,.navbar__link--active,.navbar__link:hover,.pagination-nav__link:hover,.pagination__link:hover,.tag_zVej:hover{-webkit-text-decoration:none;text-decoration:none}.button.disabled,.button:disabled,.button[disabled]{opacity:.65;pointer-events:none}.button--sm{--ifm-button-size-multiplier:0.8}.button--lg{--ifm-button-size-multiplier:1.35}.button--block{display:block;width:100%}.button.button--secondary{color:var(--ifm-color-gray-900)}:where(.button--primary){--ifm-button-background-color:var(--ifm-color-primary);--ifm-button-border-color:var(--ifm-color-primary)}:where(.button--primary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-primary-dark);--ifm-button-border-color:var(--ifm-color-primary-dark)}.button--primary.button--active,.button--primary:active{--ifm-button-background-color:var(--ifm-color-primary-darker);--ifm-button-border-color:var(--ifm-color-primary-darker)}:where(.button--secondary){--ifm-button-background-color:var(--ifm-color-secondary);--ifm-button-border-color:var(--ifm-color-secondary)}:where(.button--secondary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-secondary-dark);--ifm-button-border-color:var(--ifm-color-secondary-dark)}.button--secondary.button--active,.button--secondary:active{--ifm-button-background-color:var(--ifm-color-secondary-darker);--ifm-button-border-color:var(--ifm-color-secondary-darker)}:where(.button--success){--ifm-button-background-color:var(--ifm-color-success);--ifm-button-border-color:var(--ifm-color-success)}:where(.button--success):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-success-dark);--ifm-button-border-color:var(--ifm-color-success-dark)}.button--success.button--active,.button--success:active{--ifm-button-background-color:var(--ifm-color-success-darker);--ifm-button-border-color:var(--ifm-color-success-darker)}:where(.button--info){--ifm-button-background-color:var(--ifm-color-info);--ifm-button-border-color:var(--ifm-color-info)}:where(.button--info):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-info-dark);--ifm-button-border-color:var(--ifm-color-info-dark)}.button--info.button--active,.button--info:active{--ifm-button-background-color:var(--ifm-color-info-darker);--ifm-button-border-color:var(--ifm-color-info-darker)}:where(.button--warning){--ifm-button-background-color:var(--ifm-color-warning);--ifm-button-border-color:var(--ifm-color-warning)}:where(.button--warning):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-warning-dark);--ifm-button-border-color:var(--ifm-color-warning-dark)}.button--warning.button--active,.button--warning:active{--ifm-button-background-color:var(--ifm-color-warning-darker);--ifm-button-border-color:var(--ifm-color-warning-darker)}:where(.button--danger){--ifm-button-background-color:var(--ifm-color-danger);--ifm-button-border-color:var(--ifm-color-danger)}:where(.button--danger):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-danger-dark);--ifm-button-border-color:var(--ifm-color-danger-dark)}.button--danger.button--active,.button--danger:active{--ifm-button-background-color:var(--ifm-color-danger-darker);--ifm-button-border-color:var(--ifm-color-danger-darker)}.button-group{display:inline-flex;gap:var(--ifm-button-group-spacing)}.button-group>.button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.button-group>.button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.button-group--block{display:flex;justify-content:stretch}.button-group--block>.button{flex-grow:1}.card{background-color:var(--ifm-card-background-color);border-radius:var(--ifm-card-border-radius);box-shadow:var(--ifm-global-shadow-lw);display:flex;flex-direction:column;overflow:hidden}.card__image{padding-top:var(--ifm-card-vertical-spacing)}.card__image:first-child{padding-top:0}.card__body,.card__footer,.card__header{padding:var(--ifm-card-vertical-spacing) var(--ifm-card-horizontal-spacing)}.card__body:not(:last-child),.card__footer:not(:last-child),.card__header:not(:last-child){padding-bottom:0}.card__body>:last-child,.card__footer>:last-child,.card__header>:last-child{margin-bottom:0}.card__footer{margin-top:auto}#databases-supported-versions ul ul,.dropdown__link{margin-top:.2rem}.table-of-contents{margin-bottom:0;padding:var(--ifm-toc-padding-vertical) 0}.table-of-contents,.table-of-contents ul{list-style:none;padding-left:var(--ifm-toc-padding-horizontal)}.table-of-contents li{margin:var(--ifm-toc-padding-vertical) var(--ifm-toc-padding-horizontal)}.table-of-contents__left-border{border-left:1px solid var(--ifm-toc-border-color)}.table-of-contents__link{color:var(--ifm-toc-link-color);display:block}.table-of-contents__link--active,.table-of-contents__link--active code,.table-of-contents__link:hover,.table-of-contents__link:hover code{color:var(--ifm-color-primary);-webkit-text-decoration:none;text-decoration:none}.close{color:var(--ifm-color-black);float:right;font-size:1.5rem;font-weight:var(--ifm-font-weight-bold);line-height:1;opacity:.5;padding:1rem;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.close:hover{opacity:.7}.close:focus,.theme-code-block-highlighted-line .codeLineNumber_Tfdd:before{opacity:.8}.dropdown{display:inline-flex;font-weight:var(--ifm-dropdown-font-weight);position:relative}.dropdown--hoverable:hover .dropdown__menu,.dropdown--show .dropdown__menu{opacity:1;pointer-events:all;transform:translateY(-1px);visibility:visible}#nprogress,.dropdown__menu,.navbar__item.dropdown .navbar__link:not([href]){pointer-events:none}.dropdown--right .dropdown__menu{left:inherit;right:0}.dropdown--nocaret .navbar__link:after{content:none!important}.dropdown__menu{background-color:var(--ifm-dropdown-background-color);border-radius:var(--ifm-global-radius);box-shadow:var(--ifm-global-shadow-md);left:0;list-style:none;max-height:80vh;min-width:10rem;opacity:0;overflow-y:auto;padding:.5rem;position:absolute;top:calc(100% - var(--ifm-navbar-item-padding-vertical) + .3rem);transform:translateY(-.625rem);transition-duration:var(--ifm-transition-fast);transition-property:opacity,transform,visibility;transition-timing-function:var(--ifm-transition-timing-default);visibility:hidden;z-index:var(--ifm-z-index-dropdown)}.menu__caret,.menu__link,.menu__list-item-collapsible{border-radius:.25rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.dropdown__link{border-radius:.25rem;color:var(--ifm-dropdown-link-color);display:block;font-size:.875rem;padding:.25rem .5rem;white-space:nowrap}.dropdown__link--active,.dropdown__link:hover{background-color:var(--ifm-dropdown-hover-background-color);color:var(--ifm-dropdown-link-color)}.dropdown__link--active,.dropdown__link--active:hover{--ifm-dropdown-link-color:var(--ifm-link-color)}.dropdown>.navbar__link:after{border-color:currentcolor #0000;border-style:solid;border-width:.4em .4em 0;content:"";margin-left:.3em;position:relative;top:2px;transform:translateY(-50%)}.footer{background-color:var(--ifm-footer-background-color);color:var(--ifm-footer-color);padding:var(--ifm-footer-padding-vertical) var(--ifm-footer-padding-horizontal)}.footer--dark{--ifm-footer-background-color:#303846;--ifm-footer-color:var(--ifm-footer-link-color);--ifm-footer-link-color:var(--ifm-color-secondary);--ifm-footer-title-color:var(--ifm-color-white)}.footer__links{margin-bottom:1rem}.footer__link-item{color:var(--ifm-footer-link-color);line-height:2}.footer__link-item:hover{color:var(--ifm-footer-link-hover-color)}.footer__link-separator{margin:0 var(--ifm-footer-link-horizontal-spacing)}.footer__logo{margin-top:1rem;max-width:var(--ifm-footer-logo-max-width)}.footer__title{color:var(--ifm-footer-title-color);font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base);margin-bottom:var(--ifm-heading-margin-bottom)}.menu,.navbar__link{font-weight:var(--ifm-font-weight-semibold)}.docItemContainer_Djhp article>:first-child,.docItemContainer_Djhp header+*,.footer__item{margin-top:0}.admonitionContent_BuS1>:last-child,.api-stability p,.collapsibleContent_i85q p:last-child,.details_lb9f>summary>p:last-child,.footer__items,.markdown h1+ul li li:last-child ul,.tabItem_Ymn6>:last-child{margin-bottom:0}.codeBlockStandalone_MEMb,[type=checkbox]{padding:0}.hero{align-items:center;background-color:var(--ifm-hero-background-color);color:var(--ifm-hero-text-color);display:flex;padding:4rem 2rem}.hero--primary{--ifm-hero-background-color:var(--ifm-color-primary);--ifm-hero-text-color:var(--ifm-font-color-base-inverse)}.hero--dark{--ifm-hero-background-color:#303846;--ifm-hero-text-color:var(--ifm-color-white)}.hero__title{font-size:3rem}.hero__subtitle{font-size:1.5rem}.menu__list{list-style:none;margin:0;padding-left:0}.menu__caret,.menu__link{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu__list .menu__list{flex:0 0 100%;margin-top:.25rem;padding-left:var(--ifm-menu-link-padding-horizontal)}.menu__list-item:not(:first-child){margin-top:.25rem}.menu__list-item--collapsed .menu__list{height:0;overflow:hidden}.details_lb9f[data-collapsed=false].isBrowser_bmU9>summary:before,.details_lb9f[open]:not(.isBrowser_bmU9)>summary:before,.menu__list-item--collapsed .menu__caret:before,.menu__list-item--collapsed .menu__link--sublist:after{transform:rotate(90deg)}.menu__list-item-collapsible{display:flex;flex-wrap:wrap;position:relative}.menu__caret:hover,.menu__link:hover,.menu__list-item-collapsible--active,.menu__list-item-collapsible:hover{background:var(--ifm-menu-color-background-hover)}.menu__list-item-collapsible .menu__link--active,.menu__list-item-collapsible .menu__link:hover{background:none!important}.menu__caret,.menu__link{align-items:center;display:flex}.navbar-sidebar,.navbar-sidebar__backdrop{bottom:0;opacity:0;transition-duration:var(--ifm-transition-fast);transition-timing-function:ease-in-out;left:0;top:0;visibility:hidden}.menu__link{color:var(--ifm-menu-color);flex:1;line-height:1.25}.menu__link:hover{color:var(--ifm-menu-color)}.menu__caret:before,.menu__link--sublist-caret:after{height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast) linear;width:1.25rem;filter:var(--ifm-menu-link-sublist-icon-filter);content:""}.menu__link--sublist-caret:after{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem;margin-left:auto;min-width:1.25rem}.menu__link--active,.menu__link--active:hover{color:var(--ifm-menu-color-active)}.navbar__brand,.navbar__link{color:var(--ifm-navbar-link-color)}.menu__link--active:not(.menu__link--sublist){background-color:var(--ifm-menu-color-background-active)}.menu__caret:before{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem}.navbar--dark,html[data-theme=dark]{--ifm-menu-link-sublist-icon-filter:invert(100%) sepia(94%) saturate(17%) hue-rotate(223deg) brightness(104%) contrast(98%)}.navbar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-navbar-shadow);height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar,.navbar>.container,.navbar>.container-fluid{display:flex}.navbar--fixed-top{position:sticky;top:0;z-index:var(--ifm-z-index-fixed)}.navbar__inner{display:flex;flex-wrap:wrap;justify-content:space-between;width:100%}.navbar__brand{align-items:center;display:flex;margin-right:1rem;min-width:0}.navbar__brand:hover{color:var(--ifm-navbar-link-hover-color)}.announcementBarContent_xLdY,.navbar__title{flex:1 1 auto}.navbar__toggle{display:none;margin-right:.5rem}.navbar__logo{flex:0 0 auto;height:2rem;margin-right:.5rem}.navbar__items{align-items:center;display:flex;flex:1;min-width:0}.navbar__items--center{flex:0 0 auto}.navbar__items--center .navbar__brand{margin:0}.navbar__items--center+.navbar__items--right{flex:1}.navbar__items--right{flex:0 0 auto;justify-content:flex-end}.navbar__items--right>:last-child{padding-right:0}.navbar__item{display:inline-block;padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.navbar__link--active,.navbar__link:hover{color:var(--ifm-navbar-link-hover-color)}.navbar--dark,.navbar--primary{--ifm-menu-color:var(--ifm-color-gray-300);--ifm-navbar-link-color:var(--ifm-color-gray-100);--ifm-navbar-search-input-background-color:#ffffff1a;--ifm-navbar-search-input-placeholder-color:#ffffff80;color:var(--ifm-color-white)}.navbar--dark{--ifm-navbar-background-color:#242526;--ifm-menu-color-background-active:#ffffff0d;--ifm-navbar-search-input-color:var(--ifm-color-white)}.navbar--primary{--ifm-navbar-background-color:var(--ifm-color-primary);--ifm-navbar-link-hover-color:var(--ifm-color-white);--ifm-menu-color-active:var(--ifm-color-white);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-500)}.navbar__search-input{appearance:none;background:var(--ifm-navbar-search-input-background-color) var(--ifm-navbar-search-input-icon) no-repeat .75rem center/1rem 1rem;border:none;border-radius:2rem;color:var(--ifm-navbar-search-input-color);cursor:text;display:inline-block;font-size:1rem;height:2rem;padding:0 .5rem 0 2.25rem;width:12.5rem}.navbar__search-input::placeholder{color:var(--ifm-navbar-search-input-placeholder-color)}.navbar-sidebar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-global-shadow-md);position:fixed;transform:translate3d(-100%,0,0);transition-property:opacity,visibility,transform;width:var(--ifm-navbar-sidebar-width)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar__items{transform:translateZ(0)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar--show .navbar-sidebar__backdrop{opacity:1;visibility:visible}.navbar-sidebar__backdrop{background-color:#0009;position:fixed;right:0;transition-property:opacity,visibility}.navbar-sidebar__brand{align-items:center;box-shadow:var(--ifm-navbar-shadow);display:flex;flex:1;height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar-sidebar__items{display:flex;height:calc(100% - var(--ifm-navbar-height));transition:transform var(--ifm-transition-fast) ease-in-out}.navbar-sidebar__items--show-secondary{transform:translate3d(calc((var(--ifm-navbar-sidebar-width))*-1),0,0)}.navbar-sidebar__item{flex-shrink:0;padding:.5rem;width:calc(var(--ifm-navbar-sidebar-width))}.navbar-sidebar__back{background:var(--ifm-menu-color-background-active);font-size:15px;font-weight:var(--ifm-button-font-weight);margin:0 0 .2rem -.5rem;padding:.6rem 1.5rem;position:relative;text-align:left;top:-.5rem;width:calc(100% + 1rem)}.navbar-sidebar__close{display:flex;margin-left:auto}.pagination{column-gap:var(--ifm-pagination-page-spacing);display:flex;font-size:var(--ifm-pagination-font-size);padding-left:0}.pagination--sm{--ifm-pagination-font-size:0.8rem;--ifm-pagination-padding-horizontal:0.8rem;--ifm-pagination-padding-vertical:0.2rem}.pagination--lg{--ifm-pagination-font-size:1.2rem;--ifm-pagination-padding-horizontal:1.2rem;--ifm-pagination-padding-vertical:0.3rem}.pagination__item{display:inline-flex}.pagination__item>span{padding:var(--ifm-pagination-padding-vertical)}.pagination__item--active .pagination__link{color:var(--ifm-pagination-color-active)}.hash-link:link,.hash-link:visited,.markdown h1+ul li a:before{color:var(--ifm-color-info-darker)}.pagination__item--active .pagination__link,.pagination__item:not(.pagination__item--active):hover .pagination__link{background:var(--ifm-pagination-item-active-background)}.pagination__item--disabled,.pagination__item[disabled]{opacity:.25;pointer-events:none}.pagination__link{border-radius:var(--ifm-pagination-border-radius);color:var(--ifm-font-color-base);display:inline-block;padding:var(--ifm-pagination-padding-vertical) var(--ifm-pagination-padding-horizontal);transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav{display:grid;grid-gap:var(--ifm-spacing-horizontal);gap:var(--ifm-spacing-horizontal);grid-template-columns:repeat(2,1fr)}.pagination-nav__link{border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-pagination-nav-border-radius);display:block;height:100%;line-height:var(--ifm-heading-line-height);padding:var(--ifm-global-spacing);transition:border-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav__link:hover{border-color:var(--ifm-pagination-nav-color-hover)}.pagination-nav__link--next{grid-column:2/3;text-align:right}.pagination-nav__label{font-size:var(--ifm-h4-font-size);font-weight:var(--ifm-heading-font-weight);word-break:break-word}.pagination-nav__link--prev .pagination-nav__label:before{content:"« "}.pagination-nav__link--next .pagination-nav__label:after{content:" »"}.pagination-nav__sublabel{color:var(--ifm-color-content-secondary);font-size:var(--ifm-h5-font-size);font-weight:var(--ifm-font-weight-semibold);margin-bottom:.25rem}.pills__item,.tabs{font-weight:var(--ifm-font-weight-bold)}.pills{display:flex;gap:var(--ifm-pills-spacing);padding-left:0}.pills__item{border-radius:.5rem;cursor:pointer;display:inline-block;padding:.25rem 1rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs,:not(.containsTaskList_mC6p>li)>.containsTaskList_mC6p{padding-left:0}.pills__item--active{color:var(--ifm-pills-color-active)}.pills__item--active,.pills__item:not(.pills__item--active):hover{background:var(--ifm-pills-color-background-active)}.pills--block{justify-content:stretch}.pills--block .pills__item{flex-grow:1;text-align:center}.tabs{color:var(--ifm-tabs-color);display:flex;margin-bottom:0;overflow-x:auto}.tabs__item{border-bottom:3px solid #0000;border-radius:var(--ifm-global-radius);cursor:pointer;display:inline-flex;padding:var(--ifm-tabs-padding-vertical) var(--ifm-tabs-padding-horizontal);transition:background-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs__item--active{border-bottom-color:var(--ifm-tabs-color-active-border);border-bottom-left-radius:0;border-bottom-right-radius:0;color:var(--ifm-tabs-color-active)}.tabs__item:hover{background-color:var(--ifm-hover-overlay)}.tabs--block{justify-content:stretch}.tabs--block .tabs__item{flex-grow:1;justify-content:center}html[data-theme=dark]{--ifm-color-scheme:dark;--ifm-color-emphasis-0:var(--ifm-color-gray-1000);--ifm-color-emphasis-100:var(--ifm-color-gray-900);--ifm-color-emphasis-200:var(--ifm-color-gray-800);--ifm-color-emphasis-300:var(--ifm-color-gray-700);--ifm-color-emphasis-400:var(--ifm-color-gray-600);--ifm-color-emphasis-600:var(--ifm-color-gray-400);--ifm-color-emphasis-700:var(--ifm-color-gray-300);--ifm-color-emphasis-800:var(--ifm-color-gray-200);--ifm-color-emphasis-900:var(--ifm-color-gray-100);--ifm-color-emphasis-1000:var(--ifm-color-gray-0);--ifm-background-color:#1b1b1d;--ifm-background-surface-color:#242526;--ifm-hover-overlay:#ffffff0d;--ifm-color-content:#e3e3e3;--ifm-color-content-secondary:#fff;--ifm-breadcrumb-separator-filter:invert(64%) sepia(11%) saturate(0%) hue-rotate(149deg) brightness(99%) contrast(95%);--ifm-code-background:#ffffff1a;--ifm-scrollbar-track-background-color:#444;--ifm-scrollbar-thumb-background-color:#686868;--ifm-scrollbar-thumb-hover-background-color:#7a7a7a;--ifm-table-stripe-background:#ffffff12;--ifm-toc-border-color:var(--ifm-color-emphasis-200);--ifm-color-primary-contrast-background:#102445;--ifm-color-primary-contrast-foreground:#ebf2fc;--ifm-color-secondary-contrast-background:#474748;--ifm-color-secondary-contrast-foreground:#fdfdfe;--ifm-color-success-contrast-background:#003100;--ifm-color-success-contrast-foreground:#e6f6e6;--ifm-color-info-contrast-background:#193c47;--ifm-color-info-contrast-foreground:#eef9fd;--ifm-color-warning-contrast-background:#4d3800;--ifm-color-warning-contrast-foreground:#fff8e6;--ifm-color-danger-contrast-background:#4b1113;--ifm-color-danger-contrast-foreground:#ffebec;--docsearch-text-color:#f5f6f7;--docsearch-container-background:#090a11cc;--docsearch-modal-background:#15172a;--docsearch-modal-shadow:inset 1px 1px 0 0 #2c2e40,0 3px 8px 0 #000309;--docsearch-searchbox-background:#090a11;--docsearch-searchbox-focus-background:#000;--docsearch-hit-color:#bec3c9;--docsearch-hit-shadow:none;--docsearch-hit-background:#090a11;--docsearch-key-gradient:linear-gradient(-26.5deg,#565872,#31355b);--docsearch-key-shadow:inset 0 -2px 0 0 #282d55,inset 0 0 1px 1px #51577d,0 2px 2px 0 #0304094d;--docsearch-key-pressed-shadow:inset 0 -2px 0 0 #282d55,inset 0 0 1px 1px #51577d,0 1px 1px 0 rgba(3,4,9,.302);--docsearch-footer-background:#1e2136;--docsearch-footer-shadow:inset 0 1px 0 0 #494c6a80,0 -4px 8px 0 #0003;--docsearch-logo-color:#fff;--docsearch-muted-color:#7f8497}#nprogress .bar{background:var(--docusaurus-progress-bar-color);height:2px;left:0;position:fixed;top:0;width:100%;z-index:1031}#nprogress .peg{box-shadow:0 0 10px var(--docusaurus-progress-bar-color),0 0 5px var(--docusaurus-progress-bar-color);height:100%;opacity:1;position:absolute;right:0;transform:rotate(3deg) translateY(-4px);width:100px}[data-theme=dark]:root{--ifm-background-color:#0d1117;--ifm-background-surface-color:#161b22;--ifm-toc-border-color:#30363d;--ifm-code-background:#ffffff26;--docusaurus-highlighted-code-line-bg:#30323f;--ifm-footer-background-color:var(--ifm-background-color);--docsearch-key-gradient:linear-gradient(-26.5deg,var(--ifm-color-emphasis-200) 0%,var(--ifm-color-emphasis-100) 100%);--docsearch-text-color:var(--ifm-color-emphasis-700);--docusaurus-collapse-button-bg:#ffffff0d;--docusaurus-collapse-button-bg-hover:#ffffff1a}.darker{color:#888}[data-theme=dark] ::-webkit-scrollbar{background-color:#222526;height:14px;width:14px}[data-theme=dark] ::-webkit-scrollbar-thumb{background-color:#555;border-radius:2px}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background-color:#777}[data-theme=dark] body{scrollbar-color:#777 #222526!important;scrollbar-width:14px}h1{--ifm-h1-font-size:2.1rem!important;font-size:var(--ifm-h1-font-size)}.header-github-link:before{background:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E") no-repeat;content:"";display:flex;height:24px;width:24px}[data-theme=dark] .header-github-link:before{background:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E") no-repeat}.menu__link{font-size:.9rem}.menu__list-item .menu__list-item{padding-left:1.3rem}.markdown h1+ul,.markdown h1+ul ul{list-style-type:none}.markdown h1+ul li a{font-weight:700}.markdown h1+ul li li a{font-weight:400}.markdown h1+ul li a:before{content:"# ";font-size:90%}.markdown h1+ul li li a:before{font-size:80%}.markdown h1+ul ul ul{margin-bottom:-.25rem;padding-left:1rem}#databases-supported-versions ul ul li a,.markdown h1+ul li li li a{font-size:95%}.footer{padding-bottom:.8rem;padding-top:.4rem}#databases-supported-versions ul ul li{font-size:90%;line-height:1.35}.docusaurus-highlight-code-line{background-color:#0000001a;display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}html[data-theme=dark] .docusaurus-highlight-code-line{background-color:#0000004d}html[data-theme=dark] .prism-code{background-color:#20222b!important}img.no-blurry{will-change:transform}.prism-code .token{font-style:inherit!important}.table-of-contents{font-size:.7rem}main>.container>.row>.col:last-child>div[class^=tableOfContents_]{transition:top .2s}nav[class*=navbarHidden_]~.main-wrapper main>.container>.row>.col:last-child>div[class^=tableOfContents_]{top:1rem}#apitable-dropping-indexes th:last-child{width:50%}#apitable-dropping-indexes td:first-child{font-size:90%;overflow-wrap:anywhere}#tinyorm-configuration,.tiny-tree{position:relative}.tiny-root-folder-info-wrapper{left:15px;position:absolute;top:13px;z-index:10}.tiny-root-folder-info-wrapper .tiny-root-folder-info-prefix{color:var(--ifm-color-warning-lighter)}html[data-theme=dark] .tiny-root-folder-info-wrapper .tiny-root-folder-info-prefix{color:var(--ifm-color-warning-lightest)}.api-stability{margin:0 0 1rem}.collection-methods-list>p,.tom-column-types-list>p{column-count:3;column-gap:2em}.collection-methods-list a,.tom-column-types-list a{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#supported-compilers>h4,.collection-methods>h4,.loader_vvXV,.tom-column-types>h4{margin-top:2rem}#supported-compilers{margin-bottom:2rem}#casts-types-list{font-size:92%}#tinyorm-configuration form{position:absolute;right:0;top:1em}#tinyorm-configuration label{color:#bbb;font-family:var(--ifm-font-family-base);font-size:.7rem;vertical-align:text-bottom}#tinyorm-configuration>div:last-child{display:none}.apiTable_flxF{font-size:94%}.apiTable_flxF tbody tr{transition:box-shadow .2s}.apiTable_flxF tbody tr:focus,.apiTable_flxF tbody tr:hover{box-shadow:0 0 4.5px 0 inset var(--ifm-color-warning);cursor:pointer;outline:0;transition:box-shadow .1s}.tag_zVej{border:1px solid var(--docusaurus-tag-list-border);transition:border var(--ifm-transition-fast)}.tag_zVej:hover{--docusaurus-tag-list-border:var(--ifm-link-color)}.tagRegular_sFm0{border-radius:var(--ifm-global-radius);font-size:90%;padding:.2rem .5rem .3rem}.tagWithCount_h2kH{align-items:center;border-left:0;display:flex;padding:0 .5rem 0 1rem;position:relative}.tagWithCount_h2kH:after,.tagWithCount_h2kH:before{border:1px solid var(--docusaurus-tag-list-border);content:"";position:absolute;top:50%;transition:inherit}.tagWithCount_h2kH:before{border-bottom:0;border-right:0;height:1.18rem;right:100%;transform:translate(50%,-50%) rotate(-45deg);width:1.18rem}.tagWithCount_h2kH:after{border-radius:50%;height:.5rem;left:0;transform:translateY(-50%);width:.5rem}.tagWithCount_h2kH span{background:var(--ifm-color-secondary);border-radius:var(--ifm-global-radius);color:var(--ifm-color-black);font-size:.7rem;line-height:1.2;margin-left:.3rem;padding:.1rem .4rem}.tags_jXut{display:inline}.tag_QGVx{display:inline-block;margin:0 .4rem .5rem 0}.iconEdit_Z9Sw{margin-right:.3em;vertical-align:sub}.lastUpdated_JAkA{font-size:smaller;font-style:italic;margin-top:.2rem}.tocCollapsibleButton_TO0P{align-items:center;display:flex;font-size:inherit;justify-content:space-between;padding:.4rem .8rem;width:100%}.DocSearch-Button,.DocSearch-Button-Container{align-items:center;display:flex}.tocCollapsibleButton_TO0P:after{background:var(--ifm-menu-link-sublist-icon) 50% 50%/2rem 2rem no-repeat;content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast);width:1.25rem}.tocCollapsibleButtonExpanded_MG3E:after,.tocCollapsibleExpanded_sAul{transform:none}.tocCollapsible_ETCw{background-color:var(--ifm-menu-color-background-active);border-radius:var(--ifm-global-radius);margin:1rem 0}.tocCollapsibleContent_vkbj>ul{border-left:none;border-top:1px solid var(--ifm-color-emphasis-300);font-size:15px;padding:.2rem 0}.tocCollapsibleContent_vkbj ul li{margin:.4rem .8rem}.tocCollapsibleContent_vkbj a{display:block}.tableOfContents_bqdL{max-height:calc(100vh - var(--ifm-navbar-height) - 2rem);overflow-y:auto;position:sticky;top:calc(var(--ifm-navbar-height) + 1rem)}.backToTopButton_sjWU{background-color:var(--ifm-color-emphasis-200);border-radius:50%;bottom:1.3rem;box-shadow:var(--ifm-global-shadow-lw);height:3rem;opacity:0;position:fixed;right:1.3rem;transform:scale(0);transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default);visibility:hidden;width:3rem;z-index:calc(var(--ifm-z-index-fixed) - 1)}.backToTopButton_sjWU:after{background-color:var(--ifm-color-emphasis-1000);content:" ";display:inline-block;height:100%;-webkit-mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;width:100%}.backToTopButtonShow_xfvO{opacity:1;transform:scale(1);visibility:visible}.DocSearch-Button{background:var(--docsearch-searchbox-background);border:0;border-radius:40px;color:var(--docsearch-muted-color);cursor:pointer;font-weight:500;height:36px;justify-content:space-between;padding:0 8px;-webkit-user-select:none;user-select:none}.DocSearch-Button:active,.DocSearch-Button:focus,.DocSearch-Button:hover{background:var(--docsearch-searchbox-focus-background);box-shadow:var(--docsearch-searchbox-shadow);color:var(--docsearch-text-color);outline:0}.DocSearch-Search-Icon{stroke-width:1.6}.DocSearch-Hit-Tree,.DocSearch-Hit-action,.DocSearch-Hit-icon,.DocSearch-Reset{stroke-width:var(--docsearch-icon-stroke-width)}.DocSearch-Button .DocSearch-Search-Icon{color:var(--docsearch-text-color)}.DocSearch-Button-Placeholder{font-size:1rem;padding:0 12px 0 6px}.DocSearch-Button-Keys{display:flex;min-width:calc(40px + .8em)}.DocSearch-Button-Key{align-items:center;background:var(--docsearch-key-gradient);border:0;border-radius:3px;box-shadow:var(--docsearch-key-shadow);color:var(--docsearch-muted-color);display:flex;height:18px;justify-content:center;margin-right:.4em;padding:0 0 2px;position:relative;top:-1px;width:20px}.DocSearch-Button-Key--pressed{box-shadow:var(--docsearch-key-pressed-shadow);transform:translate3d(0,1px,0)}.DocSearch--active{overflow:hidden!important}.DocSearch-Container{background-color:var(--docsearch-container-background);height:100vh;left:0;position:fixed;top:0;width:100vw;z-index:200}.DocSearch-Hit[aria-selected=true] mark,.DocSearch-Prefill:focus,.DocSearch-Prefill:hover,.content_knG7 a{-webkit-text-decoration:underline;text-decoration:underline}.DocSearch-Link{appearance:none;background:none;border:0;color:var(--docsearch-highlight-color);cursor:pointer;font:inherit;margin:0;padding:0}.DocSearch-Modal{background:var(--docsearch-modal-background);border-radius:6px;box-shadow:var(--docsearch-modal-shadow);flex-direction:column;margin:60px auto auto;max-width:var(--docsearch-modal-width);position:relative}.DocSearch-SearchBar{display:flex;padding:var(--docsearch-spacing) var(--docsearch-spacing) 0}.DocSearch-Form{align-items:center;background:var(--docsearch-searchbox-focus-background);border-radius:4px;box-shadow:var(--docsearch-searchbox-shadow);display:flex;height:var(--docsearch-searchbox-height);margin:0;padding:0 var(--docsearch-spacing);position:relative;width:100%}.DocSearch-Input{appearance:none;background:#0000;border:0;color:var(--docsearch-text-color);flex:1;font:inherit;font-size:1.2em;height:100%;outline:0;padding:0 0 0 8px;width:80%}.DocSearch-Input::placeholder{color:var(--docsearch-muted-color);opacity:1}.DocSearch-Input::-webkit-search-cancel-button,.DocSearch-Input::-webkit-search-decoration,.DocSearch-Input::-webkit-search-results-button,.DocSearch-Input::-webkit-search-results-decoration{display:none}.DocSearch-LoadingIndicator,.DocSearch-MagnifierLabel,.DocSearch-Reset{margin:0;padding:0}.DocSearch-Container--Stalled .DocSearch-LoadingIndicator,.DocSearch-MagnifierLabel,.DocSearch-Reset{align-items:center;color:var(--docsearch-highlight-color);display:flex;justify-content:center}.DocSearch-Cancel,.DocSearch-Container--Stalled .DocSearch-MagnifierLabel,.DocSearch-LoadingIndicator,.DocSearch-Reset[hidden]{display:none}.DocSearch-Reset{animation:.1s ease-in forwards a;appearance:none;background:none;border:0;border-radius:50%;color:var(--docsearch-icon-color);cursor:pointer;padding:2px;right:0}.DocSearch-Help,.DocSearch-HitsFooter,.DocSearch-Label{color:var(--docsearch-muted-color)}.DocSearch-Reset:hover{color:var(--docsearch-highlight-color)}.DocSearch-LoadingIndicator svg,.DocSearch-MagnifierLabel svg{height:24px;width:24px}.DocSearch-Dropdown{max-height:calc(var(--docsearch-modal-height) - var(--docsearch-searchbox-height) - var(--docsearch-spacing) - var(--docsearch-footer-height));min-height:var(--docsearch-spacing);overflow-y:auto;overflow-y:overlay;padding:0 var(--docsearch-spacing);scrollbar-color:var(--docsearch-muted-color) var(--docsearch-modal-background);scrollbar-width:thin}.DocSearch-Dropdown::-webkit-scrollbar{width:12px}.DocSearch-Dropdown::-webkit-scrollbar-track{background:#0000}.DocSearch-Dropdown::-webkit-scrollbar-thumb{background-color:var(--docsearch-muted-color);border:3px solid var(--docsearch-modal-background);border-radius:20px}.DocSearch-Dropdown ul{list-style:none;margin:0;padding:0}.DocSearch-Label{font-size:.75em;line-height:1.6em}.DocSearch-Help{font-size:.9em;margin:0;-webkit-user-select:none;user-select:none}.DocSearch-Title{font-size:1.2em}.DocSearch-Logo a{display:flex}.DocSearch-Logo svg{color:var(--docsearch-logo-color);margin-left:8px}.DocSearch-Hits:last-of-type{margin-bottom:24px}.DocSearch-Hits mark{background:none;color:var(--docsearch-highlight-color)}.DocSearch-HitsFooter{display:flex;font-size:.85em;justify-content:center;margin-bottom:var(--docsearch-spacing);padding:var(--docsearch-spacing)}.DocSearch-HitsFooter a{border-bottom:1px solid;color:inherit}.DocSearch-Hit{border-radius:4px;display:flex;padding-bottom:4px;position:relative}.DocSearch-Hit--deleting{opacity:0;transition:.25s linear}.DocSearch-Hit--favoriting{transform:scale(0);transform-origin:top center;transition:.25s linear .25s}.DocSearch-Hit a{background:var(--docsearch-hit-background);border-radius:4px;box-shadow:var(--docsearch-hit-shadow);display:block;padding-left:var(--docsearch-spacing);width:100%}.DocSearch-Hit-source{background:var(--docsearch-modal-background);color:var(--docsearch-highlight-color);font-size:.85em;font-weight:600;line-height:32px;margin:0 -4px;padding:8px 4px 0;position:sticky;top:0;z-index:10}.DocSearch-Hit-Tree{color:var(--docsearch-muted-color);height:var(--docsearch-hit-height);opacity:.5;width:24px}.DocSearch-Hit[aria-selected=true] a{background-color:var(--docsearch-highlight-color)}.DocSearch-Hit-Container{align-items:center;color:var(--docsearch-hit-color);display:flex;flex-direction:row;height:var(--docsearch-hit-height);padding:0 var(--docsearch-spacing) 0 0}.DocSearch-Hit-icon{height:20px;width:20px}.DocSearch-Hit-action,.DocSearch-Hit-icon{color:var(--docsearch-muted-color)}.DocSearch-Hit-action{align-items:center;display:flex;height:22px;width:22px}.DocSearch-Hit-action svg{display:block;height:18px;width:18px}.DocSearch-Hit-action+.DocSearch-Hit-action{margin-left:6px}.DocSearch-Hit-action-button{appearance:none;background:none;border:0;border-radius:50%;color:inherit;cursor:pointer;padding:2px}#__docusaurus-base-url-issue-banner-container,.docSidebarContainer_YfHR,.navbarSearchContainer_Bca1:empty,.sidebarLogo_isFc,.themedComponent_mlkZ,[data-theme=dark] .lightToggleIcon_pyhR,[data-theme=light] .darkToggleIcon_wfgR,html[data-announcement-bar-initially-dismissed=true] .announcementBar_mb4j,svg.DocSearch-Hit-Select-Icon{display:none}.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-Select-Icon{display:block}.DocSearch-Hit-action-button:focus,.DocSearch-Hit-action-button:hover{background:#0003;transition:background-color .1s ease-in}.DocSearch-Hit-action-button:focus path,.DocSearch-Hit-action-button:hover path{fill:#fff}.DocSearch-Hit-content-wrapper{display:flex;flex:1 1 auto;flex-direction:column;font-weight:500;justify-content:center;line-height:1.2em;margin:0 8px;overflow-x:hidden;position:relative;text-overflow:ellipsis;white-space:nowrap;width:80%}.DocSearch-Hit-title{font-size:.9em}.DocSearch-Hit-path{color:var(--docsearch-muted-color);font-size:.75em}.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-Tree,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-action,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-icon,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-path,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-text,.DocSearch-Hit[aria-selected=true] .DocSearch-Hit-title,.DocSearch-Hit[aria-selected=true] mark{color:var(--docsearch-hit-active-color)!important}.DocSearch-ErrorScreen,.DocSearch-NoResults,.DocSearch-StartScreen{font-size:.9em;margin:0 auto;padding:36px 0;text-align:center;width:80%}.DocSearch-Screen-Icon{color:var(--docsearch-muted-color);padding-bottom:12px}.DocSearch-NoResults-Prefill-List{display:inline-block;padding-bottom:24px;text-align:left}.DocSearch-NoResults-Prefill-List ul{display:inline-block;padding:8px 0 0}.DocSearch-NoResults-Prefill-List li{list-style-position:inside;list-style-type:"» "}.DocSearch-Prefill{appearance:none;background:none;border:0;border-radius:1em;color:var(--docsearch-highlight-color);cursor:pointer;display:inline-block;font-size:1em;font-weight:700;padding:0}.DocSearch-Prefill:focus,.DocSearch-Prefill:hover{outline:0}.DocSearch-Footer{align-items:center;background:var(--docsearch-footer-background);border-radius:0 0 8px 8px;box-shadow:var(--docsearch-footer-shadow);display:flex;flex-direction:row-reverse;flex-shrink:0;height:var(--docsearch-footer-height);justify-content:space-between;padding:0 var(--docsearch-spacing);position:relative;-webkit-user-select:none;user-select:none;width:100%;z-index:300}.DocSearch-Commands{color:var(--docsearch-muted-color);display:flex;list-style:none;margin:0;padding:0}.DocSearch-Commands li{align-items:center;display:flex}.DocSearch-Commands li:not(:last-of-type){margin-right:.8em}.DocSearch-Commands-Key{align-items:center;background:var(--docsearch-key-gradient);border:0;border-radius:2px;box-shadow:var(--docsearch-key-shadow);color:var(--docsearch-muted-color);display:flex;height:18px;justify-content:center;margin-right:.4em;padding:0 0 1px;width:20px}.buttonGroup__atx button,.codeBlockContainer_Ckt0{background:var(--prism-background-color);color:var(--prism-color)}.DocSearch-VisuallyHiddenForAccessibility{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}@keyframes a{0%{opacity:0}to{opacity:1}}.DocSearch-Button{margin:0;transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.DocSearch-Container{z-index:calc(var(--ifm-z-index-fixed) + 1)}.codeBlockContainer_Ckt0{border-radius:var(--ifm-code-border-radius);box-shadow:var(--ifm-global-shadow-lw);margin-bottom:var(--ifm-leading)}.codeBlockContent_biex{border-radius:inherit;direction:ltr;position:relative}.codeBlockTitle_Ktv7{border-bottom:1px solid var(--ifm-color-emphasis-300);border-top-left-radius:inherit;border-top-right-radius:inherit;font-size:var(--ifm-code-font-size);font-weight:500;padding:.75rem var(--ifm-pre-padding)}.codeBlock_bY9V{--ifm-pre-background:var(--prism-background-color);margin:0;padding:0}.codeBlockTitle_Ktv7+.codeBlockContent_biex .codeBlock_bY9V{border-top-left-radius:0;border-top-right-radius:0}.codeBlockLines_e6Vv{float:left;font:inherit;min-width:100%;padding:var(--ifm-pre-padding)}.codeBlockLinesWithNumbering_o6Pm{display:table;padding:var(--ifm-pre-padding) 0}.buttonGroup__atx{column-gap:.2rem;display:flex;position:absolute;right:calc(var(--ifm-pre-padding)/2);top:calc(var(--ifm-pre-padding)/2)}.buttonGroup__atx button{align-items:center;border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-global-radius);display:flex;line-height:0;opacity:0;padding:.4rem;transition:opacity var(--ifm-transition-fast) ease-in-out}.buttonGroup__atx button:focus-visible,.buttonGroup__atx button:hover{opacity:1!important}.theme-code-block:hover .buttonGroup__atx button{opacity:.4}:where(:root){--docusaurus-highlighted-code-line-bg:#484d5b}:where([data-theme=dark]){--docusaurus-highlighted-code-line-bg:#646464}.theme-code-block-highlighted-line{background-color:var(--docusaurus-highlighted-code-line-bg);display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}.codeLine_lJS_{counter-increment:a;display:table-row}.codeLineNumber_Tfdd{background:var(--ifm-pre-background);display:table-cell;left:0;overflow-wrap:normal;padding:0 var(--ifm-pre-padding);position:sticky;text-align:right;width:1%}.codeLineNumber_Tfdd:before{content:counter(a);opacity:.4}.codeLineContent_feaV{padding-right:var(--ifm-pre-padding)}.theme-code-block:hover .copyButtonCopied_obH4{opacity:1!important}.copyButtonIcons_eSgA{height:1.125rem;position:relative;width:1.125rem}.copyButtonIcon_y97N,.copyButtonSuccessIcon_LjdS{left:0;position:absolute;top:0;fill:currentColor;height:inherit;opacity:inherit;transition:all var(--ifm-transition-fast) ease;width:inherit}.copyButtonSuccessIcon_LjdS{color:#00d600;left:50%;opacity:0;top:50%;transform:translate(-50%,-50%) scale(.33)}.copyButtonCopied_obH4 .copyButtonIcon_y97N{opacity:0;transform:scale(.33)}.copyButtonCopied_obH4 .copyButtonSuccessIcon_LjdS{opacity:1;transform:translate(-50%,-50%) scale(1);transition-delay:75ms}.wordWrapButtonIcon_Bwma{height:1.2rem;width:1.2rem}.rootFolderInput_ottS{left:13px;position:absolute;top:56px;z-index:10}.rootFolderInput_ottS .input_OR7e{background-color:#ffffff1f;border-color:#303436;width:16rem}.rootFolderInput_ottS.application_fjej{left:48px;top:87px}.input_OR7e{border-color:var(--ifm-color-content-secondary);border-radius:2px;border-style:solid;border-width:var(--ifm-global-border-width);font-size:calc(var(--ifm-font-size-base)/1.1);padding:.2rem .4rem}.input_OR7e.application_fjej{width:14rem}.skipToContent_fXgn{background-color:var(--ifm-background-surface-color);color:var(--ifm-color-emphasis-900);left:100%;padding:calc(var(--ifm-global-spacing)/2) var(--ifm-global-spacing);position:fixed;top:1rem;z-index:calc(var(--ifm-z-index-fixed) + 1)}.skipToContent_fXgn:focus{box-shadow:var(--ifm-global-shadow-md);left:1rem}.closeButton_CVFx{line-height:0;padding:0}.content_knG7{font-size:85%;padding:5px 0;text-align:center}.content_knG7 a{color:inherit}.announcementBar_mb4j{align-items:center;background-color:var(--ifm-color-white);border-bottom:1px solid var(--ifm-color-emphasis-100);color:var(--ifm-color-black);display:flex;height:var(--docusaurus-announcement-bar-height)}.announcementBarPlaceholder_vyr4{flex:0 0 10px}.announcementBarClose_gvF7{align-self:stretch;flex:0 0 30px}.toggle_vylO{height:2rem;width:2rem}.toggleButton_gllP{align-items:center;border-radius:50%;display:flex;height:100%;justify-content:center;transition:background var(--ifm-transition-fast);width:100%}.toggleButton_gllP:hover{background:var(--ifm-color-emphasis-200)}.toggleButtonDisabled_aARS{cursor:not-allowed}.darkNavbarColorModeToggle_X3D1:hover{background:var(--ifm-color-gray-800)}[data-theme=dark] .themedComponent--dark_xIcU,[data-theme=light] .themedComponent--light_NVdE,html:not([data-theme]) .themedComponent--light_NVdE{display:initial}.collapseSidebarButton_PEFL{display:none;margin:0}.iconExternalLink_nPIU{margin-left:.3rem}.docMainContainer_TBSr,.docRoot_UBD9{display:flex;width:100%}.docsWrapper_hBAB{display:flex;flex:1 0 auto}.dropdownNavbarItemMobile_S0Fm{cursor:pointer}.iconLanguage_nlXk{margin-right:5px;vertical-align:text-bottom}.navbarHideable_m1mJ{transition:transform var(--ifm-transition-fast) ease}.navbarHidden_jGov{transform:translate3d(0,calc(-100% - 2px),0)}.errorBoundaryError_a6uf{color:red;white-space:pre-wrap}.errorBoundaryFallback_VBag{color:red;padding:.55rem}.footerLogoLink_BH7S{opacity:.5;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.footerLogoLink_BH7S:hover,.hash-link:focus,:hover>.hash-link{opacity:1}body:not(.navigation-with-keyboard) :not(input):focus{outline:0}.anchorWithStickyNavbar_LWe7{scroll-margin-top:calc(var(--ifm-navbar-height) + .5rem)}.anchorWithHideOnScrollNavbar_WYt5{scroll-margin-top:.5rem}.hash-link{opacity:0;padding-left:.5rem;transition:opacity var(--ifm-transition-fast);-webkit-user-select:none;user-select:none}.hash-link:before{content:"#"}.mainWrapper_z2l0{display:flex;flex:1 0 auto;flex-direction:column}.docusaurus-mt-lg{margin-top:3rem}#__docusaurus{display:flex;flex-direction:column;min-height:100%}.details_lb9f{--docusaurus-details-summary-arrow-size:0.38rem;--docusaurus-details-transition:transform 200ms ease;--docusaurus-details-decoration-color:grey}.details_lb9f>summary{cursor:pointer;list-style:none;padding-left:1rem;position:relative}.details_lb9f>summary::-webkit-details-marker{display:none}.details_lb9f>summary:before{border-color:#0000 #0000 #0000 var(--docusaurus-details-decoration-color);border-style:solid;border-width:var(--docusaurus-details-summary-arrow-size);content:"";left:0;position:absolute;top:.45rem;transform:rotate(0);transform-origin:calc(var(--docusaurus-details-summary-arrow-size)/2) 50%;transition:var(--docusaurus-details-transition)}.collapsibleContent_i85q{border-top:1px solid var(--docusaurus-details-decoration-color);margin-top:1rem;padding-top:1rem}.details_b_Ee{--docusaurus-details-decoration-color:var(--ifm-alert-border-color);--docusaurus-details-transition:transform var(--ifm-transition-fast) ease;border:1px solid var(--ifm-alert-border-color);margin:0 0 var(--ifm-spacing-vertical)}.containsTaskList_mC6p{list-style:none}.img_ev3q{height:auto}.admonition_xJq3{margin-bottom:1em}.admonitionHeading_Gvgb{font:var(--ifm-heading-font-weight) var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family)}.admonitionHeading_Gvgb:not(:last-child){margin-bottom:.3rem}.admonitionHeading_Gvgb code{text-transform:none}.admonitionIcon_Rf37{display:inline-block;margin-right:.4em;vertical-align:middle}.admonitionIcon_Rf37 svg{display:inline-block;height:1.6em;width:1.6em;fill:var(--ifm-alert-foreground-color)}.breadcrumbHomeIcon_YNFT{height:1.1rem;position:relative;top:1px;vertical-align:top;width:1.1rem}.breadcrumbsContainer_Z_bl{--ifm-breadcrumb-size-multiplier:0.8;margin-bottom:.8rem}.searchQueryInput_u2C7,.searchVersionInput_m0Ui{background:var(--docsearch-searchbox-focus-background);border:2px solid var(--ifm-toc-border-color);border-radius:var(--ifm-global-radius);color:var(--docsearch-text-color);font:var(--ifm-font-size-base) var(--ifm-font-family-base);margin-bottom:.5rem;padding:.8rem;transition:border var(--ifm-transition-fast) ease;width:100%}.searchQueryInput_u2C7:focus,.searchVersionInput_m0Ui:focus{border-color:var(--docsearch-primary-color);outline:0}.searchQueryInput_u2C7::placeholder{color:var(--docsearch-muted-color)}.searchResultsColumn_JPFH{font-size:.9rem;font-weight:700}.algoliaLogo_rT1R{max-width:150px}.algoliaLogoPathFill_WdUC{fill:var(--ifm-font-color-base)}.searchResultItem_Tv2o{border-bottom:1px solid var(--ifm-toc-border-color);padding:1rem 0}.searchResultItemHeading_KbCB{font-weight:400;margin-bottom:0}.searchResultItemPath_lhe1{color:var(--ifm-color-content-secondary);font-size:.8rem;--ifm-breadcrumb-separator-size-multiplier:1}.searchResultItemSummary_AEaO{font-style:italic;margin:.5rem 0 0}.loadingSpinner_XVxU{animation:1s linear infinite b;border:.4em solid #eee;border-radius:50%;border-top:.4em solid var(--ifm-color-primary);height:3rem;margin:0 auto;width:3rem}@keyframes b{to{transform:rotate(1turn)}}.search-result-match{background:#ffd78e40;color:var(--docsearch-hit-color);padding:.09em 0}@media (min-width:997px){.collapseSidebarButton_PEFL,.expandButton_TmdG{background-color:var(--docusaurus-collapse-button-bg)}.lastUpdated_JAkA{text-align:right}.tocMobile_ITEo{display:none}:root{--docusaurus-announcement-bar-height:30px}.announcementBarClose_gvF7,.announcementBarPlaceholder_vyr4{flex-basis:50px}.collapseSidebarButton_PEFL{border:1px solid var(--ifm-toc-border-color);border-radius:0;bottom:0;display:block!important;height:40px;position:sticky}.collapseSidebarButtonIcon_kv0_{margin-top:4px;transform:rotate(180deg)}.expandButtonIcon_i1dp,[dir=rtl] .collapseSidebarButtonIcon_kv0_{transform:rotate(0)}.collapseSidebarButton_PEFL:focus,.collapseSidebarButton_PEFL:hover,.expandButton_TmdG:focus,.expandButton_TmdG:hover{background-color:var(--docusaurus-collapse-button-bg-hover)}.menuHtmlItem_M9Kj{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu_SIkG{flex-grow:1;padding:.5rem}@supports (scrollbar-gutter:stable){.menu_SIkG{padding:.5rem 0 .5rem .5rem;scrollbar-gutter:stable}}.menuWithAnnouncementBar_GW3s{margin-bottom:var(--docusaurus-announcement-bar-height)}.sidebar_njMd{display:flex;flex-direction:column;height:100%;padding-top:var(--ifm-navbar-height);width:var(--doc-sidebar-width)}.sidebarWithHideableNavbar_wUlq{padding-top:0}.sidebarHidden_VK0M{opacity:0;visibility:hidden}.sidebarLogo_isFc{align-items:center;color:inherit!important;display:flex!important;margin:0 var(--ifm-navbar-padding-horizontal);max-height:var(--ifm-navbar-height);min-height:var(--ifm-navbar-height);-webkit-text-decoration:none!important;text-decoration:none!important}.sidebarLogo_isFc img{height:2rem;margin-right:.5rem}.expandButton_TmdG{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;transition:background-color var(--ifm-transition-fast) ease;width:100%}[dir=rtl] .expandButtonIcon_i1dp{transform:rotate(180deg)}.docSidebarContainer_YfHR{border-right:1px solid var(--ifm-toc-border-color);clip-path:inset(0);display:block;margin-top:calc(var(--ifm-navbar-height)*-1);transition:width var(--ifm-transition-fast) ease;width:var(--doc-sidebar-width);will-change:width}.docSidebarContainerHidden_DPk8{cursor:pointer;width:var(--doc-sidebar-hidden-width)}.sidebarViewport_aRkj{height:100%;max-height:100vh;position:sticky;top:0}.docMainContainer_TBSr{flex-grow:1;max-width:calc(100% - var(--doc-sidebar-width))}.docMainContainerEnhanced_lQrH{max-width:calc(100% - var(--doc-sidebar-hidden-width))}.docItemWrapperEnhanced_JWYK{max-width:calc(var(--ifm-container-width) + var(--doc-sidebar-width))!important}.navbarSearchContainer_Bca1{padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.docItemCol_VOVn{max-width:75%!important}}@media (min-width:1440px){.container{max-width:var(--ifm-container-width-xl)}}@media (max-width:996px){.col{--ifm-col-width:100%;flex-basis:var(--ifm-col-width);margin-left:0}.footer{--ifm-footer-padding-horizontal:0}.colorModeToggle_DEke,.footer__link-separator,.navbar__item,.tableOfContents_bqdL{display:none}.footer__col{margin-bottom:calc(var(--ifm-spacing-vertical)*3)}.footer__link-item{display:block}.hero{padding-left:0;padding-right:0}.navbar>.container,.navbar>.container-fluid{padding:0}.navbar__toggle{display:inherit}.navbar__search-input{width:9rem}.pills--block,.tabs--block{flex-direction:column}.docItemContainer_F8PC{padding:0 .3rem}.navbarSearchContainer_Bca1{position:absolute;right:var(--ifm-navbar-padding-horizontal)}}@media only screen and (max-width:996px){.searchQueryColumn_RTkw,.searchResultsColumn_JPFH{max-width:60%!important}.searchLogoColumn_rJIA,.searchVersionColumn_ypXd{max-width:40%!important}.searchLogoColumn_rJIA{padding-left:0!important}}@media (max-width:768px){.DocSearch-Button-Keys,.DocSearch-Button-Placeholder,.DocSearch-Commands,.DocSearch-Hit-Tree{display:none}:root{--docsearch-spacing:10px;--docsearch-footer-height:40px}.DocSearch-Dropdown{height:100%;max-height:calc(var(--docsearch-vh,1vh)*100 - var(--docsearch-searchbox-height) - var(--docsearch-spacing) - var(--docsearch-footer-height))}.DocSearch-Container{height:100vh;height:-webkit-fill-available;height:calc(var(--docsearch-vh,1vh)*100);position:absolute}.DocSearch-Footer{border-radius:0;bottom:0;position:absolute}.DocSearch-Hit-content-wrapper{display:flex;position:relative;width:80%}.DocSearch-Modal{border-radius:0;box-shadow:none;height:100vh;height:-webkit-fill-available;height:calc(var(--docsearch-vh,1vh)*100);margin:0;max-width:100%;width:100%}.DocSearch-Cancel{appearance:none;background:none;border:0;color:var(--docsearch-highlight-color);cursor:pointer;display:inline-block;flex:none;font:inherit;font-size:1em;font-weight:500;margin-left:var(--docsearch-spacing);outline:0;overflow:hidden;padding:0;-webkit-user-select:none;user-select:none;white-space:nowrap}}@media screen and (max-width:768px){:root{--ifm-menu-link-padding-vertical:0.5rem;--ifm-list-item-margin:0.5rem}.menu__link{font-size:1.1rem}.markdown h1+ul li:first-child{margin-top:.25rem}.markdown h1+ul ul ul{margin-bottom:0}.markdown h1+ul li li li:first-child{margin-top:.5rem}}@media (max-width:576px){.markdown h1:first-child{--ifm-h1-font-size:2rem}.markdown>h2{--ifm-h2-font-size:1.5rem}.markdown>h3{--ifm-h3-font-size:1.25rem}}@media screen and (max-width:576px){.searchQueryColumn_RTkw{max-width:100%!important}.searchVersionColumn_ypXd{max-width:100%!important;padding-left:var(--ifm-spacing-horizontal)!important}}@media screen and (max-width:480px){.collection-methods-list>p,.tom-column-types-list>p{column-count:2}}@media (hover:hover){.backToTopButton_sjWU:hover{background-color:var(--ifm-color-emphasis-300)}}@media (pointer:fine){.thin-scrollbar,[data-theme=dark] .thin-scrollbar{scrollbar-width:thin}.thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}.thin-scrollbar::-webkit-scrollbar-track{background:var(--ifm-scrollbar-track-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb{background:var(--ifm-scrollbar-thumb-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb:hover{background:var(--ifm-scrollbar-thumb-hover-background-color)}[data-theme=dark] .thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}}@media (prefers-reduced-motion:reduce){:root{--ifm-transition-fast:0ms;--ifm-transition-slow:0ms}}@media screen and (prefers-reduced-motion:reduce){.DocSearch-Reset{animation:none;appearance:none;background:none;border:0;border-radius:50%;color:var(--docsearch-icon-color);cursor:pointer;right:0;stroke-width:var(--docsearch-icon-stroke-width)}.DocSearch-Hit--deleting,.DocSearch-Hit--favoriting{transition:none}.DocSearch-Hit-action-button:focus,.DocSearch-Hit-action-button:hover{background:#0003;transition:none}}@media print{.announcementBar_mb4j,.footer,.menu,.navbar,.pagination-nav,.table-of-contents,.tocMobile_ITEo{display:none}.tabs{page-break-inside:avoid}.codeBlockLines_e6Vv{white-space:pre-wrap}} \ No newline at end of file diff --git a/assets/js/0ab078a9.06fcc850.js b/assets/js/0ab078a9.06fcc850.js deleted file mode 100644 index 08467c099..000000000 --- a/assets/js/0ab078a9.06fcc850.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[395],{1503:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>O,contentTitle:()=>_,default:()=>M,frontMatter:()=>T,metadata:()=>v,toc:()=>R});var s=i(4848),d=i(8453),r=i(8774),l=i(6684),c=i(2364),t=i(9365),o=i(1470),a=i(5556),h=i.n(a),x=i(6694);function j(e){let{groupId:n}=e;return(0,s.jsx)("span",{children:(0,x.OZ)(n)})}j.propTypes={groupId:h().string.isRequired};const u=j;var p=i(4164),m=i(6362);const b={rootFolderInput:"rootFolderInput_ottS",input:"input_OR7e",application:"application_fjej"};function f(e){let{groupId:n,label:i}=e;const{rootFolder:d,setRootFolder:r}=(0,m.A)(),l=(0,x.T3)(n),c=l?"application":"root",t=l?"\nThis folder name is common for all shells (eg. pwsh, bash, ...)":"";return(0,s.jsx)("form",{name:"tinyorm-root-folder-form",className:(0,p.A)(b.rootFolderInput,b[n],n),onSubmit:e=>{e.preventDefault(),e.stopPropagation()},children:(0,s.jsx)("input",{name:"tinyorm-root-folder-input",className:(0,p.A)(b.input,b[n],n),placeholder:`Enter ${c} folder...`,title:`This ${c} folder will be used in all ${i} examples at tinyorm.org${t}`,onChange:e=>{r(n,e.target.value)},value:d[n]??(0,x.bw)(n)})})}f.propTypes={groupId:h().string.isRequired,label:h().string.isRequired};const g=f;var y=i(7324);const T={sidebar_position:0,sidebar_label:"TinyORM",hide_table_of_contents:!0,description:"How to compile the TinyORM C++ library on Windows and Linux.",keywords:["c++ orm","building","tinyorm"]},_="Building: TinyORM",v={id:"building/tinyorm",title:"Building: TinyORM",description:"How to compile the TinyORM C++ library on Windows and Linux.",source:"@site/docs/building/tinyorm.mdx",sourceDirName:"building",slug:"/building/tinyorm",permalink:"/building/tinyorm",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"TinyORM",hide_table_of_contents:!0,description:"How to compile the TinyORM C++ library on Windows and Linux.",keywords:["c++ orm","building","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/tinydrivers/getting-started"},next:{title:"Hello world",permalink:"/building/hello-world"}},O={},R=[{value:"Introduction",id:"introduction",level:2},{value:"Common Prerequisites",id:"common-prerequisites",level:4},{value:"Windows Prerequisites",id:"windows-prerequisites",level:4},{value:"Build environment scripts",id:"build-environment-scripts",level:5},{value:"Allow symbolic links unprivileged",id:"allow-symbolic-links-unprivileged",level:5},{value:"Folders structure",id:"folders-structure",level:2},{value:"Getting started",id:"getting-started",level:2},{value:"vcpkg",id:"vcpkg",level:2},{value:"Set up vcpkg environment",id:"set-up-vcpkg-environment",level:4},{value:"C preprocessor macros",id:"c-preprocessor-macros",level:2},{value:"Building with CMake",id:"building-with-cmake",level:2},{value:"Configure & Build (cmake)",id:"configure-and-build-cmake",level:3},{value:"CMake STRICT_MODE option",id:"cmake-strict_mode-option",level:5},{value:"Build TinyORM",id:"build-tinyorm",level:4},{value:"CMake build options",id:"cmake-build-options",level:3},{value:"CMake build environment variables",id:"cmake-build-environment-variables",level:3},{value:"Consume TinyOrm library (cmake)",id:"consume-tinyorm-library-cmake",level:3},{value:"Building with qmake",id:"building-with-qmake",level:2},{value:"Install dependencies",id:"install-dependencies",level:3},{value:"Configure & Build (qmake)",id:"configure-and-build-qmake",level:3},{value:"Open QtCreator IDE",id:"open-qtcreator-ide",level:4},{value:"Configure TinyORM",id:"configure-tinyorm",level:4},{value:"Auto-configuration and tiny_dotenv",id:"auto-configuration-and-tiny_dotenv",level:5},{value:"Manual configuration (conf.pri)",id:"manual-configuration-confpri",level:5},{value:"Opening TinyORM.pro (main project file)",id:"opening-tinyormpro-main-project-file",level:5},{value:"Build TinyORM",id:"build-tinyorm-1",level:4},{value:"qmake build options",id:"qmake-build-options",level:3},{value:"Consume TinyOrm library (qmake)",id:"consume-tinyorm-library-qmake",level:3},{value:"Requirements",id:"requirements",level:4},{value:"QMAKEFEATURES",id:"qmakefeatures",level:5},{value:"Variables affecting TinyOrm.pri",id:"variables-affecting-tinyormpri",level:5},{value:"Manual configuration examples",id:"manual-configuration-examples",level:5},{value:"Auto-configuration internals",id:"auto-configuration-internals",level:3},{value:"Environment files",id:"environment-files",level:4},{value:"Partial guessing of the TINYORM_BUILD_TREE",id:"partial-guessing-of-the-tinyorm_build_tree",level:4},{value:"Manual configuration internals",id:"manual-configuration-internals",level:3},{value:"Ccache support",id:"ccache-support",level:2}];function I(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"building-tinyorm",children:"Building: TinyORM"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#common-prerequisites",children:"Common Prerequisites"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#windows-prerequisites",children:"Windows Prerequisites"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#folders-structure",children:"Folders structure"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#getting-started",children:"Getting started"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#vcpkg",children:"vcpkg"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#c-preprocessor-macros",children:"C preprocessor macros"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#building-with-cmake",children:"Building with CMake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#configure-and-build-cmake",children:"Configure & Build"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-build-options",children:"CMake build options"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-build-environment-variables",children:"CMake build environment variables"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-cmake",children:"Consume TinyOrm library"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#building-with-qmake",children:"Building with qmake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#configure-and-build-qmake",children:"Configure & Build"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#qmake-build-options",children:"qmake build options"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-qmake",children:"Consume TinyOrm library"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:"Auto-configuration internals"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#environment-files",children:"Environment files"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#manual-configuration-internals",children:"Manual configuration internals"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(r.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["The build systems supported out of the box are ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["All examples below assume that ",(0,s.jsx)(n.code,{children:"pwsh"})," runs on ",(0,s.jsx)(n.code,{children:"Windows"})," and ",(0,s.jsx)(n.code,{children:"bash"})," runs on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"common-prerequisites",children:"Common Prerequisites"}),"\n",(0,s.jsxs)(n.p,{children:["Install the required ",(0,s.jsx)(n.a,{href:"/dependencies",children:"dependencies"})," before starting."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"QSqlDatabase"})," depends on ",(0,s.jsx)(n.code,{children:"QCoreApplication"})," from ",(0,s.jsx)(n.code,{children:"Qt v6.5.3"})," so you must create the ",(0,s.jsx)(n.code,{children:"QCoreApplication"})," instance before you will call anything from the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. \ud83e\udee4 The change was made ",(0,s.jsx)(n.a,{href:"https://github.com/qt/qtbase/commit/8d2bdc9cd5482eace12ba7e45304857bd24db0e6#diff-1d355c25c0b0eddec2be48253407780c4dc510d986739aec61e1ec892ccaf86e",children:"here"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"windows-prerequisites",children:"Windows Prerequisites"}),"\n",(0,s.jsx)(n.h5,{id:"build-environment-scripts",children:"Build environment scripts"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Visual Studio"})," does not provide ",(0,s.jsx)(n.code,{children:"vcvars"})," scripts for ",(0,s.jsx)(n.code,{children:"pwsh"}),", you can use ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/tools/vcvars64.ps1",children:(0,s.jsx)(n.code,{children:"vcvars64.ps1"})})," provided by ",(0,s.jsx)(n.code,{children:"TinyORM"})," in the ",(0,s.jsx)(n.code,{children:"tools/"})," folder. Place them on the ",(0,s.jsx)(n.code,{children:"$env:Path"})," user/system path and they will be available system-wide."]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"Qt Framework"}),", it doesn't provide ",(0,s.jsx)(n.code,{children:"qtenv"})," scripts for ",(0,s.jsx)(n.code,{children:"pwsh"})," too. You can create your own script, place it on the ",(0,s.jsx)(n.code,{children:"$env:Path"})," user/system path and it will be available system-wide."]}),"\n",(0,s.jsxs)(n.p,{children:["Here is one simple example for ",(0,s.jsx)(n.code,{children:"pwsh"})," and ",(0,s.jsx)(n.code,{children:"bash"})," on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",metastring:"title='qtenv6.ps1'",children:"#!/usr/bin/env pwsh\n\nSet-StrictMode -Version 3.0\n\nWrite-Host 'Setting up environment for Qt 6.7.2 usage...' -ForegroundColor Magenta\nWrite-Host\n\n$Script:QtRoot = $env:TINY_QT_ROOT ?? 'C:\\Qt'\n\n$env:Path = \"$Script:QtRoot\\6.7.2\\msvc2019_64\\bin;\" + $env:Path\n\n. vcvars64.ps1\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"title='qtenv6'",children:'#!/usr/bin/env sh\n\necho \'Setting up environment for Qt 6.7.2 usage...\'\n\nQtRoot="${TINY_QT_ROOT:-/opt/Qt}"\n\nexport PATH="$QtRoot/6.7.2/gcc_64/bin"${PATH:+:}$PATH\nexport LD_LIBRARY_PATH="$QtRoot/6.7.2/gcc_64/lib"${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH\n'})})})]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["These scripts consider the ",(0,s.jsx)(n.code,{children:"TINY_QT_ROOT"})," environment variable that should point to the ",(0,s.jsx)(n.code,{children:"Qt"})," installation folder, you can define this environment variable globally in your OS."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can't execute these ",(0,s.jsx)(n.code,{children:"qtenvX"})," scripts, they have to be sourced like ",(0,s.jsx)(n.code,{children:"source qtenvX"})," or ",(0,s.jsx)(n.code,{children:". qtenvX"}),"."]})}),"\n",(0,s.jsx)(n.h5,{id:"allow-symbolic-links-unprivileged",children:"Allow symbolic links unprivileged"}),"\n",(0,s.jsxs)(n.p,{children:["Open ",(0,s.jsx)(n.code,{children:"Local Security Policy"}),", go to ",(0,s.jsx)(n.code,{children:"Local Policies - User Rights Assignment"}),", open ",(0,s.jsx)(n.code,{children:"Create symbolic links"})," and add your user account or user group, restart when it doesn't apply immediately."]}),"\n",(0,s.jsx)(n.h2,{id:"folders-structure",children:"Folders structure"}),"\n",(0,s.jsxs)(n.p,{children:["All ",(0,s.jsx)(n.code,{children:"tinyorm.org"})," examples are based on the following folders structure. The ",(0,s.jsx)(n.code,{children:"tom"})," folder will contain a ",(0,s.jsx)(n.a,{href:"/building/migrations",children:"migrations console application"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can set the root and application folder paths in the form below and they will be used across the whole ",(0,s.jsx)(n.a,{href:"http://www.tinyorm.org",children:"www.tinyorm.org"})," website. \ud83e\udd73 The pwsh shell is supposed to use on Windows and the bash shell on Linux, but it is not a requirement."]})}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsxs)(t.A,{value:y.b,label:y.ux,className:"tiny-tree",children:[(0,s.jsx)("div",{className:"tiny-root-folder-info-wrapper",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)("span",{className:"tiny-root-folder-info-prefix",children:"Current pwsh path"}),"\xa0",(0,s.jsx)(u,{groupId:y.b})]})}),(0,s.jsx)(g,{groupId:y.b,label:y.ux}),(0,s.jsx)(g,{groupId:y.pW,label:y.kl}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\n\n\n\u251c\u2500\u2500\n\u2502 \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld-builds-cmake/\n\u2502 | | \u2514\u2500\u2500 build-debug/\n\u2502 | \u2514\u2500\u2500 HelloWorld-builds-qmake/\n\u2502 | \u2514\u2500\u2500 build-debug/\n\u2502 \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM-builds-cmake/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-debug/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-release/\n\u2502 | \u2502 \u2514\u2500\u2500 build-clang-debug/\n\u2502 | \u2514\u2500\u2500 TinyORM-builds-qmake/\n\u2502 | \u251c\u2500\u2500 build-debug/\n\u2502 | \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u2502 | \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_64bit-Release/\n\u2502 \u2514\u2500\u2500 tom/\n\u2502 \u251c\u2500\u2500 tom/\n\u2502 \u2502 \u2514\u2500\u2500 database/\n\u2502 \u2502 \u251c\u2500\u2500 migrations/\n\u2502 \u2502 \u251c\u2500\u2500 seeders/\n\u2502 \u2502 \u251c\u2500\u2500 migrations.pri\n\u2502 \u2502 \u2514\u2500\u2500 seeders.pri\n\u2502 \u251c\u2500\u2500 tom-builds-cmake/\n\u2502 \u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u2502 \u2514\u2500\u2500 tom-builds-qmake/\n\u2502 \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_64bit-Release/\n\u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u251c\u2500\u2500 tmp/\n\u2514\u2500\u2500 vcpkg/\n"})})]}),(0,s.jsxs)(t.A,{value:y.xj,label:y.gg,className:"tiny-tree",children:[(0,s.jsx)("div",{className:"tiny-root-folder-info-wrapper",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)("span",{className:"tiny-root-folder-info-prefix",children:"Current bash path"}),"\xa0",(0,s.jsx)(u,{groupId:y.xj})]})}),(0,s.jsx)(g,{groupId:y.xj,label:y.gg}),(0,s.jsx)(g,{groupId:y.pW,label:y.pW}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\n\n\n\u251c\u2500\u2500\n\u2502 \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld-builds-cmake/\n\u2502 | | \u2514\u2500\u2500 build-debug/\n\u2502 | \u2514\u2500\u2500 HelloWorld-builds-qmake/\n\u2502 | \u2514\u2500\u2500 build-debug/\n\u2502 \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM-builds-cmake/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-debug/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-release/\n\u2502 | \u2502 \u2514\u2500\u2500 build-clang-debug/\n\u2502 | \u2514\u2500\u2500 TinyORM-builds-qmake/\n\u2502 | \u251c\u2500\u2500 build-debug/\n\u2502 | \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/\n\u2502 | \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Release/\n\u2502 \u2514\u2500\u2500 tom/\n\u2502 \u251c\u2500\u2500 tom/\n\u2502 \u2502 \u2514\u2500\u2500 database/\n\u2502 \u2502 \u251c\u2500\u2500 migrations/\n\u2502 \u2502 \u251c\u2500\u2500 seeders/\n\u2502 \u2502 \u251c\u2500\u2500 migrations.pri\n\u2502 \u2502 \u2514\u2500\u2500 seeders.pri\n\u2502 \u251c\u2500\u2500 tom-builds-cmake/\n\u2502 \u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/\n\u2502 \u2514\u2500\u2500 tom-builds-qmake/\n\u2502 \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/\n\u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Release/\n\u251c\u2500\u2500 tmp/\n\u2514\u2500\u2500 vcpkg/\n"})})]})]}),"\n",(0,s.jsx)(n.admonition,{type:"danger",children:(0,s.jsxs)(n.p,{children:["Avoid paths with spaces with the ",(0,s.jsx)(n.code,{children:"qmake"})," build system, it will not compile."]})}),"\n",(0,s.jsx)(r.A,{id:"qtcreator-default-build-directory"}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described above."]}),(0,s.jsxs)(n.p,{children:["To generate the required folders structure set the ",(0,s.jsx)(n.code,{children:"Settings"})," - ",(0,s.jsx)(n.code,{children:"Build & Run"})," - ",(0,s.jsx)(n.code,{children:"Default Build Properties"})," - ",(0,s.jsx)(n.code,{children:"Default build directory"})," to:",(0,s.jsx)("br",{}),"\n",(0,s.jsx)(n.code,{children:'../%{Project:Name}-builds-%{BuildSystem:Name}/%{JS: Util.asciify("build-%{Project:Name}-%{Kit:FileSystemName}-%{BuildConfig:Name}")}'})]})]}),"\n",(0,s.jsx)(n.h2,{id:"getting-started",children:"Getting started"}),"\n",(0,s.jsxs)(n.p,{children:["Prepare compilation environment, we need to put the Qt Framework and Visual Studio MSVC compiler on the path on Windows. The compiler is already on the path on Linux and you can export ",(0,s.jsx)(n.code,{children:"PATH"})," and ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," for Qt Framework, or use our ",(0,s.jsx)(n.code,{children:"qtenvX"})," scripts described above."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`mkdir ${(0,x.Sn)(y.b)}\ncd ${(0,x.Sn)(y.b)}\n$env:Path = 'C:\\Qt\\6.7.2\\msvc2019_64\\bin;' + $env:Path\nvcvars64.ps1`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`mkdir -p ${(0,x.Sn)(y.xj)}\ncd ${(0,x.Sn)(y.xj)}\nexport PATH=/opt/Qt/6.7.2/gcc_64/bin\${PATH:+:}$PATH\nexport LD_LIBRARY_PATH=/opt/Qt/6.7.2/gcc_64/lib\${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH`})})]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can also use the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tools/Add-FolderOnPath.ps1",children:(0,s.jsx)(n.code,{children:"tools/Add-FolderOnPath.ps1"})})," pwsh script to fastly prepend a path or ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"})," on the system ",(0,s.jsx)(n.code,{children:"PATH"}),"."]})}),"\n",(0,s.jsx)(n.h2,{id:"vcpkg",children:"vcpkg"}),"\n",(0,s.jsxs)(n.p,{children:["Installing the ",(0,s.jsx)(n.code,{children:"vcpkg"})," is highly recommended, it simplifies installation of the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," dependencies."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"git clone git@github.com:microsoft/vcpkg.git\ncd vcpkg\n.\\bootstrap-vcpkg.bat\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"git clone git@github.com:microsoft/vcpkg.git\ncd vcpkg\n./bootstrap-vcpkg.sh\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["Add ",(0,s.jsx)(n.code,{children:"vcpkg"})," on the system path, add the following to the ",(0,s.jsx)(n.code,{children:".bashrc"})," or ",(0,s.jsx)(n.code,{children:".zshrc"})," on Linux."]}),"\n",(0,s.jsx)(c.A,{className:"language-bash",children:`export PATH=${(0,x.Sn)(y.xj)}/vcpkg\${PATH:+:}$PATH`}),"\n",(0,s.jsxs)(n.p,{children:["On Windows, open the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog and add ",(0,s.jsx)(n.code,{children:"vcpkg"})," on the user ",(0,s.jsx)(n.code,{children:"PATH"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Or you can export it for the current session only."}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.Sn)(y.b,!1)}\\vcpkg;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export PATH=${(0,x.Sn)(y.xj)}/vcpkg\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.h4,{id:"set-up-vcpkg-environment",children:["Set up ",(0,s.jsx)(n.code,{children:"vcpkg"})," environment"]}),"\n",(0,s.jsxs)(n.p,{children:["To export ",(0,s.jsx)(n.code,{children:"vcpkg"})," environment variables globally, add it to the ",(0,s.jsx)(n.code,{children:".bashrc"})," or ",(0,s.jsx)(n.code,{children:".zshrc"})," on Linux, and you can use the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog on Windows."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"title='Linux'",children:'export VCPKG_DEFAULT_TRIPLET=x64-linux\n#export VCPKG_DEFAULT_HOST_TRIPLET=x64-linux\nexport VCPKG_MAX_CONCURRENCY=11\nexport VCPKG_OVERLAY_PORTS="$HOME/.local/share/vcpkg/ports"\nexport VCPKG_OVERLAY_TRIPLETS="$HOME/.local/share/vcpkg/triplets"\nexport VCPKG_ROOT="$HOME/Code/c/vcpkg"\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["It is recommended to define these variables globally because the ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"})," build system are able to detect the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation from them so you don't have to configure them manually to detect the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["On Windows, it's always better to create these types of variables as user variables instead of system variables in the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog."]})}),"\n",(0,s.jsx)(n.h2,{id:"c-preprocessor-macros",children:"C preprocessor macros"}),"\n",(0,s.jsxs)(n.p,{children:["The following table summarizes all the C preprocessor macros defined in the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. These C macros are configured by ",(0,s.jsx)(n.code,{children:"CMake"})," or ",(0,s.jsx)(n.code,{children:"qmake"})," build systems. They are not sorted alphabetically, but they are sorted by how significant they are."]}),"\n",(0,s.jsxs)(n.p,{children:["In the ",(0,s.jsx)(n.code,{children:"CMake"})," build system, all the C macros are auto-detected / auto-configured or controlled by ",(0,s.jsx)(n.a,{href:"#cmake-build-options",children:(0,s.jsx)(n.code,{children:"CMake build options"})}),", so you don't have to care too much about them."]}),"\n",(0,s.jsxs)(n.p,{children:["In the ",(0,s.jsx)(n.code,{children:"qmake"})," build is important whether you are building ",(0,s.jsx)(n.code,{children:"TinyORM"})," library or you are building your application and linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. When you are building the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library, all the C macros are auto-detected / auto-configured or controlled by ",(0,s.jsx)(n.a,{href:"#qmake-build-options",children:(0,s.jsx)(n.code,{children:"qmake build options"})}),", so you don't have to care too much about them."]}),"\n",(0,s.jsxs)(n.p,{children:["But a special situation is when you are building your application / library and you are linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. In this particular case, you must configure all these C macros manually! For this reason, the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri",children:(0,s.jsx)(n.code,{children:"TinyOrm.pri"})})," has been created, so that's not a big deal either. Little more info ",(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-qmake",children:"here"}),"."]}),"\n",(0,s.jsx)("div",{id:"apitable-c-macros",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"C Macro Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_LINKING_SHARED"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)("u",{children:(0,s.jsx)(n.strong,{children:"Must"})})," be defined when you are linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," shared build (",(0,s.jsx)(n.code,{children:"dll"})," library), exported classes and functions will be tagged with ",(0,s.jsx)(n.code,{children:"__declspec(dllimport)"})," on ",(0,s.jsx)(n.code,{children:"msvc"})," and ",(0,s.jsx)(n.code,{children:'visibility("default")'})," on ",(0,s.jsx)(n.code,{children:"GCC >= 4"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_BUILDING_SHARED"})}),(0,s.jsxs)(n.td,{children:["Defined when ",(0,s.jsx)(n.code,{children:"TinyORM"})," is built as a ",(0,s.jsx)(n.code,{children:"dll"})," library (shared build)."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DEBUG"})}),(0,s.jsx)(n.td,{children:"Defined in the debug build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_NO_DEBUG"})}),(0,s.jsx)(n.td,{children:"Defined in the release build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DEBUG_SQL"})}),(0,s.jsx)(n.td,{children:"Defined in the debug build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_NO_DEBUG_SQL"})}),(0,s.jsx)(n.td,{children:"Defined in the release build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_MYSQL_PING"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#mysql_ping",children:(0,s.jsx)(n.code,{children:"mysql_ping"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#MYSQL_PING",children:(0,s.jsx)(n.code,{children:"MYSQL_PING"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DISABLE_ORM"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this macro is ",(0,s.jsx)(n.code,{children:"defined"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#disable_orm",children:(0,s.jsx)(n.code,{children:"disable_orm"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#ORM",children:(0,s.jsx)(n.code,{children:"ORM"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled ",(0,s.jsx)("small",{children:"(qmake)"})," / disabled ",(0,s.jsx)("small",{children:"(cmake)"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_EXTERN_CONSTANTS"})}),(0,s.jsxs)(n.td,{children:["Defined when extern constants are used. Extern constants are enabled by default for shared builds and disabled for static builds.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Described at ",(0,s.jsx)(n.a,{href:"#extern_constants",children:(0,s.jsx)(n.code,{children:"qmake"})})," / ",(0,s.jsx)(n.a,{href:"#INLINE_CONSTANTS",children:(0,s.jsx)(n.code,{children:"CMake"})})," how it works."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_INLINE_CONSTANTS"})}),(0,s.jsxs)(n.td,{children:["Defined when global inline constants are used.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#inline_constants",children:(0,s.jsx)(n.code,{children:"inline_constants"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#INLINE_CONSTANTS",children:(0,s.jsx)(n.code,{children:"INLINE_CONSTANTS"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_TESTS_CODE"})}),(0,s.jsxs)(n.td,{children:["Enable code needed by unit tests, eg. connection overriding in the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#build_tests",children:(0,s.jsx)(n.code,{children:"build_tests"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#BUILD_TESTS",children:(0,s.jsx)(n.code,{children:"BUILD_TESTS"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DISABLE_THREAD_LOCAL"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#disable_thread_local",children:(0,s.jsx)(n.code,{children:"disable_thread_local"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#DISABLE_THREAD_LOCAL",children:(0,s.jsx)(n.code,{children:"DISABLE_THREAD_LOCAL"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_MIGRATIONS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default migrations path for the ",(0,s.jsx)(n.code,{children:"make:migration"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/migrations"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_MIGRATIONS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_MIGRATIONS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_MIGRATIONS_DIR="\\"database/migrations\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L65-L70",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_MODELS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default models path for the ",(0,s.jsx)(n.code,{children:"make:model"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/models"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_MODELS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_MODELS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_MODELS_DIR="\\"database/models\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L72-L73",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_SEEDERS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default seeders path for the ",(0,s.jsx)(n.code,{children:"make:seeder"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/seeders"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_SEEDERS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_SEEDERS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_SEEDERS_DIR="\\"database/seeders\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L75-L76",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_USING_PCH"})}),(0,s.jsxs)(n.td,{children:["Defined if building with precompiled headers.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Controlled by ",(0,s.jsx)(n.a,{href:"#qmake-precompile_header",children:(0,s.jsx)(n.code,{children:"qmake"})})," / ",(0,s.jsx)(n.a,{href:"#CMAKE_DISABLE_PRECOMPILE_HEADERS",children:(0,s.jsx)(n.code,{children:"CMake"})}),"."]})]})]})]})]})})}),"\n",(0,s.jsx)(n.h2,{id:"building-with-cmake",children:"Building with CMake"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If something is not clear, you can still look at GitHub Action ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:(0,s.jsx)(n.code,{children:"workflows"})})," how the build is done."]})}),"\n",(0,s.jsxs)(n.p,{children:["First, create a basic folder structure and then clone the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.Sn)(y.b)}\nmkdir ${(0,x.np)()}/TinyORM/TinyORM-builds-cmake/build-debug\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.Sn)(y.xj)}\nmkdir -p ${(0,x.np)()}/TinyORM/TinyORM-builds-cmake/build-debug\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})})]}),"\n",(0,s.jsxs)(n.h3,{id:"configure-and-build-cmake",children:["Configure & Build ",(0,s.jsx)("small",{children:"(cmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd TinyORM-builds-cmake/build-debug\n"})}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,x.OZ)(y.b)}/TinyORM/TinyORM" \`\n-B "${(0,x.OZ)(y.b)}/TinyORM/TinyORM-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,x.Sn)(y.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,x.Sn)(y.b)}/tmp/TinyORM" \`\n-D BUILD_TESTS:BOOL=OFF \`\n-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON \`\n-D MYSQL_PING:BOOL=OFF \`\n-D TOM:BOOL=ON \`\n-D TOM_EXAMPLE:BOOL=OFF \`\n-D VERBOSE_CONFIGURE:BOOL=ON`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cmake \\\n-S "${(0,x.OZ)(y.xj)}/TinyORM/TinyORM" \\\n-B "${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,x.Sn)(y.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,x.Sn)(y.xj)}/tmp/TinyORM" \\\n-D VERBOSE_CONFIGURE:BOOL=ON \\\n-D BUILD_TESTS:BOOL=OFF \\\n-D MYSQL_PING:BOOL=OFF \\\n-D TOM:BOOL=ON \\\n-D TOM_EXAMPLE:BOOL=OFF \\\n-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON`})})]}),"\n",(0,s.jsxs)(n.h5,{id:"cmake-strict_mode-option",children:["CMake ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," option"]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option was added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.38.0"}),". This option was added to avoid the propagation of aggressive strict warning compiler/linker options and Qt definitions from the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library to user code through the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/cmake/CommonModules/TinyCommon.cmake",children:(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})})," interface library."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TinyORM"})," uses the strictest warning level options, virtually anything that can be enabled is enabled to produce a better code. I highly recommend enabling this option to produce better code and to follow good practices. It also helps to follow the ",(0,s.jsx)(n.code,{children:"ISOCPP"})," ",(0,s.jsx)(n.a,{href:"https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines",children:"C++ Core Guidelines"})," standards."]}),"\n",(0,s.jsxs)(n.p,{children:["If you want to enable these strict warning options in your code, you can enable the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option and they will be propagated to your code. You can also enabled it globally using the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable, and the value of this environment variable will be picked up during initial CMake configuration as the default value for the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option."]}),"\n",(0,s.jsxs)(n.p,{children:["You can achieve the same result by manually linking against the ",(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})," interface library when the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," is set to ",(0,s.jsx)(n.code,{children:"OFF"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",children:"target_link_libraries( PRIVATE TinyOrm::CommonConfig)\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The recommended way is to set the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable to ",(0,s.jsx)(n.code,{children:"1"})," or ",(0,s.jsx)(n.code,{children:"ON"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"build-tinyorm",children:"Build TinyORM"}),"\n",(0,s.jsx)(n.p,{children:"And build. You don't have to install it, you can use the build tree directly if you want."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\ncmake --install .\n"})}),"\n",(0,s.jsx)(n.p,{children:"Or build and install in one step."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target install\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["CMake multi-config generators like ",(0,s.jsx)(n.code,{children:"Ninja Multi-Config"})," or ",(0,s.jsx)(n.code,{children:"Visual Studio 16 2019"})," are also supported."]})}),"\n",(0,s.jsx)(n.h3,{id:"cmake-build-options",children:"CMake build options"}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_DRIVERS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"TinyDrivers"})," SQL database drivers (core/common code; replaces QtSql module)."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_MYSQL_DRIVER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," MySQL database driver.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"BUILD_DRIVERS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsx)(n.td,{children:"Build as a shared/static library."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_TESTS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Build TinyORM unit tests."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_TREE_DEPLOY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Copy ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," and ",(0,s.jsx)(n.code,{children:"TinyMySql"})," libraries to the root of the build tree."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"DRIVERS_TYPE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"Shared"})}),(0,s.jsxs)(n.td,{children:["How to build and link against ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," SQL database drivers.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"Static"})," value will be select by default when the ",(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})," is ",(0,s.jsx)(n.code,{children:"OFF"}),".",(0,s.jsx)("br",{}),"Supported values: ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-shared-library-build",children:(0,s.jsx)(n.code,{children:"Shared"})}),", ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-loadable-sql-drivers-build",children:(0,s.jsx)(n.code,{children:"Loadable"})}),", and ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-static-build",children:(0,s.jsx)(n.code,{children:"Static"})}),(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"BUILD_DRIVERS AND BUILD_SHARED_LIBS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"INLINE_CONSTANTS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Use inline constants instead of extern constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"OFF"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"ON"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"MSVC_RUNTIME_DYNAMIC"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Use MSVC dynamic runtime library (",(0,s.jsx)(n.code,{children:"-MD"}),") instead of static (",(0,s.jsx)(n.code,{children:"-MT"}),"), also considers a Debug configuration (",(0,s.jsx)(n.code,{children:"-MTd"}),", ",(0,s.jsx)(n.code,{children:"-MDd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"MSVC AND NOT TINY_VCPKG AND NOT DEFINED VCPKG_CRT_LINKAGE AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"MYSQL_PING"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ORM"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"STRICT_MODE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls propagation of strict compiler/linker options and Qt definitions using the ",(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})," interface library to the user code.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(highly recommended; can also be set with the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable; described ",(0,s.jsx)(n.a,{href:"#cmake-strict_mode-option",children:"here"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"Tom-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then it also excludes ",(0,s.jsx)(n.code,{children:"Tom-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_EXAMPLE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build the ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," console application example."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_MIGRATIONS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default migrations path for the ",(0,s.jsx)(n.code,{children:"make:migration"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/migrations"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_MODELS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default models path for the ",(0,s.jsx)(n.code,{children:"make:model"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/models"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_SEEDERS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default seeders path for the ",(0,s.jsx)(n.code,{children:"make:seeder"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/seeders"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VERBOSE_CONFIGURE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Show information about ",(0,s.jsx)(n.code,{children:"PACKAGES_FOUND"})," / ",(0,s.jsx)(n.code,{children:"PACKAGES_NOT_FOUND"})," in the CMake configure output."]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Advanced ",(0,s.jsx)(n.code,{children:"TinyORM"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"DISABLE_THREAD_LOCAL"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)("small",{children:(0,s.jsx)(n.code,{children:"MATCH_EQUAL_EXPORTED_BUILDTREE"})})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Exported package configuration from the build tree is considered to match only when ",(0,s.jsx)(n.code,{children:"the build type"})," of application/library that is linking against the TinyORM library ",(0,s.jsx)(n.strong,{children:"is equal"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when:",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY AND NOT TINY_IS_MULTI_CONFIG"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Important ",(0,s.jsx)(n.code,{children:"CMake"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_DISABLE_PRECOMPILE_HEADERS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Disable precompiled headers."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"auto"})}),(0,s.jsxs)(n.td,{children:["The full path to the ",(0,s.jsx)(n.code,{children:"C++"})," compiler."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER_LAUNCHER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default compiler launcher to use for the ",(0,s.jsx)(n.code,{children:"C++"})," compiler.",(0,s.jsx)("br",{}),"Can be used to enable ",(0,s.jsx)(n.code,{children:"ccache"}),", eg. ",(0,s.jsx)(n.code,{children:"ccache.exe"})," on ",(0,s.jsx)(n.code,{children:"MinGW"})," or ",(0,s.jsx)(n.code,{children:"/usr/bin/ccache"})," on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable the ",(0,s.jsx)(n.code,{children:"export(TinyOrm)"})," command.",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"TinyORM"})," doesn't set this variable by default. Its initial value is taken from the ",(0,s.jsx)(n.code,{children:"TINYORM_EXPORT_PACKAGE_REGISTRY"})," environment variable if not already defined."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)("small",{children:(0,s.jsx)(n.code,{children:"CMAKE_INTERPROCEDURAL_OPTIMIZATION"})})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Interprocedural_optimization",children:"Link time code optimization"})," (",(0,s.jsx)(n.a,{href:"https://wiki.gentoo.org/wiki/LTO",children:"LTO"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Works on all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_VERBOSE_MAKEFILE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Enable verbose output from Makefile builds."})]})]})]})})}),"\n",(0,s.jsx)(n.h3,{id:"cmake-build-environment-variables",children:"CMake build environment variables"}),"\n",(0,s.jsxs)(n.p,{children:["The following are environment variables that are affecting the ",(0,s.jsx)(n.code,{children:"TinyORM"})," CMake build system."]}),"\n",(0,s.jsxs)(n.p,{children:["These environment variables have lower priority than CMake ",(0,s.jsx)(n.code,{children:"-D"})," compile definitions and they are used if the ",(0,s.jsx)(n.code,{children:"-D"})," compile definitions are not ",(0,s.jsx)(n.code,{children:"DEFINED"}),"."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-environment-variables",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_EXPORT_PACKAGE_REGISTRY"})}),(0,s.jsxs)(n.td,{children:["Environment variable for ",(0,s.jsx)(n.a,{href:"/building/tinyorm#CMAKE_EXPORT_PACKAGE_REGISTRY",children:(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY"})}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})}),(0,s.jsxs)(n.td,{children:["Environment variable for ",(0,s.jsx)(n.a,{href:"/building/tinyorm#STRICT_MODE",children:(0,s.jsx)(n.code,{children:"STRICT_MODE"})})," CMake feature option.",(0,s.jsx)("br",{}),"It's passed as the initial value ",(0,s.jsx)(n.code,{children:"[value]"})," for the CMake ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/command/option.html",children:(0,s.jsx)(n.code,{children:"option"})})," command."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Auto-detect the ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html",children:(0,s.jsx)(n.code,{children:"CMAKE_TOOLCHAIN_FILE"})})," from the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_TOOLCHAIN_FILE"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})}),(0,s.jsxs)(n.td,{children:["Auto-detect the ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html",children:(0,s.jsx)(n.code,{children:"CMAKE_TOOLCHAIN_FILE"})})," from the ",(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})," environment variable. The ",(0,s.jsx)(n.a,{href:"https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md#environment-variables",children:(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})})," environment variable is set on GitHub hosted runners.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_TOOLCHAIN_FILE"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["Default value for the ",(0,s.jsx)(n.a,{href:"https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration#vcpkg_target_triplet",children:(0,s.jsx)(n.code,{children:"VCPKG_TARGET_TRIPLET"})}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED VCPKG_TARGET_TRIPLET"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.h3,{id:"consume-tinyorm-library-cmake",children:["Consume TinyOrm library ",(0,s.jsx)("small",{children:"(cmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["In your application or library ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file add following ",(0,s.jsx)(n.code,{children:"find_package()"})," call."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",metastring:"title='CMakeLists.txt'",children:"find_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["If the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree is not exported to the CMake's ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry",children:(0,s.jsx)(n.code,{children:"User Package Registry"})})," then also add the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree or ",(0,s.jsx)(n.code,{children:"CMAKE_INSTALL_PREFIX"})," folder to the ",(0,s.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"}),", so CMake can find TinyORM's package configuration file during ",(0,s.jsx)(n.code,{children:"find_package(TinyOrm)"})," call."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:`cmake (${y.b})`,children:(0,s.jsx)(c.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.b,(0,x.OZ)(y.b))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\n# installation folder - CMAKE_INSTALL_PREFIX\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.b,(0,x.Sn)(y.b))}/tmp/TinyORM")`})}),(0,s.jsx)(t.A,{value:y.xj,label:`cmake (${y.xj})`,children:(0,s.jsx)(c.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.xj,(0,x.OZ)(y.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\n# installation folder - CMAKE_INSTALL_PREFIX\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.xj,(0,x.Sn)(y.xj))}/tmp/TinyORM")`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Or as an alternative, you can set ",(0,s.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"})," environment variable."]}),"\n",(0,s.jsx)(r.A,{id:"tinyorm-on-path-cmake"}),"\n",(0,s.jsxs)(n.p,{children:["As the last thing, do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so your application can find it during execution."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.OZ)(y.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Now you can try the ",(0,s.jsx)(n.a,{href:"/building/hello-world#hello-world-with-cmake",children:(0,s.jsx)(n.code,{children:"HelloWorld CMake"})})," example."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can also try the ",(0,s.jsx)(n.a,{href:"/building/hello-world#fetchcontent",children:(0,s.jsx)(n.code,{children:"FetchContent"})})," method to fastly link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library."]})}),"\n",(0,s.jsx)(n.h2,{id:"building-with-qmake",children:"Building with qmake"}),"\n",(0,s.jsxs)(n.p,{children:["First, create a basic folder structure and then clone the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.Sn)(y.b)}\nmkdir ${(0,x.np)()}/TinyORM/TinyORM-builds-qmake\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.Sn)(y.xj)}\nmkdir -p ${(0,x.np)()}/TinyORM/TinyORM-builds-qmake\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})})]}),"\n",(0,s.jsx)(n.h3,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.p,{children:["With the ",(0,s.jsx)(n.code,{children:"qmake"})," build system, you have to install ",(0,s.jsx)(n.code,{children:"TinyORM"})," dependencies manually. We will use the ",(0,s.jsx)(n.code,{children:"vcpkg"})," package manager."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,s.jsxs)(n.p,{children:["On ",(0,s.jsx)(n.code,{children:"Linux"}),", you can install the ",(0,s.jsx)(n.code,{children:"range-v3"})," library and some other ",(0,s.jsx)(n.a,{href:"/dependencies#install-dependencies",children:"dependencies"})," with the package manager."]}),"\n",(0,s.jsxs)(n.h3,{id:"configure-and-build-qmake",children:["Configure & Build ",(0,s.jsx)("small",{children:"(qmake)"})]}),"\n",(0,s.jsx)(n.h4,{id:"open-qtcreator-ide",children:"Open QtCreator IDE"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["I recommend creating a new ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qtcreator/creator-project-managing-sessions.html",children:(0,s.jsx)(n.code,{children:"Session"})})," in the ",(0,s.jsx)(n.code,{children:"QtCreator"}),", this way you will have all the examples in one place and as a bonus, everything will be in the same place when you close and reopen ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),". You can name it ",(0,s.jsx)(n.code,{children:"tinyorm.org"})," or ",(0,s.jsx)(n.code,{children:"TinyORM examples"}),", it is up to you."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If you are using sessions, you can use a single ",(0,s.jsx)(n.code,{children:"clangd"})," instance for all projects in this session in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),". One significant advantage of this method is that the ",(0,s.jsx)(n.code,{children:".qtc_clangd/"})," folder will not be created in the build folder, but will be stored globally in the Roaming profile. You can enable it in the ",(0,s.jsx)(n.code,{children:"Settings"})," - ",(0,s.jsx)(n.code,{children:"C++"})," - ",(0,s.jsx)(n.code,{children:"Clangd"})," - ",(0,s.jsx)(n.code,{children:"Sessions with a single clangd instance"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"configure-tinyorm",children:"Configure TinyORM"}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. There are two ways how to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library and it's the new ",(0,s.jsx)(n.code,{children:"Auto-configure"})," feature added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"})," using the ",(0,s.jsx)(n.code,{children:".env"})," files and the old way using the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files."]}),"\n",(0,s.jsx)(n.h5,{id:"auto-configuration-and-tiny_dotenv",children:"Auto-configuration and tiny_dotenv"}),"\n",(0,s.jsxs)(n.p,{children:["This is the new recommended method to auto-configure TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," build system and also the dependencies, it was added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),". You need to copy the prepared ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw).example"})," file to the ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"}),". One ",(0,s.jsx)(n.code,{children:".env"})," example file is prepared for each supported platform."]}),"\n",(0,s.jsxs)(n.p,{children:["All prepared ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw).example"})," files are simple and clear. You can also create a common ",(0,s.jsx)(n.code,{children:".env"})," file that is included before the platform-specific ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," files."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.OZ)(y.b)}/TinyORM/TinyORM\n\ncp .env.win32.example .env.win32`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.OZ)(y.xj)}/TinyORM/TinyORM\n\ncp .env.unix.example .env.unix`})})]}),"\n",(0,s.jsxs)(n.p,{children:["And that is all, if you have correctly set all ",(0,s.jsx)(n.code,{children:"qmake"})," variables in this ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," file or you have correctly set environment variables, then the ",(0,s.jsx)(n.code,{children:"qmake"})," build system should be able to ",(0,s.jsx)(n.code,{children:"auto-detect"})," all dependencies . \ud83d\udd25"]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," and ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"Environment files"})})," internals are described at the end to make this section more clear."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),")."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_dotenv",children:(0,s.jsx)(n.code,{children:"disable_dotenv"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),")."]})}),"\n",(0,s.jsx)(n.h5,{id:"manual-configuration-confpri",children:"Manual configuration (conf.pri)"}),"\n",(0,s.jsxs)(n.p,{children:["This is the old method used before ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),". You need to copy the ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," files to ",(0,s.jsx)(n.code,{children:"conf.pri"})," (there are four, one for every project or sub-project) and manually update the ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," and ",(0,s.jsx)(n.code,{children:"LIBS"})," to configure TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," build dependencies. This way you can override any ",(0,s.jsx)(n.code,{children:"qmake"})," build options or variables."]}),"\n",(0,s.jsxs)(n.p,{children:["To disable the ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," feature you must define the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),") because from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"})," is the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature enabled by default."]}),"\n",(0,s.jsxs)(n.p,{children:["You can also remove all ",(0,s.jsx)(n.code,{children:".env"})," files or turn off the ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature using ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),". You can use them all at once if you want, ",(0,s.jsx)(n.code,{children:".env"})," and also ",(0,s.jsx)(n.code,{children:"conf.pri"})," files."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"conf.pri"})," files are nicely commented on, so you can see what needs to be modified."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.OZ)(y.b)}/TinyORM/TinyORM\n\ncp conf.pri.example conf.pri\ncp tests/conf.pri.example tests/conf.pri\ncp tests/testdata_tom/conf.pri.example tests/testdata_tom/conf.pri\ncp examples/tom/conf.pri.example examples/tom/conf.pri`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.OZ)(y.xj)}/TinyORM/TinyORM\n\ncp conf.pri.example conf.pri\ncp tests/conf.pri.example tests/conf.pri\ncp tests/testdata_tom/conf.pri.example tests/testdata_tom/conf.pri\ncp examples/tom/conf.pri.example examples/tom/conf.pri`})})]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#manual-configuration-internals",children:(0,s.jsx)(n.code,{children:"Manual configuration"})})," internals are described at the end to make this section more clear."]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Manual configuration"})," is still relevant if you have any non-standard installation of the ",(0,s.jsx)(n.code,{children:"vcpkg"})," or ",(0,s.jsx)(n.code,{children:"MySQL"})," and the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature fails."]})}),"\n",(0,s.jsx)(n.h5,{id:"opening-tinyormpro-main-project-file",children:"Opening TinyORM.pro (main project file)"}),"\n",(0,s.jsxs)(n.p,{children:["Now you can open the ",(0,s.jsx)(n.code,{children:"TinyORM.pro"})," project in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This will open the ",(0,s.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,s.jsx)(n.a,{href:"#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,s.jsx)("img",{src:i(885).A,alt:"TinyORM - QtCreator - Configure Project",width:"760"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,s.jsx)(n.a,{href:"#qtcreator-default-build-directory",children:"above"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,s.jsxs)(n.p,{children:["Disable ",(0,s.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,s.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,s.jsx)("img",{src:i(7619).A,alt:"TinyORM - QtCreator - Build Settings",width:"760"}),"\n",(0,s.jsxs)(n.p,{children:["If you want to change some ",(0,s.jsx)(n.code,{children:"TinyORM"})," build options, you can pass them to the ",(0,s.jsx)(n.code,{children:"Build Steps"})," - ",(0,s.jsx)(n.code,{children:"qmake TinyORM.pro"})," - ",(0,s.jsx)(n.code,{children:"Additional arguments"})," input field. It can look like this."]}),"\n",(0,s.jsx)("img",{src:i(2721).A,alt:"TinyORM - QtCreator - Build Settings - Additional arguments",width:"660"}),"\n",(0,s.jsx)(n.h4,{id:"build-tinyorm-1",children:"Build TinyORM"}),"\n",(0,s.jsxs)(n.p,{children:["Everything is ready for build, you can press ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,s.jsx)(n.h3,{id:"qmake-build-options",children:"qmake build options"}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.th,{children:[(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)("small",{children:"Option Name"})]}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_loadable_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started",children:(0,s.jsx)(n.code,{children:"TinyDrivers"})})," as a shared library and SQL database drivers (eg. ",(0,s.jsx)(n.code,{children:"TinyMySql"}),") as shared libraries (",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-loadable-sql-drivers-build",children:(0,s.jsx)(n.code,{children:"Loadable"})})," modules) that are loaded at runtime using ",(0,s.jsx)(n.code,{children:"LoadLibrary()"})," on Windows or ",(0,s.jsx)(n.code,{children:"dlopen()"})," on Linux."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_mysql_driver"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," MySQL database driver.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It's enabled by default when ",(0,s.jsx)(n.code,{children:"build_shared_drivers"}),", ",(0,s.jsx)(n.code,{children:"build_loadable_drivers"}),", or ",(0,s.jsx)(n.code,{children:"build_static_drivers"})," is enabled.",(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"build_shared_drivers"})," OR ",(0,s.jsx)(n.code,{children:"build_loadable_drivers"})," OR ",(0,s.jsx)(n.code,{children:"build_static_drivers"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_shared_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," as a ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-shared-library-build",children:(0,s.jsx)(n.code,{children:"Shared"})})," library."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_static_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," as a ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-static-build",children:(0,s.jsx)(n.code,{children:"Static"})})," library archive.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"build_static_drivers"})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option will be select by default when the ",(0,s.jsx)(n.a,{href:"#qmake-static",children:(0,s.jsx)(n.code,{children:"CONFIG*=static"})})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_tests"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Build TinyORM unit tests."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ccache"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works on Windows and Unix systems. This option overrides qmake's ",(0,s.jsx)(n.code,{children:"ccache"})," option. It internally calls qmake's ",(0,s.jsx)(n.a,{href:"#qmake-ccache",children:(0,s.jsx)(n.code,{children:"ccache"})})," option on Unix and ",(0,s.jsx)(n.a,{href:"#tiny_ccache_win32",children:(0,s.jsx)(n.code,{children:"tiny_ccache_win32"})})," on Windows.",(0,s.jsx)("br",{}),"Reason: It allows using the same option on both OS-es.",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})," for more information."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_autoconf"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Disable the ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," feature ",(0,s.jsxs)("small",{children:["(auto-configuration is enabled by default from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_dotenv"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Disable the ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"tiny_dotenv"})})," feature ",(0,s.jsxs)("small",{children:["(environment files are enabled by default from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_thread_local"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_orm"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"enabled"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_tom"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"Tom-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then it also excludes ",(0,s.jsx)(n.code,{children:"Tom-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"extern_constants"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Use ",(0,s.jsx)(n.code,{children:"extern"})," constants instead of ",(0,s.jsx)(n.code,{children:"inline"})," constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"ON"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"})," ",(0,s.jsx)("small",{children:"(by default)"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"OFF"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)("code",{children:"CONFIG(shared|dll):!inline_constants"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"inline_constants"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Use ",(0,s.jsx)(n.code,{children:"inline"})," constants instead of ",(0,s.jsx)(n.code,{children:"extern"})," constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"OFF"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"ON"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"link_pkgconfig_off"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Link against ",(0,s.jsx)(n.code,{children:"mysqlclient"})," or ",(0,s.jsx)(n.code,{children:"libmariadb"})," with ",(0,s.jsx)(n.code,{children:"PKGCONFIG"}),".",(0,s.jsx)("br",{}),"Used only in the ",(0,s.jsx)(n.code,{children:"Unix"})," and ",(0,s.jsx)(n.code,{children:"MinGW"})," ",(0,s.jsx)(n.strong,{children:"shared"})," build ",(0,s.jsxs)("small",{children:["(exactly ",(0,s.jsx)("code",{children:"win32-g++|win32-clang-g++"}),")"]})," and when ",(0,s.jsx)(n.code,{children:"mysql_ping"})," is also defined to link against ",(0,s.jsx)(n.code,{children:"mysqlclient"})," or ",(0,s.jsx)(n.code,{children:"libmariadb"}),", ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L129",children:"source code"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"unix:mysql_ping"})," or ",(0,s.jsx)("code",{children:"(win32-g++|win32-clang-g++):mysql_ping:!static:!staticlib"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"mysql_ping"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"tiny_ccache_win32"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works only on Windows systems. It works well with the MSYS2 ",(0,s.jsx)(n.code,{children:"g++"}),", ",(0,s.jsx)(n.code,{children:"clang++"}),", ",(0,s.jsx)(n.code,{children:"msvc"}),", and ",(0,s.jsx)(n.code,{children:"clang-cl"})," with ",(0,s.jsx)(n.code,{children:"msvc"}),". It replaces the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options with the ",(0,s.jsx)(n.code,{children:"-Z7"})," for debug builds as the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options are not supported (",(0,s.jsx)(n.a,{href:"https://github.com/ccache/ccache/issues/1040",children:"link"})," to the issue) and disables ",(0,s.jsx)(n.code,{children:"precompile_header"})," if ",(0,s.jsx)(n.code,{children:"ccache"})," ",(0,s.jsx)(n.code,{children:"<4.10"})," as they are not supported on Windows."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"tom_example"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build the ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," console application example."]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Advanced ",(0,s.jsx)(n.code,{children:"TinyORM"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ubsan"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Allows to enable ",(0,s.jsx)(n.a,{href:"https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html",children:"UBSan"})," sanitizer (Clang only)."]})]})})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Important ",(0,s.jsx)(n.code,{children:"qmake"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{name:"qmake",children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.th,{children:[(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)("small",{children:"Option Name"})]}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ccache"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works only on the Unix systems. It works well with ",(0,s.jsx)(n.code,{children:"g++"})," and ",(0,s.jsx)(n.code,{children:"clang++"})," and also supports precompiled headers. TinyORM overrides this qmake option with the ",(0,s.jsx)(n.a,{href:"#ccache",children:(0,s.jsx)(n.code,{children:"ccache"})})," option.",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})," for more information."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ltcg"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Interprocedural_optimization",children:"Link time code optimization"})," (",(0,s.jsx)(n.a,{href:"https://wiki.gentoo.org/wiki/LTO",children:"LTO"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Works on all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"precompile_header"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Enable precompiled headers, you can disable them with:",(0,s.jsx)("br",{})," ",(0,s.jsx)(n.code,{children:"CONFIG-=precompile_header"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"precompile_header"})," is enabled by default on ",(0,s.jsx)(n.code,{children:"msvc"}),", ",(0,s.jsx)(n.code,{children:"g++"}),", ",(0,s.jsx)(n.code,{children:"clang++"}),", ",(0,s.jsx)(n.code,{children:"clang-cl"})," on ",(0,s.jsx)(n.code,{children:"Windows"})," and disabled by default on ",(0,s.jsx)(n.code,{children:"linux"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"static"}),(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"staticlib"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build as a ",(0,s.jsx)(n.code,{children:"static"})," library (lib only).",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["If you want to build all libraries in the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project as static library archives and link against static libraries use the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qmake-variable-reference.html#config",children:(0,s.jsx)(n.code,{children:"CONFIG += static"})}),". Don't use the ",(0,s.jsx)(n.code,{children:"CONFIG += staticlib"}),".",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/NOTES.txt",children:"NOTES.txt"})," for more information (search ",(0,s.jsx)(n.code,{children:"static vs staticlib"}),")."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"static_runtime"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Link against the ",(0,s.jsx)(n.code,{children:"shared"})," (dynamic) or ",(0,s.jsx)(n.code,{children:"static"})," run-time library.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"-MD"})," becomes ",(0,s.jsx)(n.code,{children:"-MT"})," and ",(0,s.jsx)(n.code,{children:"-MDd"})," becomes ",(0,s.jsx)(n.code,{children:"-MTd"}),". It works only on ",(0,s.jsx)(n.code,{children:"MSVC"})," and ",(0,s.jsx)(n.code,{children:"MinGW"})," or ",(0,s.jsx)(n.code,{children:"MSYS2"}),".",(0,s.jsx)("br",{}),"Please ",(0,s.jsx)("u",{children:"don't use"})," this option.",(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"msvc"})," or ",(0,s.jsx)(n.code,{children:"mingw"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.h3,{id:"consume-tinyorm-library-qmake",children:["Consume TinyOrm library ",(0,s.jsx)("small",{children:"(qmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri",children:(0,s.jsx)(n.code,{children:"TinyOrm.pri"})})," file is available to simplify the integration of the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library into your application. It sets up and configures the ",(0,s.jsx)(n.code,{children:"CONFIG"})," and ",(0,s.jsx)(n.code,{children:"DEFINES"})," qmake variables, adds the ",(0,s.jsx)(n.code,{children:"TinyORM"}),", ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})}),", and ",(0,s.jsx)(n.code,{children:"vcpkg"})," header files on the system ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," (cross-platform using the ",(0,s.jsx)(n.code,{children:"-isystem"})," or ",(0,s.jsx)(n.code,{children:"-imsvc"}),"), links against the TinyORM ",(0,s.jsx)(n.code,{children:"shared"})," or ",(0,s.jsx)(n.code,{children:"static"})," library using the ",(0,s.jsx)(n.code,{children:"LIBS"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["You can use it to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library when you are linking against it. It does a very similar thing like the CMake's ",(0,s.jsx)(n.code,{children:"Find Modules"})," feature."]}),"\n",(0,s.jsx)(n.h4,{id:"requirements",children:"Requirements"}),"\n",(0,s.jsx)(n.p,{children:"It has a few requirements, you need to:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["specify path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,s.jsx)(n.code,{children:".prf"})," files) using the ",(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})," variable that can only be set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file"]}),"\n",(0,s.jsxs)(n.li,{children:["specify ",(0,s.jsx)(n.code,{children:"qmake"})," or ",(0,s.jsx)(n.code,{children:"environment"})," variables to find the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation ",(0,s.jsxs)("small",{children:["(",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," and ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"}),")"]})]}),"\n",(0,s.jsxs)(n.li,{children:["specify path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder ",(0,s.jsxs)("small",{children:["(",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"}),")"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["you can specify it ",(0,s.jsx)(n.strong,{children:"manually"})]}),"\n",(0,s.jsxs)(n.li,{children:["or you can use ",(0,s.jsxs)(n.a,{href:"#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["build your application with the same ",(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variables that were used when building the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Let's explain one by one."}),"\n",(0,s.jsx)(n.h5,{id:"qmakefeatures",children:(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})}),"\n",(0,s.jsxs)(n.p,{children:["Create the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file in your application root folder with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path()\n# To find .env and .env.$$QMAKE_PLATFORM files in YOUR project\nTINY_DOTENV_ROOT = $$PWD\n\n# Path to the TinyORM build folder (specified manually)\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/)\n# vcpkg - range-v3 and tabulate\nTINY_VCPKG_ROOT = $$quote(/vcpkg/)\n#TINY_VCPKG_TRIPLET = x64-windows\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You can move all ",(0,s.jsx)(n.code,{children:"qmake"})," variables that are part of the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process to the ",(0,s.jsx)(n.code,{children:".env"})," file if you want (recommended), this is possible because the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," enables the ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"Environment files"})})," feature by default."]}),"\n",(0,s.jsxs)(n.p,{children:["You can look at the ",(0,s.jsx)(n.a,{href:"/building/hello-world#auto-configure-using-qmake_conf-and-env",children:"Auto-configure using .qmake.conf and .env"})," example for ",(0,s.jsx)(n.code,{children:"Hello world"})," project of what must stay in the ",(0,s.jsx)(n.code,{children:"qmake.conf"})," file and what can be moved to the ",(0,s.jsx)(n.code,{children:".env"})," files."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsxs)(n.a,{href:"#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually."]})}),"\n",(0,s.jsxs)(n.h5,{id:"variables-affecting-tinyormpri",children:["Variables affecting ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})]}),"\n",(0,s.jsxs)(n.p,{children:["You must define the following variables before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," is included:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," to use ",(0,s.jsx)("small",{children:"(vcpkg/installed/$$TINY_VCPKG_TRIPLET/)"}),".",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," based on the current compiler and OS (based on the ",(0,s.jsx)(n.code,{children:"QMAKESPEC"}),"), and as the last thing, it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})," environment variable."]})]})]})]}),"\n",(0,s.jsx)(n.p,{children:"These variables will be set after the configuration is done:"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_BUILD_SUBFOLDER"})}),(0,s.jsxs)(n.td,{children:["Folder by release type if ",(0,s.jsx)(n.code,{children:"CONFIG+=debug_and_release"})," is defined ",(0,s.jsx)("small",{children:"(/debug, /release, or an empty string)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_CCACHE_BUILD"})}),(0,s.jsxs)(n.td,{children:["To correctly link ",(0,s.jsx)(n.code,{children:"ccache"})," build against a ",(0,s.jsx)(n.code,{children:"ccache"})," build ",(0,s.jsx)("small",{children:"(_ccache or an empty string)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MSVC_VERSION"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"MSVC"})," compiler string ",(0,s.jsx)("small",{children:"(MSVC2022 or MSVC2019)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_QT_VERSION_UNDERSCORED"})}),(0,s.jsxs)(n.td,{children:["Underscored ",(0,s.jsx)(n.code,{children:"Qt"})," version ",(0,s.jsx)("small",{children:"(eg. 6_7_2)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_RELEASE_TYPE_CAMEL"})}),(0,s.jsxs)(n.td,{children:["Build type string ",(0,s.jsx)("small",{children:"(Debug, Profile, or Release)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(vcpkg/installed//include/)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Then you simply include the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," in your project file."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='AnyProject.pro'",children:"include($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["And that is all, now you should be able to link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. \ud83d\udc4c"]}),"\n",(0,s.jsx)(n.h5,{id:"manual-configuration-examples",children:"Manual configuration examples"}),"\n",(0,s.jsxs)(n.p,{children:["Frankly, there is no reason to use the Manual configuration (define the variables described below before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," inclusion), the only reason to use it is when you want more control over this process or want to define everything yourself. I'll leave this section here to show how things work."]}),"\n",(0,s.jsxs)(n.p,{children:["You will have to link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library manually if you don't set the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variable before the inclusion of the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," file. The ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," is auto-detected every time."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"{9}",children:"# Link against TinyORM library\n# ---\nTINY_MAIN_DIR = $$clean_path()\n\n# Configure TinyORM library\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n\n# TinyORM library path\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake)\nLIBS += $$quote(-L$$TINYORM_BUILD_TREE/build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/src$${TINY_BUILD_SUBFOLDER}/)\nLIBS += -lTinyOrm\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"{9}",children:"# Link against TinyORM library\n# ---\nTINY_MAIN_DIR = $$clean_path()\n\n# Configure TinyORM library\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n\n# TinyORM library path\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake)\nLIBS += $$quote(-L$$TINYORM_BUILD_TREE/build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/src$${TINY_BUILD_SUBFOLDER}/)\nLIBS += -lTinyOrm\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"vcpkg"})," include path. If you don't set the ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," or have not defined the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable, then you need to set up the ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," for the ",(0,s.jsx)(n.code,{children:"vcpkg"})," that provides the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," header files."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nINCLUDEPATH += $$quote(/vcpkg/installed/x64-windows/include/)\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nQMAKE_CXXFLAGS += -isystem $$shell_quote(/vcpkg/installed/x64-linux/include/)\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["You can also use TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," function ",(0,s.jsx)(n.code,{children:"tiny_add_system_includepath()"})," which handles ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," in a cross-platform way."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nload(private/tiny_system_includepath)\ntiny_add_system_includepath(/vcpkg/installed/x64-linux/include/)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so your application can find it during execution."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.OZ)(y.b,!1)}\\TinyORM\\TinyORM-builds-qmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-qmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.p,{children:["On Linux ",(0,s.jsx)(n.code,{children:"-isystem"})," marks the directory as a system directory, it prevents warnings."]}),(0,s.jsxs)(n.p,{children:["On Windows you can use ",(0,s.jsx)(n.code,{children:"QMAKE_CXXFLAGS_WARN_ON = -external:anglebrackets -external:W0"}),", it applies a warning level 0 to the angel bracket includes; ",(0,s.jsx)(n.code,{children:"#include "}),"."]}),(0,s.jsxs)(n.p,{children:["With the ",(0,s.jsx)(n.code,{children:"Clang-cl"})," with ",(0,s.jsx)(n.code,{children:"MSVC"})," you can use ",(0,s.jsx)(n.code,{children:"-imsvc"}),"."]})]}),"\n",(0,s.jsx)(n.h3,{id:"auto-configuration-internals",children:"Auto-configuration internals"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"qmake"})," build system does not support ",(0,s.jsx)(n.code,{children:"auto-configuration"})," of dependencies out of the box but ",(0,s.jsx)(n.code,{children:"TinyORM"})," from ",(0,s.jsx)(n.code,{children:"v0.34.0"})," added its own ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature along with the ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," qmake feature. These new features allow us to ",(0,s.jsx)(n.code,{children:"auto-configure"})," ",(0,s.jsx)(n.code,{children:"TinyORM"})," project, and with their help, the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files can be ",(0,s.jsx)("u",{children:"skipped entirely"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["While it adds additional complexity to the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process, the benefits are significant."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature is designed to find the ",(0,s.jsx)(n.code,{children:"vcpkg"})," and ",(0,s.jsx)(n.code,{children:"MySQL"})," installations, and ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," to include the ",(0,s.jsx)(n.code,{children:".env"})," and ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," files in the project's root folder. These new features can be configured using ",(0,s.jsx)(n.code,{children:"qmake"})," and ",(0,s.jsx)(n.code,{children:"environment"})," variables, and they also contain some guessing logic if these variables are not defined."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),")."]}),"\n",(0,s.jsxs)(n.p,{children:["These are ",(0,s.jsx)("u",{children:(0,s.jsx)(n.code,{children:"qmake"})})," and ",(0,s.jsx)("u",{children:(0,s.jsx)(n.code,{children:"environment"})})," variables that affect the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," to use ",(0,s.jsx)("small",{children:"(vcpkg/installed/$$TINY_VCPKG_TRIPLET/)"}),".",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," based on the current compiler and OS (based on the ",(0,s.jsx)(n.code,{children:"QMAKESPEC"}),"), and as the last thing, it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"MySQL"})," installation folder (",(0,s.jsx)(n.code,{children:"win32"})," only): ",(0,s.jsx)("code",{children:"$$(ProgramFiles)/MySQL/MySQL Server (9.0|8.4|8.3|8.2|8.1|8.0|5.7)/"})]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["You can set these variables in the ",(0,s.jsx)(n.code,{children:".env"})," (recommended) or ",(0,s.jsx)(n.code,{children:"conf.pri"})," files, in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file (or wherever you want), or as environment variables."]}),"\n",(0,s.jsxs)(n.p,{children:["These variables will be set after ",(0,s.jsx)(n.code,{children:"auto-configuration"})," is done:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(vcpkg/installed//include/)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(MySQL Server 9.0/include/)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_LIB"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," ",(0,s.jsx)(n.code,{children:"lib"})," folder ",(0,s.jsx)("small",{children:"(MySQL Server 9.0/lib/)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TINY_MYSQL_INCLUDE"})," and ",(0,s.jsx)(n.code,{children:"TINY_MYSQL_LIB"})," are only set on ",(0,s.jsx)(n.code,{children:"win32"})," platform except ",(0,s.jsx)(n.code,{children:"mingw"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"environment-files",children:"Environment files"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature allows us to define the ",(0,s.jsx)(n.code,{children:".env"})," and ",(0,s.jsx)(n.code,{children:".env.$$TINY_DOTENV_PLATFORM"})," files in the project's root folder. These files are loaded as early as possible so you can affect the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process. On the other hand, the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are loaded as late as possible, and they can be used to override the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:".env"})," file is included ",(0,s.jsx)("u",{children:"first"})," and is included on all platforms."]}),"\n",(0,s.jsxs)(n.p,{children:["There is only one requirement for this feature to work correctly, and that is to set the ",(0,s.jsx)(n.code,{children:"TINY_DOTENV_ROOT"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variable to the project's root folder. This variable is ",(0,s.jsx)(n.strong,{children:"already"})," set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file for the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsx)(n.p,{children:"Then the following names are taken into account: .env, .env.win32, .env.unix, .env.mingw"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_dotenv",children:(0,s.jsx)(n.code,{children:"disable_dotenv"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),")."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Environment files"})," don't work in the ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]})}),"\n",(0,s.jsxs)(n.h4,{id:"partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]}),"\n",(0,s.jsxs)(n.p,{children:["You don't have to manually define the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," in ",(0,s.jsx)(n.code,{children:".env"})," or ",(0,s.jsx)(n.code,{children:".qmake.conf"})," files. The ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," absolute path can be put together for you (this is happening inside the ",(0,s.jsx)(n.code,{children:"variables.pri"})," file) and ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder name can be guessed for you too."]}),"\n",(0,s.jsxs)(n.p,{children:["You must define the following variables before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," will be included to make this real (set them in the ",(0,s.jsx)(n.code,{children:".qmake.conf"}),"):"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MAIN_DIR"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.strong,{children:"PARENT"})," folder of the ",(0,s.jsx)(n.code,{children:"TinyORM"})," source folder."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.strong,{children:"current"})," build tree - ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TINY_MAIN_DIR"})," is required for another features anyway (so it should already be set) and all that's left is to set the ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the current build tree (used to guess the TinyORM build tree)\nTINY_BUILD_TREE = $$shadowed($$PWD)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["If you will follow this pattern or logic then you can switch ",(0,s.jsx)(n.code,{children:"QtCreator Kits"})," and the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," will be ",(0,s.jsx)(n.strong,{children:"auto-generated"})," correctly and will always point to the correct ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree."]}),"\n",(0,s.jsxs)(n.p,{children:["It works this way, all is happening inside the ",(0,s.jsx)(n.code,{children:"variables.pri"}),", it takes a build folder name for the ",(0,s.jsx)(n.strong,{children:"current"})," project eg. ",(0,s.jsx)(n.code,{children:"build-HelloWorld-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug"}),", replaces the ",(0,s.jsx)(n.code,{children:"HelloWorld"})," with the ",(0,s.jsx)(n.code,{children:"TinyORM"})," and as we already know the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder location we can simply concatenate these paths like ",(0,s.jsx)(n.code,{children:"$$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["This will only work if you follow the recommended ",(0,s.jsx)(n.a,{href:"#folders-structure",children:(0,s.jsx)(n.code,{children:"Folders structure"})}),"."]})}),"\n",(0,s.jsx)(n.h3,{id:"manual-configuration-internals",children:"Manual configuration internals"}),"\n",(0,s.jsxs)(n.p,{children:["There is not much to say about the ",(0,s.jsx)(n.code,{children:"Manual configuration"})," feature. It uses ",(0,s.jsx)(n.code,{children:"conf.pri"})," files (there are four, one for every project or sub-project), and every project has prepared its own ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," file for faster initial configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["These ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," files are nicely commented on, so you can see what needs to be modified. The ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are loaded as late as possible, and they can be used to override the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["If the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature is disabled and there are no ",(0,s.jsx)(n.code,{children:"conf.pri"})," files, then the ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration or build will fail at 100%."]}),"\n",(0,s.jsxs)(n.p,{children:["These ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are intended for configuring qmake's ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," and ",(0,s.jsx)(n.code,{children:"LIBS"}),", ",(0,s.jsx)(n.code,{children:"CONFIG"})," or eg. ",(0,s.jsx)(n.code,{children:"QMAKE_LFLAGS"}),", or any other ",(0,s.jsx)(n.code,{children:"qmake"})," options or variables."]}),"\n",(0,s.jsx)(n.h2,{id:"ccache-support",children:"Ccache support"}),"\n",(0,s.jsxs)(n.p,{children:["The TinyORM supports the ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:(0,s.jsx)(n.code,{children:"ccache"})})," out of the box for all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"supported compilers"}),". For ",(0,s.jsx)(n.code,{children:"qmake"})," you can enable it using the ",(0,s.jsx)(n.a,{href:"#ccache",children:(0,s.jsx)(n.code,{children:"CONFIG+=ccache"})})," and for ",(0,s.jsx)(n.code,{children:"CMake"})," you can set the ",(0,s.jsx)(n.a,{href:"#CMAKE_CXX_COMPILER_LAUNCHER",children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER_LAUNCHER=ccache"})}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["On ",(0,s.jsx)(n.code,{children:"Linux"})," it's clear, the ",(0,s.jsx)(n.code,{children:"ccache"})," is fully supported and works also with the ",(0,s.jsx)(n.code,{children:"precompiled headers"}),". But was necessary to add some workarounds to the ",(0,s.jsx)(n.code,{children:"qmake"}),"/",(0,s.jsx)(n.code,{children:"CMake"})," build systems to make out of the box support on ",(0,s.jsx)(n.code,{children:"Windows"}),". When you enable the ",(0,s.jsx)(n.code,{children:"ccache"})," on ",(0,s.jsx)(n.code,{children:"Windows"})," then the build system replaces the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options with the ",(0,s.jsx)(n.code,{children:"-Z7"})," (link to the ",(0,s.jsx)(n.a,{href:"https://github.com/ccache/ccache/issues/1040",children:"issue"}),") and disables ",(0,s.jsx)(n.code,{children:"precompiled headers"})," if ",(0,s.jsx)(n.code,{children:"ccache <4.10"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can install the ",(0,s.jsx)(n.code,{children:"ccache"})," using the ",(0,s.jsx)(n.code,{children:"scoop install ccache"})," command on Windows. See the ",(0,s.jsx)(n.a,{href:"/dependencies#linux-installation-ccache",children:"Dependencies"})," page for how to install ",(0,s.jsx)(n.code,{children:"ccache"})," on Linux."]})})]})}function M(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(I,{...e})}):I(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>l});i(6540);var s=i(4164);const d={tabItem:"tabItem_Ymn6"};var r=i(4848);function l(e){let{children:n,hidden:i,className:l}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,s.A)(d.tabItem,l),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>_});var s=i(6540),d=i(4164),r=i(3104),l=i(6347),c=i(205),t=i(7485),o=i(1682),a=i(679);function h(e){return s.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function x(e){const{values:n,children:i}=e;return(0,s.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:s,default:d}}=e;return{value:n,label:i,attributes:s,default:d}}))}(i);return function(e){const n=(0,o.X)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function j(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function u(e){let{queryString:n=!1,groupId:i}=e;const d=(0,l.W6)(),r=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,t.aZ)(r),(0,s.useCallback)((e=>{if(!r)return;const n=new URLSearchParams(d.location.search);n.set(r,e),d.replace({...d.location,search:n.toString()})}),[r,d])]}function p(e){const{defaultValue:n,queryString:i=!1,groupId:d}=e,r=x(e),[l,t]=(0,s.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!j({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const s=i.find((e=>e.default))??i[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:n,tabValues:r}))),[o,h]=u({queryString:i,groupId:d}),[p,m]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[d,r]=(0,a.Dv)(i);return[d,(0,s.useCallback)((e=>{i&&r.set(e)}),[i,r])]}({groupId:d}),b=(()=>{const e=o??p;return j({value:e,tabValues:r})?e:null})();(0,c.A)((()=>{b&&t(b)}),[b]);return{selectedValue:l,selectValue:(0,s.useCallback)((e=>{if(!j({value:e,tabValues:r}))throw new Error(`Can't select invalid tab value=${e}`);t(e),h(e),m(e)}),[h,m,r]),tabValues:r}}var m=i(2303);const b={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var f=i(4848);function g(e){let{className:n,block:i,selectedValue:s,selectValue:l,tabValues:c}=e;const t=[],{blockElementScrollPositionUntilNextRender:o}=(0,r.a_)(),a=e=>{const n=e.currentTarget,i=t.indexOf(n),d=c[i].value;d!==s&&(o(n),l(d))},h=e=>{let n=null;switch(e.key){case"Enter":a(e);break;case"ArrowRight":{const i=t.indexOf(e.currentTarget)+1;n=t[i]??t[0];break}case"ArrowLeft":{const i=t.indexOf(e.currentTarget)-1;n=t[i]??t[t.length-1];break}}n?.focus()};return(0,f.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,d.A)("tabs",{"tabs--block":i},n),children:c.map((e=>{let{value:n,label:i,attributes:r}=e;return(0,f.jsx)("li",{role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:e=>t.push(e),onKeyDown:h,onClick:a,...r,className:(0,d.A)("tabs__item",b.tabItem,r?.className,{"tabs__item--active":s===n}),children:i??n},n)}))})}function y(e){let{lazy:n,children:i,selectedValue:d}=e;const r=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=r.find((e=>e.props.value===d));return e?(0,s.cloneElement)(e,{className:"margin-top--md"}):null}return(0,f.jsx)("div",{className:"margin-top--md",children:r.map(((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==d})))})}function T(e){const n=p(e);return(0,f.jsxs)("div",{className:(0,d.A)("tabs-container",b.tabList),children:[(0,f.jsx)(g,{...n,...e}),(0,f.jsx)(y,{...n,...e})]})}function _(e){const n=(0,m.A)();return(0,f.jsx)(T,{...e,children:h(e.children)},String(n))}},6684:(e,n,i)=>{i.d(n,{A:()=>a});var s=i(6540),d=i(3427),r=i(6347);const l={apiTable:"apiTable_flxF"};var c=i(4848);function t(e,n){let{name:i,children:l}=e;const t=function(e){let n=e;for(;(0,s.isValidElement)(n);)[n]=s.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(l),o=i?`${i}-${t}`:t,a=`#${o}`,h=(0,r.W6)();return(0,d.A)().collectAnchor(o),(0,c.jsx)("tr",{id:o,tabIndex:0,ref:h.location.hash===a?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||h.push(a)},onKeyDown:e=>{"Enter"===e.key&&h.push(a)},children:l.props.children})}const o=s.forwardRef(t);function a(e){let{children:n,name:i}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[d,r]=s.Children.toArray(n.props.children),t=(0,s.useRef)(null);(0,s.useEffect)((()=>{t.current?.focus()}),[t]);const a=s.Children.map(r.props.children,(e=>(0,c.jsx)(o,{name:i,ref:t,children:e})));return(0,c.jsxs)("table",{className:l.apiTable,children:[d,(0,c.jsx)("tbody",{children:a})]})}},7324:(e,n,i)=>{i.d(n,{$E:()=>m,A3:()=>f,CW:()=>b,Dx:()=>a,F4:()=>x,Fi:()=>o,J_:()=>_,LQ:()=>g,Lf:()=>v,OO:()=>d,Q7:()=>y,b:()=>c,cy:()=>t,gg:()=>u,kl:()=>j,os:()=>h,pW:()=>r,ux:()=>p,vf:()=>s,xj:()=>l,xt:()=>T});const s="shell",d="database",r="application",l="bash",c="pwsh",t="zsh",o="maria",a="mysql",h="postgres",x="sqlite",j="application",u="bash",p="pwsh",m="zsh",b="MariaDB",f="MySQL",g="PostgreSQL",y="SQLite",T="tinyorm.org",_="$HOME/Code/c/",v="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>r});var s=i(6540),d=i(1838);function r(){const e=(0,s.useContext)(d.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>t,Sn:()=>l,T3:()=>a,bw:()=>o,nC:()=>h,np:()=>c});var s=i(6362),d=i(2303),r=i(7324);const l=function(e,n){return void 0===n&&(n=!0),x((0,s.A)().rootFolder[e]??o(e),e,n)},c=()=>(0,s.A)().rootFolder[r.pW]??o(r.pW),t=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==r.b?"/":"\\";return x(l(e)+i+c(),e,n)};function o(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,d.A)())return"";switch(e){case r.b:return r.Lf;case r.xj:return r.J_;case r.pW:return r.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function a(e){return e===r.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case r.b:return u(n).replace(/\$env:(.+?)(\/.*)/,i);case r.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function x(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==r.b)return j(e);const s=j(e);return i?u(s):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(s)}function j(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function u(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},2721:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-additional_arguments-14d3b6b82ad6d28db5b999a462500a6a.png"},7619:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-build_settings-7caa6d7c86232484b82acb24b5a3a6a7.png"},885:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-configure_project-0b6821ea0523567dab9f21b3215055a3.png"}}]); \ No newline at end of file diff --git a/assets/js/0ab078a9.b808fb6a.js b/assets/js/0ab078a9.b808fb6a.js new file mode 100644 index 000000000..190490db3 --- /dev/null +++ b/assets/js/0ab078a9.b808fb6a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[395],{1503:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>O,contentTitle:()=>_,default:()=>M,frontMatter:()=>T,metadata:()=>v,toc:()=>R});var s=i(4848),d=i(8453),r=i(8774),l=i(6684),c=i(2364),t=i(9365),o=i(1470),a=i(5556),h=i.n(a),x=i(6694);function j(e){let{groupId:n}=e;return(0,s.jsx)("span",{children:(0,x.OZ)(n)})}j.propTypes={groupId:h().string.isRequired};const u=j;var p=i(4164),m=i(6362);const b={rootFolderInput:"rootFolderInput_ottS",input:"input_OR7e",application:"application_fjej"};function f(e){let{groupId:n,label:i}=e;const{rootFolder:d,setRootFolder:r}=(0,m.A)(),l=(0,x.T3)(n),c=l?"application":"root",t=l?"\nThis folder name is common for all shells (eg. pwsh, bash, ...)":"";return(0,s.jsx)("form",{name:"tinyorm-root-folder-form",className:(0,p.A)(b.rootFolderInput,b[n],n),onSubmit:e=>{e.preventDefault(),e.stopPropagation()},children:(0,s.jsx)("input",{name:"tinyorm-root-folder-input",className:(0,p.A)(b.input,b[n],n),placeholder:`Enter ${c} folder...`,title:`This ${c} folder will be used in all ${i} examples at tinyorm.org${t}`,onChange:e=>{r(n,e.target.value)},value:d[n]??(0,x.bw)(n)})})}f.propTypes={groupId:h().string.isRequired,label:h().string.isRequired};const g=f;var y=i(7324);const T={sidebar_position:0,sidebar_label:"TinyORM",hide_table_of_contents:!0,description:"How to compile the TinyORM C++ library on Windows and Linux.",keywords:["c++ orm","building","tinyorm"]},_="Building: TinyORM",v={id:"building/tinyorm",title:"Building: TinyORM",description:"How to compile the TinyORM C++ library on Windows and Linux.",source:"@site/docs/building/tinyorm.mdx",sourceDirName:"building",slug:"/building/tinyorm",permalink:"/building/tinyorm",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"TinyORM",hide_table_of_contents:!0,description:"How to compile the TinyORM C++ library on Windows and Linux.",keywords:["c++ orm","building","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/tinydrivers/getting-started"},next:{title:"Hello world",permalink:"/building/hello-world"}},O={},R=[{value:"Introduction",id:"introduction",level:2},{value:"Common Prerequisites",id:"common-prerequisites",level:4},{value:"Windows Prerequisites",id:"windows-prerequisites",level:4},{value:"Build environment scripts",id:"build-environment-scripts",level:5},{value:"Allow symbolic links unprivileged",id:"allow-symbolic-links-unprivileged",level:5},{value:"Folders structure",id:"folders-structure",level:2},{value:"Getting started",id:"getting-started",level:2},{value:"vcpkg",id:"vcpkg",level:2},{value:"Set up vcpkg environment",id:"set-up-vcpkg-environment",level:4},{value:"C preprocessor macros",id:"c-preprocessor-macros",level:2},{value:"Building with CMake",id:"building-with-cmake",level:2},{value:"Configure & Build (cmake)",id:"configure-and-build-cmake",level:3},{value:"CMake STRICT_MODE option",id:"cmake-strict_mode-option",level:5},{value:"Build TinyORM",id:"build-tinyorm",level:4},{value:"CMake build options",id:"cmake-build-options",level:3},{value:"CMake build environment variables",id:"cmake-build-environment-variables",level:3},{value:"Consume TinyOrm library (cmake)",id:"consume-tinyorm-library-cmake",level:3},{value:"Building with qmake",id:"building-with-qmake",level:2},{value:"Install dependencies",id:"install-dependencies",level:3},{value:"Configure & Build (qmake)",id:"configure-and-build-qmake",level:3},{value:"Open QtCreator IDE",id:"open-qtcreator-ide",level:4},{value:"Configure TinyORM",id:"configure-tinyorm",level:4},{value:"Auto-configuration and tiny_dotenv",id:"auto-configuration-and-tiny_dotenv",level:5},{value:"Manual configuration (conf.pri)",id:"manual-configuration-confpri",level:5},{value:"Opening TinyORM.pro (main project file)",id:"opening-tinyormpro-main-project-file",level:5},{value:"Build TinyORM",id:"build-tinyorm-1",level:4},{value:"qmake build options",id:"qmake-build-options",level:3},{value:"Consume TinyOrm library (qmake)",id:"consume-tinyorm-library-qmake",level:3},{value:"Requirements",id:"requirements",level:4},{value:"QMAKEFEATURES",id:"qmakefeatures",level:5},{value:"Variables affecting TinyOrm.pri",id:"variables-affecting-tinyormpri",level:5},{value:"Manual configuration examples",id:"manual-configuration-examples",level:5},{value:"Auto-configuration internals",id:"auto-configuration-internals",level:3},{value:"Environment files",id:"environment-files",level:4},{value:"Partial guessing of the TINYORM_BUILD_TREE",id:"partial-guessing-of-the-tinyorm_build_tree",level:4},{value:"Manual configuration internals",id:"manual-configuration-internals",level:3},{value:"Ccache support",id:"ccache-support",level:2}];function I(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"building-tinyorm",children:"Building: TinyORM"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#common-prerequisites",children:"Common Prerequisites"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#windows-prerequisites",children:"Windows Prerequisites"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#folders-structure",children:"Folders structure"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#getting-started",children:"Getting started"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#vcpkg",children:"vcpkg"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#c-preprocessor-macros",children:"C preprocessor macros"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#building-with-cmake",children:"Building with CMake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#configure-and-build-cmake",children:"Configure & Build"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-build-options",children:"CMake build options"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-build-environment-variables",children:"CMake build environment variables"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-cmake",children:"Consume TinyOrm library"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#building-with-qmake",children:"Building with qmake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#configure-and-build-qmake",children:"Configure & Build"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#qmake-build-options",children:"qmake build options"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-qmake",children:"Consume TinyOrm library"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:"Auto-configuration internals"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#environment-files",children:"Environment files"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#manual-configuration-internals",children:"Manual configuration internals"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(r.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["The build systems supported out of the box are ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["All examples below assume that ",(0,s.jsx)(n.code,{children:"pwsh"})," runs on ",(0,s.jsx)(n.code,{children:"Windows"})," and ",(0,s.jsx)(n.code,{children:"bash"})," runs on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"common-prerequisites",children:"Common Prerequisites"}),"\n",(0,s.jsxs)(n.p,{children:["Install the required ",(0,s.jsx)(n.a,{href:"/dependencies",children:"dependencies"})," before starting."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"QSqlDatabase"})," depends on ",(0,s.jsx)(n.code,{children:"QCoreApplication"})," from ",(0,s.jsx)(n.code,{children:"Qt v6.5.3"})," so you must create the ",(0,s.jsx)(n.code,{children:"QCoreApplication"})," instance before you will call anything from the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. \ud83e\udee4 The change was made ",(0,s.jsx)(n.a,{href:"https://github.com/qt/qtbase/commit/8d2bdc9cd5482eace12ba7e45304857bd24db0e6#diff-1d355c25c0b0eddec2be48253407780c4dc510d986739aec61e1ec892ccaf86e",children:"here"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"windows-prerequisites",children:"Windows Prerequisites"}),"\n",(0,s.jsx)(n.h5,{id:"build-environment-scripts",children:"Build environment scripts"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Visual Studio"})," does not provide ",(0,s.jsx)(n.code,{children:"vcvars"})," scripts for ",(0,s.jsx)(n.code,{children:"pwsh"}),", you can use ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/tools/vcvars64.ps1",children:(0,s.jsx)(n.code,{children:"vcvars64.ps1"})})," provided by ",(0,s.jsx)(n.code,{children:"TinyORM"})," in the ",(0,s.jsx)(n.code,{children:"tools/"})," folder. Place them on the ",(0,s.jsx)(n.code,{children:"$env:Path"})," user/system path and they will be available system-wide."]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"Qt Framework"}),", it doesn't provide ",(0,s.jsx)(n.code,{children:"qtenv"})," scripts for ",(0,s.jsx)(n.code,{children:"pwsh"})," too. You can create your own script, place it on the ",(0,s.jsx)(n.code,{children:"$env:Path"})," user/system path and it will be available system-wide."]}),"\n",(0,s.jsxs)(n.p,{children:["Here is one simple example for ",(0,s.jsx)(n.code,{children:"pwsh"})," and ",(0,s.jsx)(n.code,{children:"bash"})," on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",metastring:"title='qtenv6.ps1'",children:"#!/usr/bin/env pwsh\n\nSet-StrictMode -Version 3.0\n\nWrite-Host 'Setting up environment for Qt 6.7.2 usage...' -ForegroundColor Magenta\nWrite-Host\n\n$Script:QtRoot = $env:TINY_QT_ROOT ?? 'C:\\Qt'\n\n$env:Path = \"$Script:QtRoot\\6.7.2\\msvc2019_64\\bin;\" + $env:Path\n\n. vcvars64.ps1\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"title='qtenv6'",children:'#!/usr/bin/env sh\n\necho \'Setting up environment for Qt 6.7.2 usage...\'\n\nQtRoot="${TINY_QT_ROOT:-/opt/Qt}"\n\nexport PATH="$QtRoot/6.7.2/gcc_64/bin"${PATH:+:}$PATH\nexport LD_LIBRARY_PATH="$QtRoot/6.7.2/gcc_64/lib"${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH\n'})})})]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["These scripts consider the ",(0,s.jsx)(n.code,{children:"TINY_QT_ROOT"})," environment variable that should point to the ",(0,s.jsx)(n.code,{children:"Qt"})," installation folder, you can define this environment variable globally in your OS."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can't execute these ",(0,s.jsx)(n.code,{children:"qtenvX"})," scripts, they have to be sourced like ",(0,s.jsx)(n.code,{children:"source qtenvX"})," or ",(0,s.jsx)(n.code,{children:". qtenvX"}),"."]})}),"\n",(0,s.jsx)(n.h5,{id:"allow-symbolic-links-unprivileged",children:"Allow symbolic links unprivileged"}),"\n",(0,s.jsxs)(n.p,{children:["Open ",(0,s.jsx)(n.code,{children:"Local Security Policy"}),", go to ",(0,s.jsx)(n.code,{children:"Local Policies - User Rights Assignment"}),", open ",(0,s.jsx)(n.code,{children:"Create symbolic links"})," and add your user account or user group, restart when it doesn't apply immediately."]}),"\n",(0,s.jsx)(n.h2,{id:"folders-structure",children:"Folders structure"}),"\n",(0,s.jsxs)(n.p,{children:["All ",(0,s.jsx)(n.code,{children:"tinyorm.org"})," examples are based on the following folders structure. The ",(0,s.jsx)(n.code,{children:"tom"})," folder will contain a ",(0,s.jsx)(n.a,{href:"/building/migrations",children:"migrations console application"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can set the root and application folder paths in the form below and they will be used across the whole ",(0,s.jsx)(n.a,{href:"http://www.tinyorm.org",children:"www.tinyorm.org"})," website. \ud83e\udd73 The pwsh shell is supposed to use on Windows and the bash shell on Linux, but it is not a requirement."]})}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsxs)(t.A,{value:y.b,label:y.ux,className:"tiny-tree",children:[(0,s.jsx)("div",{className:"tiny-root-folder-info-wrapper",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)("span",{className:"tiny-root-folder-info-prefix",children:"Current pwsh path"}),"\xa0",(0,s.jsx)(u,{groupId:y.b})]})}),(0,s.jsx)(g,{groupId:y.b,label:y.ux}),(0,s.jsx)(g,{groupId:y.pW,label:y.kl}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\n\n\n\u251c\u2500\u2500\n\u2502 \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld-builds-cmake/\n\u2502 | | \u2514\u2500\u2500 build-debug/\n\u2502 | \u2514\u2500\u2500 HelloWorld-builds-qmake/\n\u2502 | \u2514\u2500\u2500 build-debug/\n\u2502 \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM-builds-cmake/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-debug/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-release/\n\u2502 | \u2502 \u2514\u2500\u2500 build-clang-debug/\n\u2502 | \u2514\u2500\u2500 TinyORM-builds-qmake/\n\u2502 | \u251c\u2500\u2500 build-debug/\n\u2502 | \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u2502 | \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_64bit-Release/\n\u2502 \u2514\u2500\u2500 tom/\n\u2502 \u251c\u2500\u2500 tom/\n\u2502 \u2502 \u2514\u2500\u2500 database/\n\u2502 \u2502 \u251c\u2500\u2500 migrations/\n\u2502 \u2502 \u251c\u2500\u2500 seeders/\n\u2502 \u2502 \u251c\u2500\u2500 migrations.pri\n\u2502 \u2502 \u2514\u2500\u2500 seeders.pri\n\u2502 \u251c\u2500\u2500 tom-builds-cmake/\n\u2502 \u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u2502 \u2514\u2500\u2500 tom-builds-qmake/\n\u2502 \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_64bit-Release/\n\u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/\n\u251c\u2500\u2500 tmp/\n\u2514\u2500\u2500 vcpkg/\n"})})]}),(0,s.jsxs)(t.A,{value:y.xj,label:y.gg,className:"tiny-tree",children:[(0,s.jsx)("div",{className:"tiny-root-folder-info-wrapper",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)("span",{className:"tiny-root-folder-info-prefix",children:"Current bash path"}),"\xa0",(0,s.jsx)(u,{groupId:y.xj})]})}),(0,s.jsx)(g,{groupId:y.xj,label:y.gg}),(0,s.jsx)(g,{groupId:y.pW,label:y.pW}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\n\n\n\u251c\u2500\u2500\n\u2502 \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld/\n\u2502 | \u251c\u2500\u2500 HelloWorld-builds-cmake/\n\u2502 | | \u2514\u2500\u2500 build-debug/\n\u2502 | \u2514\u2500\u2500 HelloWorld-builds-qmake/\n\u2502 | \u2514\u2500\u2500 build-debug/\n\u2502 \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM/\n\u2502 | \u251c\u2500\u2500 TinyORM-builds-cmake/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-debug/\n\u2502 | \u2502 \u251c\u2500\u2500 build-gcc-release/\n\u2502 | \u2502 \u2514\u2500\u2500 build-clang-debug/\n\u2502 | \u2514\u2500\u2500 TinyORM-builds-qmake/\n\u2502 | \u251c\u2500\u2500 build-debug/\n\u2502 | \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/\n\u2502 | \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Release/\n\u2502 \u2514\u2500\u2500 tom/\n\u2502 \u251c\u2500\u2500 tom/\n\u2502 \u2502 \u2514\u2500\u2500 database/\n\u2502 \u2502 \u251c\u2500\u2500 migrations/\n\u2502 \u2502 \u251c\u2500\u2500 seeders/\n\u2502 \u2502 \u251c\u2500\u2500 migrations.pri\n\u2502 \u2502 \u2514\u2500\u2500 seeders.pri\n\u2502 \u251c\u2500\u2500 tom-builds-cmake/\n\u2502 \u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/\n\u2502 \u2514\u2500\u2500 tom-builds-qmake/\n\u2502 \u251c\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/\n\u2502 \u2514\u2500\u2500 build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Release/\n\u251c\u2500\u2500 tmp/\n\u2514\u2500\u2500 vcpkg/\n"})})]})]}),"\n",(0,s.jsx)(n.admonition,{type:"danger",children:(0,s.jsxs)(n.p,{children:["Avoid paths with spaces with the ",(0,s.jsx)(n.code,{children:"qmake"})," build system, it will not compile."]})}),"\n",(0,s.jsx)(r.A,{id:"qtcreator-default-build-directory"}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described above."]}),(0,s.jsxs)(n.p,{children:["To generate the required folders structure set the ",(0,s.jsx)(n.code,{children:"Settings"})," - ",(0,s.jsx)(n.code,{children:"Build & Run"})," - ",(0,s.jsx)(n.code,{children:"Default Build Properties"})," - ",(0,s.jsx)(n.code,{children:"Default build directory"})," to:",(0,s.jsx)("br",{}),"\n",(0,s.jsx)(n.code,{children:'../%{Project:Name}-builds-%{BuildSystem:Name}/%{JS: Util.asciify("build-%{Project:Name}-%{Kit:FileSystemName}-%{BuildConfig:Name}")}'})]})]}),"\n",(0,s.jsx)(n.h2,{id:"getting-started",children:"Getting started"}),"\n",(0,s.jsxs)(n.p,{children:["Prepare compilation environment, we need to put the Qt Framework and Visual Studio MSVC compiler on the path on Windows. The compiler is already on the path on Linux and you can export ",(0,s.jsx)(n.code,{children:"PATH"})," and ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," for Qt Framework, or use our ",(0,s.jsx)(n.code,{children:"qtenvX"})," scripts described above."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`mkdir ${(0,x.Sn)(y.b)}\ncd ${(0,x.Sn)(y.b)}\n$env:Path = 'C:\\Qt\\6.7.2\\msvc2019_64\\bin;' + $env:Path\nvcvars64.ps1`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`mkdir -p ${(0,x.Sn)(y.xj)}\ncd ${(0,x.Sn)(y.xj)}\nexport PATH=/opt/Qt/6.7.2/gcc_64/bin\${PATH:+:}$PATH\nexport LD_LIBRARY_PATH=/opt/Qt/6.7.2/gcc_64/lib\${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH`})})]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can also use the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tools/Add-FolderOnPath.ps1",children:(0,s.jsx)(n.code,{children:"tools/Add-FolderOnPath.ps1"})})," pwsh script to fastly prepend a path or ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"})," on the system ",(0,s.jsx)(n.code,{children:"PATH"}),"."]})}),"\n",(0,s.jsx)(n.h2,{id:"vcpkg",children:"vcpkg"}),"\n",(0,s.jsxs)(n.p,{children:["Installing the ",(0,s.jsx)(n.code,{children:"vcpkg"})," is highly recommended, it simplifies installation of the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," dependencies."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"git clone git@github.com:microsoft/vcpkg.git\ncd vcpkg\n.\\bootstrap-vcpkg.bat\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"git clone git@github.com:microsoft/vcpkg.git\ncd vcpkg\n./bootstrap-vcpkg.sh\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["Add ",(0,s.jsx)(n.code,{children:"vcpkg"})," on the system path, add the following to the ",(0,s.jsx)(n.code,{children:".bashrc"})," or ",(0,s.jsx)(n.code,{children:".zshrc"})," on Linux."]}),"\n",(0,s.jsx)(c.A,{className:"language-bash",children:`export PATH=${(0,x.Sn)(y.xj)}/vcpkg\${PATH:+:}$PATH`}),"\n",(0,s.jsxs)(n.p,{children:["On Windows, open the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog and add ",(0,s.jsx)(n.code,{children:"vcpkg"})," on the user ",(0,s.jsx)(n.code,{children:"PATH"}),"."]}),"\n",(0,s.jsx)(n.p,{children:"Or you can export it for the current session only."}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.Sn)(y.b,!1)}\\vcpkg;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export PATH=${(0,x.Sn)(y.xj)}/vcpkg\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.h4,{id:"set-up-vcpkg-environment",children:["Set up ",(0,s.jsx)(n.code,{children:"vcpkg"})," environment"]}),"\n",(0,s.jsxs)(n.p,{children:["To export ",(0,s.jsx)(n.code,{children:"vcpkg"})," environment variables globally, add it to the ",(0,s.jsx)(n.code,{children:".bashrc"})," or ",(0,s.jsx)(n.code,{children:".zshrc"})," on Linux, and you can use the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog on Windows."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",metastring:"title='Linux'",children:'export VCPKG_DEFAULT_TRIPLET=x64-linux\n#export VCPKG_DEFAULT_HOST_TRIPLET=x64-linux\nexport VCPKG_MAX_CONCURRENCY=11\nexport VCPKG_OVERLAY_PORTS="$HOME/.local/share/vcpkg/ports"\nexport VCPKG_OVERLAY_TRIPLETS="$HOME/.local/share/vcpkg/triplets"\nexport VCPKG_ROOT="$HOME/Code/c/vcpkg"\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["It is recommended to define these variables globally because the ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"})," build system are able to detect the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation from them so you don't have to configure them manually to detect the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["On Windows, it's always better to create these types of variables as user variables instead of system variables in the ",(0,s.jsx)(n.code,{children:"Environment variables"})," dialog."]})}),"\n",(0,s.jsx)(n.h2,{id:"c-preprocessor-macros",children:"C preprocessor macros"}),"\n",(0,s.jsxs)(n.p,{children:["The following table summarizes all the C preprocessor macros defined in the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. These C macros are configured by ",(0,s.jsx)(n.code,{children:"CMake"})," or ",(0,s.jsx)(n.code,{children:"qmake"})," build systems. They are not sorted alphabetically, but they are sorted by how significant they are."]}),"\n",(0,s.jsxs)(n.p,{children:["In the ",(0,s.jsx)(n.code,{children:"CMake"})," build system, all the C macros are auto-detected / auto-configured or controlled by ",(0,s.jsx)(n.a,{href:"#cmake-build-options",children:(0,s.jsx)(n.code,{children:"CMake build options"})}),", so you don't have to care too much about them."]}),"\n",(0,s.jsxs)(n.p,{children:["In the ",(0,s.jsx)(n.code,{children:"qmake"})," build is important whether you are building ",(0,s.jsx)(n.code,{children:"TinyORM"})," library or you are building your application and linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. When you are building the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library, all the C macros are auto-detected / auto-configured or controlled by ",(0,s.jsx)(n.a,{href:"#qmake-build-options",children:(0,s.jsx)(n.code,{children:"qmake build options"})}),", so you don't have to care too much about them."]}),"\n",(0,s.jsxs)(n.p,{children:["But a special situation is when you are building your application / library and you are linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. In this particular case, you must configure all these C macros manually! For this reason, the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri",children:(0,s.jsx)(n.code,{children:"TinyOrm.pri"})})," has been created, so that's not a big deal either. Little more info ",(0,s.jsx)(n.a,{href:"#consume-tinyorm-library-qmake",children:"here"}),"."]}),"\n",(0,s.jsx)("div",{id:"apitable-c-macros",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"C Macro Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_LINKING_SHARED"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)("u",{children:(0,s.jsx)(n.strong,{children:"Must"})})," be defined when you are linking against ",(0,s.jsx)(n.code,{children:"TinyORM"})," shared build (",(0,s.jsx)(n.code,{children:"dll"})," library), exported classes and functions will be tagged with ",(0,s.jsx)(n.code,{children:"__declspec(dllimport)"})," on ",(0,s.jsx)(n.code,{children:"msvc"})," and ",(0,s.jsx)(n.code,{children:'visibility("default")'})," on ",(0,s.jsx)(n.code,{children:"GCC >= 4"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_BUILDING_SHARED"})}),(0,s.jsxs)(n.td,{children:["Defined when ",(0,s.jsx)(n.code,{children:"TinyORM"})," is built as a ",(0,s.jsx)(n.code,{children:"dll"})," library (shared build)."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DEBUG"})}),(0,s.jsx)(n.td,{children:"Defined in the debug build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_NO_DEBUG"})}),(0,s.jsx)(n.td,{children:"Defined in the release build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DEBUG_SQL"})}),(0,s.jsx)(n.td,{children:"Defined in the debug build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_NO_DEBUG_SQL"})}),(0,s.jsx)(n.td,{children:"Defined in the release build."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_MYSQL_PING"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#mysql_ping",children:(0,s.jsx)(n.code,{children:"mysql_ping"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#MYSQL_PING",children:(0,s.jsx)(n.code,{children:"MYSQL_PING"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DISABLE_ORM"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this macro is ",(0,s.jsx)(n.code,{children:"defined"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#disable_orm",children:(0,s.jsx)(n.code,{children:"disable_orm"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#ORM",children:(0,s.jsx)(n.code,{children:"ORM"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled ",(0,s.jsx)("small",{children:"(qmake)"})," / disabled ",(0,s.jsx)("small",{children:"(cmake)"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_EXTERN_CONSTANTS"})}),(0,s.jsxs)(n.td,{children:["Defined when extern constants are used. Extern constants are enabled by default for shared builds and disabled for static builds.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Described at ",(0,s.jsx)(n.a,{href:"#extern_constants",children:(0,s.jsx)(n.code,{children:"qmake"})})," / ",(0,s.jsx)(n.a,{href:"#INLINE_CONSTANTS",children:(0,s.jsx)(n.code,{children:"CMake"})})," how it works."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_INLINE_CONSTANTS"})}),(0,s.jsxs)(n.td,{children:["Defined when global inline constants are used.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#inline_constants",children:(0,s.jsx)(n.code,{children:"inline_constants"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#INLINE_CONSTANTS",children:(0,s.jsx)(n.code,{children:"INLINE_CONSTANTS"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_TESTS_CODE"})}),(0,s.jsxs)(n.td,{children:["Enable code needed by unit tests, eg. connection overriding in the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#build_tests",children:(0,s.jsx)(n.code,{children:"build_tests"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#BUILD_TESTS",children:(0,s.jsx)(n.code,{children:"BUILD_TESTS"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_DISABLE_THREAD_LOCAL"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined when ",(0,s.jsx)(n.a,{href:"#disable_thread_local",children:(0,s.jsx)(n.code,{children:"disable_thread_local"})})," ",(0,s.jsx)("small",{children:"(qmake)"})," / ",(0,s.jsx)(n.a,{href:"#DISABLE_THREAD_LOCAL",children:(0,s.jsx)(n.code,{children:"DISABLE_THREAD_LOCAL"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration ",(0,s.jsx)(n.code,{children:"build option"})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_MIGRATIONS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default migrations path for the ",(0,s.jsx)(n.code,{children:"make:migration"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/migrations"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_MIGRATIONS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_MIGRATIONS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_MIGRATIONS_DIR="\\"database/migrations\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L65-L70",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_MODELS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default models path for the ",(0,s.jsx)(n.code,{children:"make:model"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/models"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_MODELS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_MODELS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_MODELS_DIR="\\"database/models\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L72-L73",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYTOM_SEEDERS_DIR"})}),(0,s.jsxs)(n.td,{children:["Default seeders path for the ",(0,s.jsx)(n.code,{children:"make:seeder"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/seeders"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Defined by ",(0,s.jsx)(n.a,{href:"#TOM_SEEDERS_DIR",children:(0,s.jsx)(n.code,{children:"TOM_SEEDERS_DIR"})})," ",(0,s.jsx)("small",{children:"(cmake)"})," configuration build option.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(qmake note) You can use ",(0,s.jsx)(n.code,{children:'DEFINES += TINYTOM_SEEDERS_DIR="\\"database/seeders\\""'})," on the command-line or set it in the ",(0,s.jsx)(n.strong,{children:"main"})," ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L75-L76",children:(0,s.jsx)(n.code,{children:"conf.pri"})})," file."]})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_USING_PCH"})}),(0,s.jsxs)(n.td,{children:["Defined if building with precompiled headers.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Controlled by ",(0,s.jsx)(n.a,{href:"#qmake-precompile_header",children:(0,s.jsx)(n.code,{children:"qmake"})})," / ",(0,s.jsx)(n.a,{href:"#CMAKE_DISABLE_PRECOMPILE_HEADERS",children:(0,s.jsx)(n.code,{children:"CMake"})}),"."]})]})]})]})]})})}),"\n",(0,s.jsx)(n.h2,{id:"building-with-cmake",children:"Building with CMake"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If something is not clear, you can still look at GitHub Action ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:(0,s.jsx)(n.code,{children:"workflows"})})," how the build is done."]})}),"\n",(0,s.jsxs)(n.p,{children:["First, create a basic folder structure and then clone the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.Sn)(y.b)}\nmkdir ${(0,x.np)()}/TinyORM/TinyORM-builds-cmake/build-debug\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.Sn)(y.xj)}\nmkdir -p ${(0,x.np)()}/TinyORM/TinyORM-builds-cmake/build-debug\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})})]}),"\n",(0,s.jsxs)(n.h3,{id:"configure-and-build-cmake",children:["Configure & Build ",(0,s.jsx)("small",{children:"(cmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd TinyORM-builds-cmake/build-debug\n"})}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,x.OZ)(y.b)}/TinyORM/TinyORM" \`\n-B "${(0,x.OZ)(y.b)}/TinyORM/TinyORM-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,x.Sn)(y.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,x.Sn)(y.b)}/tmp/TinyORM" \`\n-D BUILD_TESTS:BOOL=OFF \`\n-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON \`\n-D MYSQL_PING:BOOL=OFF \`\n-D TOM:BOOL=ON \`\n-D TOM_EXAMPLE:BOOL=OFF \`\n-D VERBOSE_CONFIGURE:BOOL=ON`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cmake \\\n-S "${(0,x.OZ)(y.xj)}/TinyORM/TinyORM" \\\n-B "${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,x.Sn)(y.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,x.Sn)(y.xj)}/tmp/TinyORM" \\\n-D VERBOSE_CONFIGURE:BOOL=ON \\\n-D BUILD_TESTS:BOOL=OFF \\\n-D MYSQL_PING:BOOL=OFF \\\n-D TOM:BOOL=ON \\\n-D TOM_EXAMPLE:BOOL=OFF \\\n-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON`})})]}),"\n",(0,s.jsxs)(n.h5,{id:"cmake-strict_mode-option",children:["CMake ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," option"]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option was added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.38.0"}),". This option was added to avoid the propagation of aggressive strict warning compiler/linker options and Qt definitions from the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library to user code through the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/cmake/CommonModules/TinyCommon.cmake",children:(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})})," interface library."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TinyORM"})," uses the strictest warning level options, virtually anything that can be enabled is enabled to produce a better code. I highly recommend enabling this option to produce better code and to follow good practices. It also helps to follow the ",(0,s.jsx)(n.code,{children:"ISOCPP"})," ",(0,s.jsx)(n.a,{href:"https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines",children:"C++ Core Guidelines"})," standards."]}),"\n",(0,s.jsxs)(n.p,{children:["If you want to enable these strict warning options in your code, you can enable the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option and they will be propagated to your code. You can also enabled it globally using the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable, and the value of this environment variable will be picked up during initial CMake configuration as the default value for the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," ",(0,s.jsx)(n.code,{children:"CMake"})," configuration option."]}),"\n",(0,s.jsxs)(n.p,{children:["You can achieve the same result by manually linking against the ",(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})," interface library when the ",(0,s.jsx)(n.code,{children:"STRICT_MODE"})," is set to ",(0,s.jsx)(n.code,{children:"OFF"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",children:"target_link_libraries( PRIVATE TinyOrm::CommonConfig)\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The recommended way is to set the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable to ",(0,s.jsx)(n.code,{children:"1"})," or ",(0,s.jsx)(n.code,{children:"ON"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"build-tinyorm",children:"Build TinyORM"}),"\n",(0,s.jsx)(n.p,{children:"And build. You don't have to install it, you can use the build tree directly if you want."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\ncmake --install .\n"})}),"\n",(0,s.jsx)(n.p,{children:"Or build and install in one step."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target install\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["CMake multi-config generators like ",(0,s.jsx)(n.code,{children:"Ninja Multi-Config"})," or ",(0,s.jsx)(n.code,{children:"Visual Studio 16 2019"})," are also supported."]})}),"\n",(0,s.jsx)(n.h3,{id:"cmake-build-options",children:"CMake build options"}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_DRIVERS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"TinyDrivers"})," SQL database drivers (core/common code; replaces QtSql module)."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_MYSQL_DRIVER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," MySQL database driver.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"BUILD_DRIVERS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsx)(n.td,{children:"Build as a shared/static library."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_TESTS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Build TinyORM unit tests."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"BUILD_TREE_DEPLOY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Copy ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," and ",(0,s.jsx)(n.code,{children:"TinyMySql"})," libraries to the root of the build tree."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"DRIVERS_TYPE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"Shared"})}),(0,s.jsxs)(n.td,{children:["How to build and link against ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," SQL database drivers.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"Static"})," value will be select by default when the ",(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})," is ",(0,s.jsx)(n.code,{children:"OFF"}),".",(0,s.jsx)("br",{}),"Supported values: ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-shared-library-build",children:(0,s.jsx)(n.code,{children:"Shared"})}),", ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-loadable-sql-drivers-build",children:(0,s.jsx)(n.code,{children:"Loadable"})}),", and ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-static-build",children:(0,s.jsx)(n.code,{children:"Static"})}),(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"BUILD_DRIVERS AND BUILD_SHARED_LIBS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"INLINE_CONSTANTS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Use inline constants instead of extern constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"OFF"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"ON"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"BUILD_SHARED_LIBS"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"MSVC_RUNTIME_DYNAMIC"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Use MSVC dynamic runtime library (",(0,s.jsx)(n.code,{children:"-MD"}),") instead of static (",(0,s.jsx)(n.code,{children:"-MT"}),"), also considers a Debug configuration (",(0,s.jsx)(n.code,{children:"-MTd"}),", ",(0,s.jsx)(n.code,{children:"-MDd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"MSVC AND NOT TINY_VCPKG AND NOT DEFINED VCPKG_CRT_LINKAGE AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"MYSQL_PING"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ORM"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"STRICT_MODE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls propagation of strict compiler/linker options and Qt definitions using the ",(0,s.jsx)(n.code,{children:"TinyOrm::CommonConfig"})," interface library to the user code.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["(highly recommended; can also be set with the ",(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})," environment variable; described ",(0,s.jsx)(n.a,{href:"#cmake-strict_mode-option",children:"here"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"Tom-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then it also excludes ",(0,s.jsx)(n.code,{children:"Tom-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_EXAMPLE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build the ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," console application example."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_MIGRATIONS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default migrations path for the ",(0,s.jsx)(n.code,{children:"make:migration"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/migrations"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_MODELS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default models path for the ",(0,s.jsx)(n.code,{children:"make:model"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/models"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TOM_SEEDERS_DIR"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default seeders path for the ",(0,s.jsx)(n.code,{children:"make:seeder"})," command, can be an absolute or relative path (to the ",(0,s.jsx)("abbr",{title:"Current working directory",children:"pwd"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Default value: ",(0,s.jsx)(n.code,{children:"database/seeders"})," ",(0,s.jsx)("small",{children:"(relative to the pwd)"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VERBOSE_CONFIGURE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Show information about ",(0,s.jsx)(n.code,{children:"PACKAGES_FOUND"})," / ",(0,s.jsx)(n.code,{children:"PACKAGES_NOT_FOUND"})," in the CMake configure output."]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Advanced ",(0,s.jsx)(n.code,{children:"TinyORM"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"DISABLE_THREAD_LOCAL"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)("small",{children:(0,s.jsx)(n.code,{children:"MATCH_EQUAL_EXPORTED_BUILDTREE"})})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Exported package configuration from the build tree is considered to match only when ",(0,s.jsx)(n.code,{children:"the build type"})," of application/library that is linking against the TinyORM library ",(0,s.jsx)(n.strong,{children:"is equal"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when:",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY AND NOT TINY_IS_MULTI_CONFIG"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Important ",(0,s.jsx)(n.code,{children:"CMake"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_DISABLE_PRECOMPILE_HEADERS"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Disable precompiled headers."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"auto"})}),(0,s.jsxs)(n.td,{children:["The full path to the ",(0,s.jsx)(n.code,{children:"C++"})," compiler."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER_LAUNCHER"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Default compiler launcher to use for the ",(0,s.jsx)(n.code,{children:"C++"})," compiler.",(0,s.jsx)("br",{}),"Can be used to enable ",(0,s.jsx)(n.code,{children:"ccache"}),", eg. ",(0,s.jsx)(n.code,{children:"ccache.exe"})," on ",(0,s.jsx)(n.code,{children:"MinGW"})," or ",(0,s.jsx)(n.code,{children:"/usr/bin/ccache"})," on ",(0,s.jsx)(n.code,{children:"Linux"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable the ",(0,s.jsx)(n.code,{children:"export(TinyOrm)"})," command.",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"TinyORM"})," doesn't set this variable by default. Its initial value is taken from the ",(0,s.jsx)(n.code,{children:"TINYORM_EXPORT_PACKAGE_REGISTRY"})," environment variable if not already defined."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)("small",{children:(0,s.jsx)(n.code,{children:"CMAKE_INTERPROCEDURAL_OPTIMIZATION"})})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Interprocedural_optimization",children:"Link time code optimization"})," (",(0,s.jsx)(n.a,{href:"https://wiki.gentoo.org/wiki/LTO",children:"LTO"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Works on all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CMAKE_VERBOSE_MAKEFILE"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Enable verbose output from Makefile builds."})]})]})]})})}),"\n",(0,s.jsx)(n.h3,{id:"cmake-build-environment-variables",children:"CMake build environment variables"}),"\n",(0,s.jsxs)(n.p,{children:["The following are environment variables that are affecting the ",(0,s.jsx)(n.code,{children:"TinyORM"})," CMake build system."]}),"\n",(0,s.jsxs)(n.p,{children:["These environment variables have lower priority than CMake ",(0,s.jsx)(n.code,{children:"-D"})," compile definitions and they are used if the ",(0,s.jsx)(n.code,{children:"-D"})," compile definitions are not ",(0,s.jsx)(n.code,{children:"DEFINED"}),"."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-environment-variables",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_EXPORT_PACKAGE_REGISTRY"})}),(0,s.jsxs)(n.td,{children:["Environment variable for ",(0,s.jsx)(n.a,{href:"/building/tinyorm#CMAKE_EXPORT_PACKAGE_REGISTRY",children:(0,s.jsx)(n.code,{children:"CMAKE_EXPORT_PACKAGE_REGISTRY"})}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})}),(0,s.jsxs)(n.td,{children:["Environment variable for ",(0,s.jsx)(n.a,{href:"/building/tinyorm#STRICT_MODE",children:(0,s.jsx)(n.code,{children:"STRICT_MODE"})})," CMake feature option.",(0,s.jsx)("br",{}),"It's passed as the initial value ",(0,s.jsx)(n.code,{children:"[value]"})," for the CMake ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/command/option.html",children:(0,s.jsx)(n.code,{children:"option"})})," command."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Auto-detect the ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html",children:(0,s.jsx)(n.code,{children:"CMAKE_TOOLCHAIN_FILE"})})," from the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_TOOLCHAIN_FILE"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})}),(0,s.jsxs)(n.td,{children:["Auto-detect the ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html",children:(0,s.jsx)(n.code,{children:"CMAKE_TOOLCHAIN_FILE"})})," from the ",(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})," environment variable. The ",(0,s.jsx)(n.a,{href:"https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md#environment-variables",children:(0,s.jsx)(n.code,{children:"VCPKG_INSTALLATION_ROOT"})})," environment variable is set on GitHub hosted runners.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED CMAKE_TOOLCHAIN_FILE"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["Default value for the ",(0,s.jsx)(n.a,{href:"https://learn.microsoft.com/en-us/vcpkg/users/buildsystems/cmake-integration#vcpkg_target_triplet",children:(0,s.jsx)(n.code,{children:"VCPKG_TARGET_TRIPLET"})}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Used if: ",(0,s.jsx)(n.code,{children:"NOT DEFINED VCPKG_TARGET_TRIPLET"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.h3,{id:"consume-tinyorm-library-cmake",children:["Consume TinyOrm library ",(0,s.jsx)("small",{children:"(cmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["In your application or library ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file add following ",(0,s.jsx)(n.code,{children:"find_package()"})," call."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",metastring:"title='CMakeLists.txt'",children:"find_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["If the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree is not exported to the CMake's ",(0,s.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry",children:(0,s.jsx)(n.code,{children:"User Package Registry"})})," then also add the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree or ",(0,s.jsx)(n.code,{children:"CMAKE_INSTALL_PREFIX"})," folder to the ",(0,s.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"}),", so CMake can find TinyORM's package configuration file during ",(0,s.jsx)(n.code,{children:"find_package(TinyOrm)"})," call."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:`cmake (${y.b})`,children:(0,s.jsx)(c.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.b,(0,x.OZ)(y.b))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\n# installation folder - CMAKE_INSTALL_PREFIX\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.b,(0,x.Sn)(y.b))}/tmp/TinyORM")`})}),(0,s.jsx)(t.A,{value:y.xj,label:`cmake (${y.xj})`,children:(0,s.jsx)(c.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.xj,(0,x.OZ)(y.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\n# installation folder - CMAKE_INSTALL_PREFIX\nlist(APPEND CMAKE_PREFIX_PATH "${(0,x.nC)(y.xj,(0,x.Sn)(y.xj))}/tmp/TinyORM")`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Or as an alternative, you can set ",(0,s.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"})," environment variable."]}),"\n",(0,s.jsx)(r.A,{id:"tinyorm-on-path-cmake"}),"\n",(0,s.jsxs)(n.p,{children:["As the last thing, do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so your application can find it during execution."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.OZ)(y.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Now you can try the ",(0,s.jsx)(n.a,{href:"/building/hello-world#hello-world-with-cmake",children:(0,s.jsx)(n.code,{children:"HelloWorld CMake"})})," example."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can also try the ",(0,s.jsx)(n.a,{href:"/building/hello-world#fetchcontent",children:(0,s.jsx)(n.code,{children:"FetchContent"})})," method to fastly link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library."]})}),"\n",(0,s.jsx)(n.h2,{id:"building-with-qmake",children:"Building with qmake"}),"\n",(0,s.jsxs)(n.p,{children:["First, create a basic folder structure and then clone the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.Sn)(y.b)}\nmkdir ${(0,x.np)()}/TinyORM/TinyORM-builds-qmake\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.Sn)(y.xj)}\nmkdir -p ${(0,x.np)()}/TinyORM/TinyORM-builds-qmake\n\ncd ${(0,x.np)()}/TinyORM\ngit clone git@github.com:silverqx/TinyORM.git`})})]}),"\n",(0,s.jsx)(n.h3,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.p,{children:["With the ",(0,s.jsx)(n.code,{children:"qmake"})," build system, you have to install ",(0,s.jsx)(n.code,{children:"TinyORM"})," dependencies manually. We will use the ",(0,s.jsx)(n.code,{children:"vcpkg"})," package manager."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,s.jsxs)(n.p,{children:["On ",(0,s.jsx)(n.code,{children:"Linux"}),", you can install the ",(0,s.jsx)(n.code,{children:"range-v3"})," library and some other ",(0,s.jsx)(n.a,{href:"/dependencies#install-dependencies",children:"dependencies"})," with the package manager."]}),"\n",(0,s.jsxs)(n.h3,{id:"configure-and-build-qmake",children:["Configure & Build ",(0,s.jsx)("small",{children:"(qmake)"})]}),"\n",(0,s.jsx)(n.h4,{id:"open-qtcreator-ide",children:"Open QtCreator IDE"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["I recommend creating a new ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qtcreator/creator-project-managing-sessions.html",children:(0,s.jsx)(n.code,{children:"Session"})})," in the ",(0,s.jsx)(n.code,{children:"QtCreator"}),", this way you will have all the examples in one place and as a bonus, everything will be in the same place when you close and reopen ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),". You can name it ",(0,s.jsx)(n.code,{children:"tinyorm.org"})," or ",(0,s.jsx)(n.code,{children:"TinyORM examples"}),", it is up to you."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If you are using sessions, you can use a single ",(0,s.jsx)(n.code,{children:"clangd"})," instance for all projects in this session in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),". One significant advantage of this method is that the ",(0,s.jsx)(n.code,{children:".qtc_clangd/"})," folder will not be created in the build folder, but will be stored globally in the Roaming profile. You can enable it in the ",(0,s.jsx)(n.code,{children:"Settings"})," - ",(0,s.jsx)(n.code,{children:"C++"})," - ",(0,s.jsx)(n.code,{children:"Clangd"})," - ",(0,s.jsx)(n.code,{children:"Sessions with a single clangd instance"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"configure-tinyorm",children:"Configure TinyORM"}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. There are two ways how to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library and it's the new ",(0,s.jsx)(n.code,{children:"Auto-configure"})," feature added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"})," using the ",(0,s.jsx)(n.code,{children:".env"})," files and the old way using the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files."]}),"\n",(0,s.jsx)(n.h5,{id:"auto-configuration-and-tiny_dotenv",children:"Auto-configuration and tiny_dotenv"}),"\n",(0,s.jsxs)(n.p,{children:["This is the new recommended method to auto-configure TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," build system and also the dependencies, it was added in ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),". You need to copy the prepared ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw).example"})," file to the ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"}),". One ",(0,s.jsx)(n.code,{children:".env"})," example file is prepared for each supported platform."]}),"\n",(0,s.jsxs)(n.p,{children:["All prepared ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw).example"})," files are simple and clear. You can also create a common ",(0,s.jsx)(n.code,{children:".env"})," file that is included before the platform-specific ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," files."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.OZ)(y.b)}/TinyORM/TinyORM\n\ncp .env.win32.example .env.win32`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.OZ)(y.xj)}/TinyORM/TinyORM\n\ncp .env.unix.example .env.unix`})})]}),"\n",(0,s.jsxs)(n.p,{children:["And that is all, if you have correctly set all ",(0,s.jsx)(n.code,{children:"qmake"})," variables in this ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," file or you have correctly set environment variables, then the ",(0,s.jsx)(n.code,{children:"qmake"})," build system should be able to ",(0,s.jsx)(n.code,{children:"auto-detect"})," all dependencies . \ud83d\udd25"]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," and ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"Environment files"})})," internals are described at the end to make this section more clear."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),")."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_dotenv",children:(0,s.jsx)(n.code,{children:"disable_dotenv"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),")."]})}),"\n",(0,s.jsx)(n.h5,{id:"manual-configuration-confpri",children:"Manual configuration (conf.pri)"}),"\n",(0,s.jsxs)(n.p,{children:["This is the old method used before ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),". You need to copy the ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," files to ",(0,s.jsx)(n.code,{children:"conf.pri"})," (there are four, one for every project or sub-project) and manually update the ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," and ",(0,s.jsx)(n.code,{children:"LIBS"})," to configure TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," build dependencies. This way you can override any ",(0,s.jsx)(n.code,{children:"qmake"})," build options or variables."]}),"\n",(0,s.jsxs)(n.p,{children:["To disable the ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," feature you must define the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),") because from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"})," is the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature enabled by default."]}),"\n",(0,s.jsxs)(n.p,{children:["You can also remove all ",(0,s.jsx)(n.code,{children:".env"})," files or turn off the ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature using ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),". You can use them all at once if you want, ",(0,s.jsx)(n.code,{children:".env"})," and also ",(0,s.jsx)(n.code,{children:"conf.pri"})," files."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"conf.pri"})," files are nicely commented on, so you can see what needs to be modified."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`cd ${(0,x.OZ)(y.b)}/TinyORM/TinyORM\n\ncp conf.pri.example conf.pri\ncp tests/conf.pri.example tests/conf.pri\ncp tests/testdata_tom/conf.pri.example tests/testdata_tom/conf.pri\ncp examples/tom/conf.pri.example examples/tom/conf.pri`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`cd ${(0,x.OZ)(y.xj)}/TinyORM/TinyORM\n\ncp conf.pri.example conf.pri\ncp tests/conf.pri.example tests/conf.pri\ncp tests/testdata_tom/conf.pri.example tests/testdata_tom/conf.pri\ncp examples/tom/conf.pri.example examples/tom/conf.pri`})})]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#manual-configuration-internals",children:(0,s.jsx)(n.code,{children:"Manual configuration"})})," internals are described at the end to make this section more clear."]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Manual configuration"})," is still relevant if you have any non-standard installation of the ",(0,s.jsx)(n.code,{children:"vcpkg"})," or ",(0,s.jsx)(n.code,{children:"MySQL"})," and the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature fails."]})}),"\n",(0,s.jsx)(n.h5,{id:"opening-tinyormpro-main-project-file",children:"Opening TinyORM.pro (main project file)"}),"\n",(0,s.jsxs)(n.p,{children:["Now you can open the ",(0,s.jsx)(n.code,{children:"TinyORM.pro"})," project in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This will open the ",(0,s.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,s.jsx)(n.a,{href:"#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,s.jsx)("img",{src:i(885).A,alt:"TinyORM - QtCreator - Configure Project",width:"760"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,s.jsx)(n.a,{href:"#qtcreator-default-build-directory",children:"above"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,s.jsxs)(n.p,{children:["Disable ",(0,s.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,s.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,s.jsx)("img",{src:i(7619).A,alt:"TinyORM - QtCreator - Build Settings",width:"760"}),"\n",(0,s.jsxs)(n.p,{children:["If you want to change some ",(0,s.jsx)(n.code,{children:"TinyORM"})," build options, you can pass them to the ",(0,s.jsx)(n.code,{children:"Build Steps"})," - ",(0,s.jsx)(n.code,{children:"qmake TinyORM.pro"})," - ",(0,s.jsx)(n.code,{children:"Additional arguments"})," input field. It can look like this."]}),"\n",(0,s.jsx)("img",{src:i(2721).A,alt:"TinyORM - QtCreator - Build Settings - Additional arguments",width:"660"}),"\n",(0,s.jsx)(n.h4,{id:"build-tinyorm-1",children:"Build TinyORM"}),"\n",(0,s.jsxs)(n.p,{children:["Everything is ready for build, you can press ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,s.jsx)(n.h3,{id:"qmake-build-options",children:"qmake build options"}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.th,{children:[(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)("small",{children:"Option Name"})]}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_loadable_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started",children:(0,s.jsx)(n.code,{children:"TinyDrivers"})})," as a shared library and SQL database drivers (eg. ",(0,s.jsx)(n.code,{children:"TinyMySql"}),") as shared libraries (",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-loadable-sql-drivers-build",children:(0,s.jsx)(n.code,{children:"Loadable"})})," modules) that are loaded at runtime using ",(0,s.jsx)(n.code,{children:"LoadLibrary()"})," on Windows or ",(0,s.jsx)(n.code,{children:"dlopen()"})," on Linux."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_mysql_driver"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," MySQL database driver.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It's enabled by default when ",(0,s.jsx)(n.code,{children:"build_shared_drivers"}),", ",(0,s.jsx)(n.code,{children:"build_loadable_drivers"}),", or ",(0,s.jsx)(n.code,{children:"build_static_drivers"})," is enabled.",(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"build_shared_drivers"})," OR ",(0,s.jsx)(n.code,{children:"build_loadable_drivers"})," OR ",(0,s.jsx)(n.code,{children:"build_static_drivers"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_shared_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," as a ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-shared-library-build",children:(0,s.jsx)(n.code,{children:"Shared"})})," library."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_static_drivers"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build ",(0,s.jsx)(n.code,{children:"TinyDrivers"})," as a ",(0,s.jsx)(n.a,{href:"/tinydrivers/getting-started#the-static-build",children:(0,s.jsx)(n.code,{children:"Static"})})," library archive.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"build_static_drivers"})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option will be select by default when the ",(0,s.jsx)(n.a,{href:"#qmake-static",children:(0,s.jsx)(n.code,{children:"CONFIG*=static"})})," is enabled."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"build_tests"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsx)(n.td,{children:"Build TinyORM unit tests."})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ccache"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works on Windows and Unix systems. This option overrides qmake's ",(0,s.jsx)(n.code,{children:"ccache"})," option. It internally calls qmake's ",(0,s.jsx)(n.a,{href:"#qmake-ccache",children:(0,s.jsx)(n.code,{children:"ccache"})})," option on Unix and ",(0,s.jsx)(n.a,{href:"#tiny_ccache_win32",children:(0,s.jsx)(n.code,{children:"tiny_ccache_win32"})})," on Windows.",(0,s.jsx)("br",{}),"Reason: It allows using the same option on both OS-es.",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})," for more information."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_autoconf"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Disable the ",(0,s.jsx)(n.a,{href:"#auto-configuration-internals",children:(0,s.jsx)(n.code,{children:"Auto-configuration"})})," feature ",(0,s.jsxs)("small",{children:["(auto-configuration is enabled by default from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_dotenv"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Disable the ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"tiny_dotenv"})})," feature ",(0,s.jsxs)("small",{children:["(environment files are enabled by default from ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"v0.34.0"}),")"]}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_thread_local"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Remove all ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/c/language/storage_duration",children:(0,s.jsx)(n.code,{children:"thread_local"})})," storage duration specifiers, it disables multi-threading support."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_orm"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"ORM-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"enabled"}),", then only the ",(0,s.jsx)(n.code,{children:"query builder"})," without ",(0,s.jsx)(n.code,{children:"ORM"})," is compiled. Also excludes ",(0,s.jsx)(n.code,{children:"ORM-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"disable_tom"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Controls the compilation of all ",(0,s.jsx)(n.code,{children:"Tom-related"})," source code, when this option is ",(0,s.jsx)(n.code,{children:"disabled"}),", then it also excludes ",(0,s.jsx)(n.code,{children:"Tom-related"})," unit tests."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"extern_constants"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Use ",(0,s.jsx)(n.code,{children:"extern"})," constants instead of ",(0,s.jsx)(n.code,{children:"inline"})," constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"ON"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"})," ",(0,s.jsx)("small",{children:"(by default)"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"OFF"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)("code",{children:"CONFIG(shared|dll):!inline_constants"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"inline_constants"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Use ",(0,s.jsx)(n.code,{children:"inline"})," constants instead of ",(0,s.jsx)(n.code,{children:"extern"})," constants in the ",(0,s.jsx)(n.code,{children:"shared build"}),".",(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"OFF"})," is highly recommended for the ",(0,s.jsx)(n.code,{children:"shared build"}),";",(0,s.jsx)("br",{}),"is always ",(0,s.jsx)(n.code,{children:"ON"})," for the ",(0,s.jsx)(n.code,{children:"static build"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"link_pkgconfig_off"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Link against ",(0,s.jsx)(n.code,{children:"mysqlclient"})," or ",(0,s.jsx)(n.code,{children:"libmariadb"})," with ",(0,s.jsx)(n.code,{children:"PKGCONFIG"}),".",(0,s.jsx)("br",{}),"Used only in the ",(0,s.jsx)(n.code,{children:"Unix"})," and ",(0,s.jsx)(n.code,{children:"MinGW"})," ",(0,s.jsx)(n.strong,{children:"shared"})," build ",(0,s.jsxs)("small",{children:["(exactly ",(0,s.jsx)("code",{children:"win32-g++|win32-clang-g++"}),")"]})," and when ",(0,s.jsx)(n.code,{children:"mysql_ping"})," is also defined to link against ",(0,s.jsx)(n.code,{children:"mysqlclient"})," or ",(0,s.jsx)(n.code,{children:"libmariadb"}),", ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/conf.pri.example#L129",children:"source code"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Available when: ",(0,s.jsx)(n.code,{children:"unix:mysql_ping"})," or ",(0,s.jsx)("code",{children:"(win32-g++|win32-clang-g++):mysql_ping:!static:!staticlib"})]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"mysql_ping"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.code,{children:"Orm::MySqlConnection::pingDatabase()"})," method."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"tiny_ccache_win32"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ON"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works only on Windows systems. It works well with the MSYS2 ",(0,s.jsx)(n.code,{children:"g++"}),", ",(0,s.jsx)(n.code,{children:"clang++"}),", ",(0,s.jsx)(n.code,{children:"msvc"}),", and ",(0,s.jsx)(n.code,{children:"clang-cl"})," with ",(0,s.jsx)(n.code,{children:"msvc"}),". It replaces the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options with the ",(0,s.jsx)(n.code,{children:"-Z7"})," for debug builds as the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options are not supported (",(0,s.jsx)(n.a,{href:"https://github.com/ccache/ccache/issues/1040",children:"link"})," to the issue) and disables ",(0,s.jsx)(n.code,{children:"precompile_header"})," if ",(0,s.jsx)(n.code,{children:"ccache"})," ",(0,s.jsx)(n.code,{children:"<4.10"})," as they are not supported on Windows."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"tom_example"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build the ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," console application example."]})]})]})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Advanced ",(0,s.jsx)(n.code,{children:"TinyORM"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Option Name"}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ubsan"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Allows to enable ",(0,s.jsx)(n.a,{href:"https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html",children:"UBSan"})," sanitizer (Clang only)."]})]})})]})})}),"\n",(0,s.jsxs)(n.p,{children:["Important ",(0,s.jsx)(n.code,{children:"qmake"})," options."]}),"\n",(0,s.jsx)("div",{className:"apitable-build-options",children:(0,s.jsx)(l.A,{name:"qmake",children:(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.th,{children:[(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)("small",{children:"Option Name"})]}),(0,s.jsx)(n.th,{children:"Default"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ccache"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable compiler cache. ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:"Homepage"}),(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["It works only on the Unix systems. It works well with ",(0,s.jsx)(n.code,{children:"g++"})," and ",(0,s.jsx)(n.code,{children:"clang++"})," and also supports precompiled headers. TinyORM overrides this qmake option with the ",(0,s.jsx)(n.a,{href:"#ccache",children:(0,s.jsx)(n.code,{children:"ccache"})})," option.",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"#ccache-support",children:"Ccache support"})," for more information."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"ltcg"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Enable ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Interprocedural_optimization",children:"Link time code optimization"})," (",(0,s.jsx)(n.a,{href:"https://wiki.gentoo.org/wiki/LTO",children:"LTO"}),").",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["Works on all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"precompile_header"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"-"})}),(0,s.jsxs)(n.td,{children:["Enable precompiled headers, you can disable them with:",(0,s.jsx)("br",{})," ",(0,s.jsx)(n.code,{children:"CONFIG-=precompile_header"}),".",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"precompile_header"})," is enabled by default on ",(0,s.jsx)(n.code,{children:"msvc"}),", ",(0,s.jsx)(n.code,{children:"g++"}),", ",(0,s.jsx)(n.code,{children:"clang++"}),", ",(0,s.jsx)(n.code,{children:"clang-cl"})," on ",(0,s.jsx)(n.code,{children:"Windows"})," and disabled by default on ",(0,s.jsx)(n.code,{children:"linux"}),"."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"static"}),(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"staticlib"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Build as a ",(0,s.jsx)(n.code,{children:"static"})," library (lib only).",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["If you want to build all libraries in the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project as static library archives and link against static libraries use the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qmake-variable-reference.html#config",children:(0,s.jsx)(n.code,{children:"CONFIG += static"})}),". Don't use the ",(0,s.jsx)(n.code,{children:"CONFIG += staticlib"}),".",(0,s.jsx)("br",{}),"See ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/NOTES.txt",children:"NOTES.txt"})," for more information (search ",(0,s.jsx)(n.code,{children:"static vs staticlib"}),")."]})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"static_runtime"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"OFF"})}),(0,s.jsxs)(n.td,{children:["Link against the ",(0,s.jsx)(n.code,{children:"shared"})," (dynamic) or ",(0,s.jsx)(n.code,{children:"static"})," run-time library.",(0,s.jsx)("br",{}),(0,s.jsxs)("small",{children:["The ",(0,s.jsx)(n.code,{children:"-MD"})," becomes ",(0,s.jsx)(n.code,{children:"-MT"})," and ",(0,s.jsx)(n.code,{children:"-MDd"})," becomes ",(0,s.jsx)(n.code,{children:"-MTd"}),". It works only on ",(0,s.jsx)(n.code,{children:"MSVC"})," and ",(0,s.jsx)(n.code,{children:"MinGW"})," or ",(0,s.jsx)(n.code,{children:"MSYS2"}),".",(0,s.jsx)("br",{}),"Please ",(0,s.jsx)("u",{children:"don't use"})," this option.",(0,s.jsx)("br",{}),"Available when: ",(0,s.jsx)(n.code,{children:"msvc"})," or ",(0,s.jsx)(n.code,{children:"mingw"})]})]})]})]})]})})}),"\n",(0,s.jsxs)(n.h3,{id:"consume-tinyorm-library-qmake",children:["Consume TinyOrm library ",(0,s.jsx)("small",{children:"(qmake)"})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/qmake/TinyOrm.pri",children:(0,s.jsx)(n.code,{children:"TinyOrm.pri"})})," file is available to simplify the integration of the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library into your application. It sets up and configures the ",(0,s.jsx)(n.code,{children:"CONFIG"})," and ",(0,s.jsx)(n.code,{children:"DEFINES"})," qmake variables, adds the ",(0,s.jsx)(n.code,{children:"TinyORM"}),", ",(0,s.jsx)("abbr",{title:"TinyORM Migrations",children:(0,s.jsx)(n.code,{children:"tom"})}),", and ",(0,s.jsx)(n.code,{children:"vcpkg"})," header files on the system ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," (cross-platform using the ",(0,s.jsx)(n.code,{children:"-isystem"})," or ",(0,s.jsx)(n.code,{children:"-imsvc"}),"), links against the TinyORM ",(0,s.jsx)(n.code,{children:"shared"})," or ",(0,s.jsx)(n.code,{children:"static"})," library using the ",(0,s.jsx)(n.code,{children:"LIBS"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["You can use it to configure the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library when you are linking against it. It does a very similar thing like the CMake's ",(0,s.jsx)(n.code,{children:"Find Modules"})," feature."]}),"\n",(0,s.jsx)(n.h4,{id:"requirements",children:"Requirements"}),"\n",(0,s.jsx)(n.p,{children:"It has a few requirements, you need to:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["specify path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,s.jsx)(n.code,{children:".prf"})," files) using the ",(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})," variable that can only be set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file"]}),"\n",(0,s.jsxs)(n.li,{children:["specify ",(0,s.jsx)(n.code,{children:"qmake"})," or ",(0,s.jsx)(n.code,{children:"environment"})," variables to find the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation ",(0,s.jsxs)("small",{children:["(",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," and ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"}),")"]})]}),"\n",(0,s.jsxs)(n.li,{children:["specify path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder ",(0,s.jsxs)("small",{children:["(",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"}),")"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["you can specify it ",(0,s.jsx)(n.strong,{children:"manually"})]}),"\n",(0,s.jsxs)(n.li,{children:["or you can use ",(0,s.jsxs)(n.a,{href:"#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["build your application with the same ",(0,s.jsx)(n.code,{children:"CONFIG"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variables that were used when building the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"Let's explain one by one."}),"\n",(0,s.jsx)(n.h5,{id:"qmakefeatures",children:(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})}),"\n",(0,s.jsxs)(n.p,{children:["Create the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file in your application root folder with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path()\n# To find .env and .env.$$QMAKE_PLATFORM files in YOUR project\nTINY_DOTENV_ROOT = $$PWD\n\n# Path to the TinyORM build folder (specified manually)\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/)\n# vcpkg - range-v3 and tabulate\nTINY_VCPKG_ROOT = $$quote(/vcpkg/)\n#TINY_VCPKG_TRIPLET = x64-windows\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You can move all ",(0,s.jsx)(n.code,{children:"qmake"})," variables that are part of the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process to the ",(0,s.jsx)(n.code,{children:".env"})," file if you want (recommended), this is possible because the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," enables the ",(0,s.jsx)(n.a,{href:"#environment-files",children:(0,s.jsx)(n.code,{children:"Environment files"})})," feature by default."]}),"\n",(0,s.jsxs)(n.p,{children:["You can look at the ",(0,s.jsx)(n.a,{href:"/building/hello-world#auto-configure-using-qmake_conf-and-env",children:"Auto-configure using .qmake.conf and .env"})," example for ",(0,s.jsx)(n.code,{children:"Hello world"})," project of what must stay in the ",(0,s.jsx)(n.code,{children:"qmake.conf"})," file and what can be moved to the ",(0,s.jsx)(n.code,{children:".env"})," files."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsxs)(n.a,{href:"#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually."]})}),"\n",(0,s.jsxs)(n.h5,{id:"variables-affecting-tinyormpri",children:["Variables affecting ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})]}),"\n",(0,s.jsxs)(n.p,{children:["You must define the following variables before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," is included:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," to use ",(0,s.jsx)("small",{children:"(vcpkg/installed/$$TINY_VCPKG_TRIPLET/)"}),".",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," based on the current compiler and OS (based on the ",(0,s.jsx)(n.code,{children:"QMAKESPEC"}),"), and as the last thing, it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})," environment variable."]})]})]})]}),"\n",(0,s.jsx)(n.p,{children:"These variables will be set after the configuration is done:"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_BUILD_SUBFOLDER"})}),(0,s.jsxs)(n.td,{children:["Folder by release type if ",(0,s.jsx)(n.code,{children:"CONFIG+=debug_and_release"})," is defined ",(0,s.jsx)("small",{children:"(/debug, /release, or an empty string)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_CCACHE_BUILD"})}),(0,s.jsxs)(n.td,{children:["To correctly link ",(0,s.jsx)(n.code,{children:"ccache"})," build against a ",(0,s.jsx)(n.code,{children:"ccache"})," build ",(0,s.jsx)("small",{children:"(_ccache or an empty string)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MSVC_VERSION"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"MSVC"})," compiler string ",(0,s.jsx)("small",{children:"(MSVC2022 or MSVC2019)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_QT_VERSION_UNDERSCORED"})}),(0,s.jsxs)(n.td,{children:["Underscored ",(0,s.jsx)(n.code,{children:"Qt"})," version ",(0,s.jsx)("small",{children:"(eg. 6_7_2)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_RELEASE_TYPE_CAMEL"})}),(0,s.jsxs)(n.td,{children:["Build type string ",(0,s.jsx)("small",{children:"(Debug, Profile, or Release)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(vcpkg/installed//include/)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Then you simply include the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," in your project file."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='AnyProject.pro'",children:"include($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["And that is all, now you should be able to link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library. \ud83d\udc4c"]}),"\n",(0,s.jsx)(n.h5,{id:"manual-configuration-examples",children:"Manual configuration examples"}),"\n",(0,s.jsxs)(n.p,{children:["Frankly, there is no reason to use the Manual configuration (define the variables described below before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," inclusion), the only reason to use it is when you want more control over this process or want to define everything yourself. I'll leave this section here to show how things work."]}),"\n",(0,s.jsxs)(n.p,{children:["You will have to link against the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library manually if you don't set the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variable before the inclusion of the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," file. The ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," is auto-detected every time."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"{9}",children:"# Link against TinyORM library\n# ---\nTINY_MAIN_DIR = $$clean_path()\n\n# Configure TinyORM library\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n\n# TinyORM library path\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake)\nLIBS += $$quote(-L$$TINYORM_BUILD_TREE/build-TinyORM-Desktop_Qt_6_7_2_MSVC2019_64bit-Debug/src$${TINY_BUILD_SUBFOLDER}/)\nLIBS += -lTinyOrm\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"{9}",children:"# Link against TinyORM library\n# ---\nTINY_MAIN_DIR = $$clean_path()\n\n# Configure TinyORM library\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n\n# TinyORM library path\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake)\nLIBS += $$quote(-L$$TINYORM_BUILD_TREE/build-TinyORM-Desktop_Qt_6_7_2_GCC_64bit-Debug/src$${TINY_BUILD_SUBFOLDER}/)\nLIBS += -lTinyOrm\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"vcpkg"})," include path. If you don't set the ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," or have not defined the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable, then you need to set up the ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," for the ",(0,s.jsx)(n.code,{children:"vcpkg"})," that provides the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," header files."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nINCLUDEPATH += $$quote(/vcpkg/installed/x64-windows/include/)\n"})})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nQMAKE_CXXFLAGS += -isystem $$shell_quote(/vcpkg/installed/x64-linux/include/)\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["You can also use TinyORM's ",(0,s.jsx)(n.code,{children:"qmake"})," function ",(0,s.jsx)(n.code,{children:"tiny_add_system_includepath()"})," which handles ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," in a cross-platform way."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# vcpkg - range-v3 and tabulate\n# ---\nload(private/tiny_system_includepath)\ntiny_add_system_includepath(/vcpkg/installed/x64-linux/include/)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so your application can find it during execution."]}),"\n",(0,s.jsxs)(o.A,{groupId:y.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(t.A,{value:y.b,label:y.ux,children:(0,s.jsx)(c.A,{className:"language-powershell",children:`$env:Path = "${(0,x.OZ)(y.b,!1)}\\TinyORM\\TinyORM-builds-qmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(t.A,{value:y.xj,label:y.gg,children:(0,s.jsx)(c.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,x.OZ)(y.xj)}/TinyORM/TinyORM-builds-qmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.p,{children:["On Linux ",(0,s.jsx)(n.code,{children:"-isystem"})," marks the directory as a system directory, it prevents warnings."]}),(0,s.jsxs)(n.p,{children:["On Windows you can use ",(0,s.jsx)(n.code,{children:"QMAKE_CXXFLAGS_WARN_ON = -external:anglebrackets -external:W0"}),", it applies a warning level 0 to the angel bracket includes; ",(0,s.jsx)(n.code,{children:"#include "}),"."]}),(0,s.jsxs)(n.p,{children:["With the ",(0,s.jsx)(n.code,{children:"Clang-cl"})," with ",(0,s.jsx)(n.code,{children:"MSVC"})," you can use ",(0,s.jsx)(n.code,{children:"-imsvc"}),"."]})]}),"\n",(0,s.jsx)(n.h3,{id:"auto-configuration-internals",children:"Auto-configuration internals"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"qmake"})," build system does not support ",(0,s.jsx)(n.code,{children:"auto-configuration"})," of dependencies out of the box but ",(0,s.jsx)(n.code,{children:"TinyORM"})," from ",(0,s.jsx)(n.code,{children:"v0.34.0"})," added its own ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature along with the ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," qmake feature. These new features allow us to ",(0,s.jsx)(n.code,{children:"auto-configure"})," ",(0,s.jsx)(n.code,{children:"TinyORM"})," project, and with their help, the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files can be ",(0,s.jsx)("u",{children:"skipped entirely"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["While it adds additional complexity to the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process, the benefits are significant."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature is designed to find the ",(0,s.jsx)(n.code,{children:"vcpkg"})," and ",(0,s.jsx)(n.code,{children:"MySQL"})," installations, and ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," to include the ",(0,s.jsx)(n.code,{children:".env"})," and ",(0,s.jsx)(n.code,{children:".env.(win32|unix|mingw)"})," files in the project's root folder. These new features can be configured using ",(0,s.jsx)(n.code,{children:"qmake"})," and ",(0,s.jsx)(n.code,{children:"environment"})," variables, and they also contain some guessing logic if these variables are not defined."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_autoconf",children:(0,s.jsx)(n.code,{children:"disable_autoconf"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_autoconf"}),")."]}),"\n",(0,s.jsxs)(n.p,{children:["These are ",(0,s.jsx)("u",{children:(0,s.jsx)(n.code,{children:"qmake"})})," and ",(0,s.jsx)("u",{children:(0,s.jsx)(n.code,{children:"environment"})})," variables that affect the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_TRIPLET"})}),(0,s.jsxs)(n.td,{children:["The ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," to use ",(0,s.jsx)("small",{children:"(vcpkg/installed/$$TINY_VCPKG_TRIPLET/)"}),".",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"triplet"})," based on the current compiler and OS (based on the ",(0,s.jsx)(n.code,{children:"QMAKESPEC"}),"), and as the last thing, it tries to use the ",(0,s.jsx)(n.code,{children:"VCPKG_DEFAULT_TRIPLET"})," environment variable."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_ROOT"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," installation folder.",(0,s.jsx)("br",{}),"If not defined, then it tries to guess the ",(0,s.jsx)(n.code,{children:"MySQL"})," installation folder (",(0,s.jsx)(n.code,{children:"win32"})," only): ",(0,s.jsx)("code",{children:"$$(ProgramFiles)/MySQL/MySQL Server (9.0|8.4|8.3|8.2|8.1|8.0|5.7)/"})]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["You can set these variables in the ",(0,s.jsx)(n.code,{children:".env"})," (recommended) or ",(0,s.jsx)(n.code,{children:"conf.pri"})," files, in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file (or wherever you want), or as environment variables."]}),"\n",(0,s.jsxs)(n.p,{children:["These variables will be set after ",(0,s.jsx)(n.code,{children:"auto-configuration"})," is done:"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_VCPKG_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"vcpkg"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(vcpkg/installed//include/)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_INCLUDE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," ",(0,s.jsx)(n.code,{children:"include"})," folder ",(0,s.jsx)("small",{children:"(MySQL Server 9.0/include/)"}),"."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MYSQL_LIB"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.code,{children:"MySQL"})," ",(0,s.jsx)(n.code,{children:"lib"})," folder ",(0,s.jsx)("small",{children:"(MySQL Server 9.0/lib/)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TINY_MYSQL_INCLUDE"})," and ",(0,s.jsx)(n.code,{children:"TINY_MYSQL_LIB"})," are only set on ",(0,s.jsx)(n.code,{children:"win32"})," platform except ",(0,s.jsx)(n.code,{children:"mingw"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"environment-files",children:"Environment files"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature allows us to define the ",(0,s.jsx)(n.code,{children:".env"})," and ",(0,s.jsx)(n.code,{children:".env.$$TINY_DOTENV_PLATFORM"})," files in the project's root folder. These files are loaded as early as possible so you can affect the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration process. On the other hand, the ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are loaded as late as possible, and they can be used to override the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:".env"})," file is included ",(0,s.jsx)("u",{children:"first"})," and is included on all platforms."]}),"\n",(0,s.jsxs)(n.p,{children:["There is only one requirement for this feature to work correctly, and that is to set the ",(0,s.jsx)(n.code,{children:"TINY_DOTENV_ROOT"})," ",(0,s.jsx)(n.code,{children:"qmake"})," variable to the project's root folder. This variable is ",(0,s.jsx)(n.strong,{children:"already"})," set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file for the ",(0,s.jsx)(n.code,{children:"TinyORM"})," project."]}),"\n",(0,s.jsx)(n.p,{children:"Then the following names are taken into account: .env, .env.win32, .env.unix, .env.mingw"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tiny_dotenv"})," feature can be turned off using the ",(0,s.jsx)(n.a,{href:"#disable_dotenv",children:(0,s.jsx)(n.code,{children:"disable_dotenv"})})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration option (eg. ",(0,s.jsx)(n.code,{children:"CONFIG*=disable_dotenv"}),")."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Environment files"})," don't work in the ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]})}),"\n",(0,s.jsxs)(n.h4,{id:"partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]}),"\n",(0,s.jsxs)(n.p,{children:["You don't have to manually define the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," in ",(0,s.jsx)(n.code,{children:".env"})," or ",(0,s.jsx)(n.code,{children:".qmake.conf"})," files. The ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," absolute path can be put together for you (this is happening inside the ",(0,s.jsx)(n.code,{children:"variables.pri"})," file) and ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder name can be guessed for you too."]}),"\n",(0,s.jsxs)(n.p,{children:["You must define the following variables before the ",(0,s.jsx)(n.code,{children:"TinyOrm.pri"})," will be included to make this real (set them in the ",(0,s.jsx)(n.code,{children:".qmake.conf"}),"):"]}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Variable Name"}),(0,s.jsx)(n.th,{children:"Description"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_MAIN_DIR"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.strong,{children:"PARENT"})," folder of the ",(0,s.jsx)(n.code,{children:"TinyORM"})," source folder."]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE"})}),(0,s.jsxs)(n.td,{children:["Path to the ",(0,s.jsx)(n.strong,{children:"current"})," build tree - ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"}),"."]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TINY_MAIN_DIR"})," is required for another features anyway (so it should already be set) and all that's left is to set the ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the current build tree (used to guess the TinyORM build tree)\nTINY_BUILD_TREE = $$shadowed($$PWD)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["If you will follow this pattern or logic then you can switch ",(0,s.jsx)(n.code,{children:"QtCreator Kits"})," and the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," will be ",(0,s.jsx)(n.strong,{children:"auto-generated"})," correctly and will always point to the correct ",(0,s.jsx)(n.code,{children:"TinyORM"})," build tree."]}),"\n",(0,s.jsxs)(n.p,{children:["It works this way, all is happening inside the ",(0,s.jsx)(n.code,{children:"variables.pri"}),", it takes a build folder name for the ",(0,s.jsx)(n.strong,{children:"current"})," project eg. ",(0,s.jsx)(n.code,{children:"build-HelloWorld-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug"}),", replaces the ",(0,s.jsx)(n.code,{children:"HelloWorld"})," with the ",(0,s.jsx)(n.code,{children:"TinyORM"})," and as we already know the ",(0,s.jsx)(n.code,{children:"TinyORM"})," build folder location we can simply concatenate these paths like ",(0,s.jsx)(n.code,{children:"$$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["This will only work if you follow the recommended ",(0,s.jsx)(n.a,{href:"#folders-structure",children:(0,s.jsx)(n.code,{children:"Folders structure"})}),"."]})}),"\n",(0,s.jsx)(n.h3,{id:"manual-configuration-internals",children:"Manual configuration internals"}),"\n",(0,s.jsxs)(n.p,{children:["There is not much to say about the ",(0,s.jsx)(n.code,{children:"Manual configuration"})," feature. It uses ",(0,s.jsx)(n.code,{children:"conf.pri"})," files (there are four, one for every project or sub-project), and every project has prepared its own ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," file for faster initial configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["These ",(0,s.jsx)(n.code,{children:"conf.pri.example"})," files are nicely commented on, so you can see what needs to be modified. The ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are loaded as late as possible, and they can be used to override the ",(0,s.jsx)(n.code,{children:"qmake"})," configuration."]}),"\n",(0,s.jsxs)(n.p,{children:["If the ",(0,s.jsx)(n.code,{children:"Auto-configuration"})," feature is disabled and there are no ",(0,s.jsx)(n.code,{children:"conf.pri"})," files, then the ",(0,s.jsx)(n.code,{children:"TinyORM"})," ",(0,s.jsx)(n.code,{children:"qmake"})," configuration or build will fail at 100%."]}),"\n",(0,s.jsxs)(n.p,{children:["These ",(0,s.jsx)(n.code,{children:"conf.pri"})," files are intended for configuring qmake's ",(0,s.jsx)(n.code,{children:"INCLUDEPATH"})," and ",(0,s.jsx)(n.code,{children:"LIBS"}),", ",(0,s.jsx)(n.code,{children:"CONFIG"})," or eg. ",(0,s.jsx)(n.code,{children:"QMAKE_LFLAGS"}),", or any other ",(0,s.jsx)(n.code,{children:"qmake"})," options or variables."]}),"\n",(0,s.jsx)(n.h2,{id:"ccache-support",children:"Ccache support"}),"\n",(0,s.jsxs)(n.p,{children:["The TinyORM supports the ",(0,s.jsx)(n.a,{href:"https://ccache.dev/",children:(0,s.jsx)(n.code,{children:"ccache"})})," out of the box for all ",(0,s.jsx)(n.a,{href:"/supported-compilers",children:"supported compilers"}),". For ",(0,s.jsx)(n.code,{children:"qmake"})," you can enable it using the ",(0,s.jsx)(n.a,{href:"#ccache",children:(0,s.jsx)(n.code,{children:"CONFIG+=ccache"})})," and for ",(0,s.jsx)(n.code,{children:"CMake"})," you can set the ",(0,s.jsx)(n.a,{href:"#CMAKE_CXX_COMPILER_LAUNCHER",children:(0,s.jsx)(n.code,{children:"CMAKE_CXX_COMPILER_LAUNCHER=ccache"})}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["On ",(0,s.jsx)(n.code,{children:"Linux"})," it's clear, the ",(0,s.jsx)(n.code,{children:"ccache"})," is fully supported and works also with the ",(0,s.jsx)(n.code,{children:"precompiled headers"}),". But was necessary to add some workarounds to the ",(0,s.jsx)(n.code,{children:"qmake"}),"/",(0,s.jsx)(n.code,{children:"CMake"})," build systems to make out of the box support on ",(0,s.jsx)(n.code,{children:"Windows"}),". When you enable the ",(0,s.jsx)(n.code,{children:"ccache"})," on ",(0,s.jsx)(n.code,{children:"Windows"})," then the build system replaces the ",(0,s.jsx)(n.code,{children:"-Zi"})," and ",(0,s.jsx)(n.code,{children:"-ZI"})," compiler options with the ",(0,s.jsx)(n.code,{children:"-Z7"})," (link to the ",(0,s.jsx)(n.a,{href:"https://github.com/ccache/ccache/issues/1040",children:"issue"}),") and disables ",(0,s.jsx)(n.code,{children:"precompiled headers"})," if ",(0,s.jsx)(n.code,{children:"ccache <4.10"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can install the ",(0,s.jsx)(n.code,{children:"ccache"})," using the ",(0,s.jsx)(n.code,{children:"scoop install ccache"})," command on Windows. See the ",(0,s.jsx)(n.a,{href:"/dependencies#linux-installation-ccache",children:"Dependencies"})," page for how to install ",(0,s.jsx)(n.code,{children:"ccache"})," on Linux."]})})]})}function M(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(I,{...e})}):I(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>l});i(6540);var s=i(4164);const d={tabItem:"tabItem_Ymn6"};var r=i(4848);function l(e){let{children:n,hidden:i,className:l}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,s.A)(d.tabItem,l),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>_});var s=i(6540),d=i(4164),r=i(3104),l=i(6347),c=i(205),t=i(7485),o=i(1682),a=i(679);function h(e){return s.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function x(e){const{values:n,children:i}=e;return(0,s.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:s,default:d}}=e;return{value:n,label:i,attributes:s,default:d}}))}(i);return function(e){const n=(0,o.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function j(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function u(e){let{queryString:n=!1,groupId:i}=e;const d=(0,l.W6)(),r=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,t.aZ)(r),(0,s.useCallback)((e=>{if(!r)return;const n=new URLSearchParams(d.location.search);n.set(r,e),d.replace({...d.location,search:n.toString()})}),[r,d])]}function p(e){const{defaultValue:n,queryString:i=!1,groupId:d}=e,r=x(e),[l,t]=(0,s.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!j({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const s=i.find((e=>e.default))??i[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:n,tabValues:r}))),[o,h]=u({queryString:i,groupId:d}),[p,m]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[d,r]=(0,a.Dv)(i);return[d,(0,s.useCallback)((e=>{i&&r.set(e)}),[i,r])]}({groupId:d}),b=(()=>{const e=o??p;return j({value:e,tabValues:r})?e:null})();(0,c.A)((()=>{b&&t(b)}),[b]);return{selectedValue:l,selectValue:(0,s.useCallback)((e=>{if(!j({value:e,tabValues:r}))throw new Error(`Can't select invalid tab value=${e}`);t(e),h(e),m(e)}),[h,m,r]),tabValues:r}}var m=i(2303);const b={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var f=i(4848);function g(e){let{className:n,block:i,selectedValue:s,selectValue:l,tabValues:c}=e;const t=[],{blockElementScrollPositionUntilNextRender:o}=(0,r.a_)(),a=e=>{const n=e.currentTarget,i=t.indexOf(n),d=c[i].value;d!==s&&(o(n),l(d))},h=e=>{let n=null;switch(e.key){case"Enter":a(e);break;case"ArrowRight":{const i=t.indexOf(e.currentTarget)+1;n=t[i]??t[0];break}case"ArrowLeft":{const i=t.indexOf(e.currentTarget)-1;n=t[i]??t[t.length-1];break}}n?.focus()};return(0,f.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,d.A)("tabs",{"tabs--block":i},n),children:c.map((e=>{let{value:n,label:i,attributes:r}=e;return(0,f.jsx)("li",{role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:e=>t.push(e),onKeyDown:h,onClick:a,...r,className:(0,d.A)("tabs__item",b.tabItem,r?.className,{"tabs__item--active":s===n}),children:i??n},n)}))})}function y(e){let{lazy:n,children:i,selectedValue:r}=e;const l=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=l.find((e=>e.props.value===r));return e?(0,s.cloneElement)(e,{className:(0,d.A)("margin-top--md",e.props.className)}):null}return(0,f.jsx)("div",{className:"margin-top--md",children:l.map(((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==r})))})}function T(e){const n=p(e);return(0,f.jsxs)("div",{className:(0,d.A)("tabs-container",b.tabList),children:[(0,f.jsx)(g,{...n,...e}),(0,f.jsx)(y,{...n,...e})]})}function _(e){const n=(0,m.A)();return(0,f.jsx)(T,{...e,children:h(e.children)},String(n))}},6684:(e,n,i)=>{i.d(n,{A:()=>a});var s=i(6540),d=i(3427),r=i(6347);const l={apiTable:"apiTable_flxF"};var c=i(4848);function t(e,n){let{name:i,children:l}=e;const t=function(e){let n=e;for(;(0,s.isValidElement)(n);)[n]=s.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(l),o=i?`${i}-${t}`:t,a=`#${o}`,h=(0,r.W6)();return(0,d.A)().collectAnchor(o),(0,c.jsx)("tr",{id:o,tabIndex:0,ref:h.location.hash===a?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||h.push(a)},onKeyDown:e=>{"Enter"===e.key&&h.push(a)},children:l.props.children})}const o=s.forwardRef(t);function a(e){let{children:n,name:i}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[d,r]=s.Children.toArray(n.props.children),t=(0,s.useRef)(null);(0,s.useEffect)((()=>{t.current?.focus()}),[t]);const a=s.Children.map(r.props.children,(e=>(0,c.jsx)(o,{name:i,ref:t,children:e})));return(0,c.jsxs)("table",{className:l.apiTable,children:[d,(0,c.jsx)("tbody",{children:a})]})}},7324:(e,n,i)=>{i.d(n,{$E:()=>m,A3:()=>f,CW:()=>b,Dx:()=>a,F4:()=>x,Fi:()=>o,J_:()=>_,LQ:()=>g,Lf:()=>v,OO:()=>d,Q7:()=>y,b:()=>c,cy:()=>t,gg:()=>u,kl:()=>j,os:()=>h,pW:()=>r,ux:()=>p,vf:()=>s,xj:()=>l,xt:()=>T});const s="shell",d="database",r="application",l="bash",c="pwsh",t="zsh",o="maria",a="mysql",h="postgres",x="sqlite",j="application",u="bash",p="pwsh",m="zsh",b="MariaDB",f="MySQL",g="PostgreSQL",y="SQLite",T="tinyorm.org",_="$HOME/Code/c/",v="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>r});var s=i(6540),d=i(1838);function r(){const e=(0,s.useContext)(d.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>t,Sn:()=>l,T3:()=>a,bw:()=>o,nC:()=>h,np:()=>c});var s=i(6362),d=i(2303),r=i(7324);const l=function(e,n){return void 0===n&&(n=!0),x((0,s.A)().rootFolder[e]??o(e),e,n)},c=()=>(0,s.A)().rootFolder[r.pW]??o(r.pW),t=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==r.b?"/":"\\";return x(l(e)+i+c(),e,n)};function o(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,d.A)())return"";switch(e){case r.b:return r.Lf;case r.xj:return r.J_;case r.pW:return r.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function a(e){return e===r.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case r.b:return u(n).replace(/\$env:(.+?)(\/.*)/,i);case r.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function x(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==r.b)return j(e);const s=j(e);return i?u(s):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(s)}function j(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function u(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},2721:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-additional_arguments-14d3b6b82ad6d28db5b999a462500a6a.png"},7619:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-build_settings-7caa6d7c86232484b82acb24b5a3a6a7.png"},885:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-configure_project-0b6821ea0523567dab9f21b3215055a3.png"}}]); \ No newline at end of file diff --git a/assets/js/1222ea4e.9aaae761.js b/assets/js/1222ea4e.9aaae761.js new file mode 100644 index 000000000..f80d58cfb --- /dev/null +++ b/assets/js/1222ea4e.9aaae761.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[153],{3392:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var t=i(4848),s=i(8453),o=i(8774);const r={sidebar_position:4,sidebar_label:"Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",keywords:["c++ orm","orm","serialization","json","toJson","serializing models","serializing relations","serializing collections","converting","toList","toMap"]},a="TinyORM: Serialization",l={id:"tinyorm/serialization",title:"TinyORM: Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",source:"@site/docs/tinyorm/serialization.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/serialization",permalink:"/tinyorm/serialization",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:4,frontMatter:{sidebar_position:4,sidebar_label:"Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",keywords:["c++ orm","orm","serialization","json","toJson","serializing models","serializing relations","serializing collections","converting","toList","toMap"]},sidebar:"tinyormSidebar",previous:{title:"Casts",permalink:"/tinyorm/casts"},next:{title:"Getting Started",permalink:"/tinydrivers/getting-started"}},d={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Serializing Models & Collections",id:"serializing-models-and-collections",level:2},{value:"Serializing To Vectors & Maps",id:"serializing-to-vectors-and-maps",level:3},{value:"Serializing To JSON",id:"serializing-to-json",level:3},{value:"Relationships",id:"relationships",level:4},{value:"Hiding Attributes From JSON",id:"hiding-attributes-from-json",level:2},{value:"Temporarily Modifying Attribute Visibility",id:"temporarily-modifying-attribute-visibility",level:4},{value:"Appending Values To JSON",id:"appending-values-to-json",level:2},{value:"Appending At Run Time",id:"appending-at-run-time",level:4},{value:"Date Serialization",id:"date-serialization",level:2},{value:"Customizing The Default Date Format",id:"customizing-the-default-date-format",level:4},{value:"Customizing The Date Format Per Attribute",id:"customizing-the-date-format-per-attribute",level:4}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"tinyorm-serialization",children:"TinyORM: Serialization"})}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"#serializing-models-and-collections",children:"Serializing Models & Collections"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#serializing-to-vectors-and-maps",children:"Serializing To Vectors & Maps"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#serializing-to-json",children:"Serializing To JSON"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#hiding-attributes-from-json",children:"Hiding Attributes From JSON"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#appending-values-to-json",children:"Appending Values To JSON"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#date-serialization",children:"Date Serialization"})}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,t.jsx)("div",{className:"api-stability alert alert--success",children:(0,t.jsxs)(n.p,{children:[(0,t.jsx)(o.A,{to:"/stability#stability-indexes",children:(0,t.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,t.jsx)(n.p,{children:"When building APIs using TinyORM, you will often need to convert your models and relationships to vectors, maps, or JSON. TinyORM includes convenient methods for making these conversions, as well as controlling which attributes are included in the serialized representation of your models."}),"\n",(0,t.jsx)(n.h2,{id:"serializing-models-and-collections",children:"Serializing Models & Collections"}),"\n",(0,t.jsx)(n.h3,{id:"serializing-to-vectors-and-maps",children:"Serializing To Vectors & Maps"}),"\n",(0,t.jsxs)(n.p,{children:["To convert a model and its loaded ",(0,t.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationships"})," to a vector, you should use the ",(0,t.jsx)(n.code,{children:"toList"})," or ",(0,t.jsx)(n.code,{children:"toMap"})," methods. This methods are recursive, so all attributes and all relations (including the relations of relations) will be converted to vectors:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nauto user = User::with("roles")->first();\n\nreturn user->toList();\n\nreturn user->toMap();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"attributesToList"})," or ",(0,t.jsx)(n.code,{children:"attributesToMap"})," methods may be used to convert a model's attributes to a vector or map but not its relationships:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:"auto user = User::first();\n\nreturn user->attributesToList();\n\nreturn user->attributesToMap();\n"})}),"\n",(0,t.jsxs)(n.p,{children:["You may also convert entire ",(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"collections"})," of models to vectors or maps by calling the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tolist",children:(0,t.jsx)(n.code,{children:"toList"})})," or ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tomap",children:(0,t.jsx)(n.code,{children:"toMap"})})," methods on the collection instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = User::with("roles")->all();\n\nreturn users.toList();\n\nreturn users.toMap();\n'})}),"\n",(0,t.jsx)(n.h3,{id:"serializing-to-json",children:"Serializing To JSON"}),"\n",(0,t.jsxs)(n.p,{children:["To convert a model to JSON, you should use the ",(0,t.jsx)(n.code,{children:"toJson"})," method. Like ",(0,t.jsx)(n.code,{children:"toList"})," or ",(0,t.jsx)(n.code,{children:"toMap"}),", the ",(0,t.jsx)(n.code,{children:"toJson"})," method is recursive, so all attributes and relations will be converted to JSON. You may also specify any JSON encoding options that are supported by ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html#toJson",children:"QJsonDocument::toJson"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nauto user = User::with("roles")->find(1);\n\nreturn user->toJson();\n\nreturn user->toJson(QJsonDocument::Indented);\n'})}),"\n",(0,t.jsxs)(n.p,{children:["You may also convert entire ",(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"collections"})," of models to JSON by calling the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojson",children:(0,t.jsx)(n.code,{children:"toJson"})})," method on the collection instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = User::with("roles")->findMany({1, 2});\n\nreturn users.toJson();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["You can also convert models to the ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonobject.html",children:(0,t.jsx)(n.code,{children:"QJsonObject"})})," and ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,t.jsx)(n.code,{children:"QJsonDocument"})})," using the ",(0,t.jsx)(n.code,{children:"toJsonArray"})," and ",(0,t.jsx)(n.code,{children:"toJsonDocument"})," methods and collection of models to ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonarray.html",children:(0,t.jsx)(n.code,{children:"QJsonArray"})})," and ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,t.jsx)(n.code,{children:"QJsonDocument"})})," using the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojsonarray",children:(0,t.jsx)(n.code,{children:"toJsonArray"})})," and ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojsondocument",children:(0,t.jsx)(n.code,{children:"toJsonDocument"})})," methods."]}),"\n",(0,t.jsx)(n.h4,{id:"relationships",children:"Relationships"}),"\n",(0,t.jsx)(n.p,{children:'When a TinyORM model is converted to JSON, its loaded relationships will automatically be included as attributes on the JSON object. Also, though TinyORM relationship methods are defined using "camelCase" method names, a relationship\'s JSON attributes will be "snake_case".'}),"\n",(0,t.jsxs)(n.p,{children:["This behavior is affected and can be overridden by the ",(0,t.jsx)(n.code,{children:"u_snakeAttributes"})," static data member:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Album final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! Indicates whether attributes are snake_cased during serialization. */\n inline static const bool u_snakeAttributes = false;\n};\n"})}),"\n",(0,t.jsx)(n.h2,{id:"hiding-attributes-from-json",children:"Hiding Attributes From JSON"}),"\n",(0,t.jsxs)(n.p,{children:["Sometimes you may wish to limit the attributes, such as passwords, that are included in your model's vector, map, or JSON representation. To do so, add a ",(0,t.jsx)(n.code,{children:"u_hidden"})," static data member to your model. Attributes that are listed in the ",(0,t.jsx)(n.code,{children:"u_hidden"})," data member set will not be included in the serialized representation of your model:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be hidden during serialization. */\n inline static std::set u_hidden {"password"};\n};\n'})}),"\n",(0,t.jsx)(n.admonition,{type:"note",children:(0,t.jsxs)(n.p,{children:["To hide relationships, add the relationship's method name to your TinyORM model's ",(0,t.jsx)(n.code,{children:"u_hidden"})," static data member."]})}),"\n",(0,t.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,t.jsx)(n.code,{children:"u_visible"}),' static data member to define an "allow list" of attributes that should be included in your model\'s vector, map, and JSON representation. All attributes that are not present in the ',(0,t.jsx)(n.code,{children:"u_visible"})," set will be hidden during serialization:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be visible during serialization. */\n inline static std::set u_visible {\n "first_name", "last_name",\n };\n};\n'})}),"\n",(0,t.jsx)(n.h4,{id:"temporarily-modifying-attribute-visibility",children:"Temporarily Modifying Attribute Visibility"}),"\n",(0,t.jsxs)(n.p,{children:["If you would like to make some typically hidden attributes visible on a given model instance, you may use the ",(0,t.jsx)(n.code,{children:"makeVisible"})," method. The ",(0,t.jsx)(n.code,{children:"makeVisible"})," method returns a model reference:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.makeVisible("attribute").toMap();\n\nreturn user.makeVisible({"id", "name"}).toMap();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Likewise, if you would like to hide some attributes that are typically visible, you may use the ",(0,t.jsx)(n.code,{children:"makeHidden"})," method."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.makeHidden("attribute").toList();\n\nreturn user.makeHidden({"id", "name"}).toList();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["If you wish to temporarily override all of the visible or hidden attributes, you may use the ",(0,t.jsx)(n.code,{children:"setVisible"})," and ",(0,t.jsx)(n.code,{children:"setHidden"})," methods respectively:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.setVisible({"id", "name"}).toMap();\n\nreturn user.setHidden({"email", "password", "note"}).toJson();\n'})}),"\n",(0,t.jsx)(n.p,{children:"You can also clear all visible and hidden attributes or determine whether a visible / hidden attribute is defined:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'user.clearVisible();\n\nuser.clearHidden();\n\nreturn user.hasVisible("name");\n\nreturn user.hasHidden("password");\n'})}),"\n",(0,t.jsx)(n.h2,{id:"appending-values-to-json",children:"Appending Values To JSON"}),"\n",(0,t.jsxs)(n.p,{children:["Occasionally, when converting models to vector, map, or JSON, you may wish to add attributes that do not have a corresponding column in your database. To do so, first define an ",(0,t.jsx)(n.a,{href:"/tinyorm/casts#accessors",children:"accessor"})," for the value:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\nprotected:\n /*! Accessor to determine if the user is an administrator. */\n Attribute isAdmin() const noexcept\n {\n return Attribute::make(/* get */ []() -> QVariant\n {\n return QStringLiteral("yes");\n });\n }\n};\n'})}),"\n",(0,t.jsxs)(n.p,{children:["If you would like the accessor to always be appended to your model's vector, map, and JSON representations, you may add the attribute name to the ",(0,t.jsx)(n.code,{children:"u_appends"}),' data member set of your model. Note that attribute names are typically referenced using their "snake_case" serialized representation, even though the accessor\'s method name is defined using "camelCase":']}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! Map of mutator names to methods. */\n inline static const QHash u_mutators {\n {"is_admin", &User::isAdmin},\n };\n\n /*! The attributes that should be appended during serialization. */\n std::set u_appends {"is_admin"};\n};\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Once the attribute has been added to the ",(0,t.jsx)(n.code,{children:"u_appends"})," set, it will be included in both the model's vector, map, and JSON representations. Attributes in the ",(0,t.jsx)(n.code,{children:"u_appends"})," set will also respect the ",(0,t.jsx)(n.code,{children:"u_visible"})," and ",(0,t.jsx)(n.code,{children:"u_hidden"})," attribute settings configured on the model."]}),"\n",(0,t.jsxs)(n.p,{children:["Special note should be given to the ",(0,t.jsx)(n.code,{children:"u_mutators"})," static data member map, which maps accessors' attribute names to its methods. This data member is ",(0,t.jsx)(n.strong,{children:"required"})," because C++ does not currently support reflection."]}),"\n",(0,t.jsx)(n.h4,{id:"appending-at-run-time",children:"Appending At Run Time"}),"\n",(0,t.jsxs)(n.p,{children:["At runtime, you may instruct a model instance to append additional attributes using the ",(0,t.jsx)(n.code,{children:"append"})," method. Or, you may use the ",(0,t.jsx)(n.code,{children:"setAppends"})," method to override the entire set of appended attributes for a given model instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.append("is_admin").toList();\n\nreturn user.append({"is_admin", "is_banned"}).toMap();\n\nreturn user.setAppends({"is_admin"}).toJson();\n'})}),"\n",(0,t.jsx)(n.p,{children:"And you can also clear all appends or determine whether an append is defined:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'user.clearAppends();\n\nreturn user.hasAppend("is_admin");\n'})}),"\n",(0,t.jsx)(n.h2,{id:"date-serialization",children:"Date Serialization"}),"\n",(0,t.jsx)(n.h4,{id:"customizing-the-default-date-format",children:"Customizing The Default Date Format"}),"\n",(0,t.jsxs)(n.p,{children:["You may customize the default serialization format by overriding the ",(0,t.jsx)(n.code,{children:"serializeDate"})," and ",(0,t.jsx)(n.code,{children:"serializeDateTime"})," methods. These methods do not affect how your dates are formatted for storage in the database:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'/*! Prepare a date for vector, map, or JSON serialization. */\nQString serializeDate(const QDate date)\n{\n return date.toString("yyyy-MM-dd");\n}\n\n/*! Prepare a datetime for vector, map, or JSON serialization. */\nQString serializeDateTime(const QDateTime &datetime)\n{\n return datetime.toUTC().toString("yyyy-MM-ddTHH:mm:ssZ");\n}\n'})}),"\n",(0,t.jsx)(n.h4,{id:"customizing-the-date-format-per-attribute",children:"Customizing The Date Format Per Attribute"}),"\n",(0,t.jsxs)(n.p,{children:["You may customize the serialization format of individual TinyORM date attributes by specifying the date format in the model's ",(0,t.jsx)(n.a,{href:"/tinyorm/casts#attribute-casting",children:"cast declarations"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'/*! The attributes that should be cast. */\ninline static std::unordered_map u_casts {\n {"birthday", {CastType::CustomQDate, "yyyy-MM-dd"}},\n {"joined_at", {CastType::CustomQDateTime, "yyyy-MM-dd HH:00"}},\n};\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>a});var t=i(6540);const s={},o=t.createContext(s);function r(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1222ea4e.a36e63d0.js b/assets/js/1222ea4e.a36e63d0.js deleted file mode 100644 index 2398925e4..000000000 --- a/assets/js/1222ea4e.a36e63d0.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[153],{3392:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var t=i(4848),s=i(8453),o=i(8774);const r={sidebar_position:4,sidebar_label:"Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",keywords:["c++ orm","orm","serialization","json","toJson","serializing models","serializing relations","serializing collections","converting","toList","toMap"]},a="TinyORM: Serialization",l={id:"tinyorm/serialization",title:"TinyORM: Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",source:"@site/docs/tinyorm/serialization.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/serialization",permalink:"/tinyorm/serialization",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:4,frontMatter:{sidebar_position:4,sidebar_label:"Serialization",description:"TinyORM models serialization allows you to serialize models and collection of models including all nested relations to JSON. It also supports converting to vectors or maps and allows controlling a custom date format during serialization.",keywords:["c++ orm","orm","serialization","json","toJson","serializing models","serializing relations","serializing collections","converting","toList","toMap"]},sidebar:"tinyormSidebar",previous:{title:"Casts",permalink:"/tinyorm/casts"},next:{title:"Getting Started",permalink:"/tinydrivers/getting-started"}},d={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Serializing Models & Collections",id:"serializing-models-and-collections",level:2},{value:"Serializing To Vectors & Maps",id:"serializing-to-vectors-and-maps",level:3},{value:"Serializing To JSON",id:"serializing-to-json",level:3},{value:"Relationships",id:"relationships",level:4},{value:"Hiding Attributes From JSON",id:"hiding-attributes-from-json",level:2},{value:"Temporarily Modifying Attribute Visibility",id:"temporarily-modifying-attribute-visibility",level:4},{value:"Appending Values To JSON",id:"appending-values-to-json",level:2},{value:"Appending At Run Time",id:"appending-at-run-time",level:4},{value:"Date Serialization",id:"date-serialization",level:2},{value:"Customizing The Default Date Format",id:"customizing-the-default-date-format",level:4},{value:"Customizing The Date Format Per Attribute",id:"customizing-the-date-format-per-attribute",level:4}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"tinyorm-serialization",children:"TinyORM: Serialization"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"#serializing-models-and-collections",children:"Serializing Models & Collections"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#serializing-to-vectors-and-maps",children:"Serializing To Vectors & Maps"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#serializing-to-json",children:"Serializing To JSON"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#hiding-attributes-from-json",children:"Hiding Attributes From JSON"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#appending-values-to-json",children:"Appending Values To JSON"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#date-serialization",children:"Date Serialization"})}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,t.jsx)("div",{class:"api-stability alert alert--success",children:(0,t.jsxs)(n.p,{children:[(0,t.jsx)(o.A,{to:"/stability#stability-indexes",children:(0,t.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,t.jsx)(n.p,{children:"When building APIs using TinyORM, you will often need to convert your models and relationships to vectors, maps, or JSON. TinyORM includes convenient methods for making these conversions, as well as controlling which attributes are included in the serialized representation of your models."}),"\n",(0,t.jsx)(n.h2,{id:"serializing-models-and-collections",children:"Serializing Models & Collections"}),"\n",(0,t.jsx)(n.h3,{id:"serializing-to-vectors-and-maps",children:"Serializing To Vectors & Maps"}),"\n",(0,t.jsxs)(n.p,{children:["To convert a model and its loaded ",(0,t.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationships"})," to a vector, you should use the ",(0,t.jsx)(n.code,{children:"toList"})," or ",(0,t.jsx)(n.code,{children:"toMap"})," methods. This methods are recursive, so all attributes and all relations (including the relations of relations) will be converted to vectors:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nauto user = User::with("roles")->first();\n\nreturn user->toList();\n\nreturn user->toMap();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.code,{children:"attributesToList"})," or ",(0,t.jsx)(n.code,{children:"attributesToMap"})," methods may be used to convert a model's attributes to a vector or map but not its relationships:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:"auto user = User::first();\n\nreturn user->attributesToList();\n\nreturn user->attributesToMap();\n"})}),"\n",(0,t.jsxs)(n.p,{children:["You may also convert entire ",(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"collections"})," of models to vectors or maps by calling the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tolist",children:(0,t.jsx)(n.code,{children:"toList"})})," or ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tomap",children:(0,t.jsx)(n.code,{children:"toMap"})})," methods on the collection instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = User::with("roles")->all();\n\nreturn users.toList();\n\nreturn users.toMap();\n'})}),"\n",(0,t.jsx)(n.h3,{id:"serializing-to-json",children:"Serializing To JSON"}),"\n",(0,t.jsxs)(n.p,{children:["To convert a model to JSON, you should use the ",(0,t.jsx)(n.code,{children:"toJson"})," method. Like ",(0,t.jsx)(n.code,{children:"toList"})," or ",(0,t.jsx)(n.code,{children:"toMap"}),", the ",(0,t.jsx)(n.code,{children:"toJson"})," method is recursive, so all attributes and relations will be converted to JSON. You may also specify any JSON encoding options that are supported by ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html#toJson",children:"QJsonDocument::toJson"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nauto user = User::with("roles")->find(1);\n\nreturn user->toJson();\n\nreturn user->toJson(QJsonDocument::Indented);\n'})}),"\n",(0,t.jsxs)(n.p,{children:["You may also convert entire ",(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"collections"})," of models to JSON by calling the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojson",children:(0,t.jsx)(n.code,{children:"toJson"})})," method on the collection instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = User::with("roles")->findMany({1, 2});\n\nreturn users.toJson();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["You can also convert models to the ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonobject.html",children:(0,t.jsx)(n.code,{children:"QJsonObject"})})," and ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,t.jsx)(n.code,{children:"QJsonDocument"})})," using the ",(0,t.jsx)(n.code,{children:"toJsonArray"})," and ",(0,t.jsx)(n.code,{children:"toJsonDocument"})," methods and collection of models to ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonarray.html",children:(0,t.jsx)(n.code,{children:"QJsonArray"})})," and ",(0,t.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,t.jsx)(n.code,{children:"QJsonDocument"})})," using the ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojsonarray",children:(0,t.jsx)(n.code,{children:"toJsonArray"})})," and ",(0,t.jsx)(n.a,{href:"/tinyorm/collections#method-tojsondocument",children:(0,t.jsx)(n.code,{children:"toJsonDocument"})})," methods."]}),"\n",(0,t.jsx)(n.h4,{id:"relationships",children:"Relationships"}),"\n",(0,t.jsx)(n.p,{children:'When a TinyORM model is converted to JSON, its loaded relationships will automatically be included as attributes on the JSON object. Also, though TinyORM relationship methods are defined using "camelCase" method names, a relationship\'s JSON attributes will be "snake_case".'}),"\n",(0,t.jsxs)(n.p,{children:["This behavior is affected and can be overridden by the ",(0,t.jsx)(n.code,{children:"u_snakeAttributes"})," static data member:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Album final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! Indicates whether attributes are snake_cased during serialization. */\n inline static const bool u_snakeAttributes = false;\n};\n"})}),"\n",(0,t.jsx)(n.h2,{id:"hiding-attributes-from-json",children:"Hiding Attributes From JSON"}),"\n",(0,t.jsxs)(n.p,{children:["Sometimes you may wish to limit the attributes, such as passwords, that are included in your model's vector, map, or JSON representation. To do so, add a ",(0,t.jsx)(n.code,{children:"u_hidden"})," static data member to your model. Attributes that are listed in the ",(0,t.jsx)(n.code,{children:"u_hidden"})," data member set will not be included in the serialized representation of your model:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be hidden during serialization. */\n inline static std::set u_hidden {"password"};\n};\n'})}),"\n",(0,t.jsx)(n.admonition,{type:"note",children:(0,t.jsxs)(n.p,{children:["To hide relationships, add the relationship's method name to your TinyORM model's ",(0,t.jsx)(n.code,{children:"u_hidden"})," static data member."]})}),"\n",(0,t.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,t.jsx)(n.code,{children:"u_visible"}),' static data member to define an "allow list" of attributes that should be included in your model\'s vector, map, and JSON representation. All attributes that are not present in the ',(0,t.jsx)(n.code,{children:"u_visible"})," set will be hidden during serialization:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be visible during serialization. */\n inline static std::set u_visible {\n "first_name", "last_name",\n };\n};\n'})}),"\n",(0,t.jsx)(n.h4,{id:"temporarily-modifying-attribute-visibility",children:"Temporarily Modifying Attribute Visibility"}),"\n",(0,t.jsxs)(n.p,{children:["If you would like to make some typically hidden attributes visible on a given model instance, you may use the ",(0,t.jsx)(n.code,{children:"makeVisible"})," method. The ",(0,t.jsx)(n.code,{children:"makeVisible"})," method returns a model reference:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.makeVisible("attribute").toMap();\n\nreturn user.makeVisible({"id", "name"}).toMap();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Likewise, if you would like to hide some attributes that are typically visible, you may use the ",(0,t.jsx)(n.code,{children:"makeHidden"})," method."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.makeHidden("attribute").toList();\n\nreturn user.makeHidden({"id", "name"}).toList();\n'})}),"\n",(0,t.jsxs)(n.p,{children:["If you wish to temporarily override all of the visible or hidden attributes, you may use the ",(0,t.jsx)(n.code,{children:"setVisible"})," and ",(0,t.jsx)(n.code,{children:"setHidden"})," methods respectively:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.setVisible({"id", "name"}).toMap();\n\nreturn user.setHidden({"email", "password", "note"}).toJson();\n'})}),"\n",(0,t.jsx)(n.p,{children:"You can also clear all visible and hidden attributes or determine whether a visible / hidden attribute is defined:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'user.clearVisible();\n\nuser.clearHidden();\n\nreturn user.hasVisible("name");\n\nreturn user.hasHidden("password");\n'})}),"\n",(0,t.jsx)(n.h2,{id:"appending-values-to-json",children:"Appending Values To JSON"}),"\n",(0,t.jsxs)(n.p,{children:["Occasionally, when converting models to vector, map, or JSON, you may wish to add attributes that do not have a corresponding column in your database. To do so, first define an ",(0,t.jsx)(n.a,{href:"/tinyorm/casts#accessors",children:"accessor"})," for the value:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\nprotected:\n /*! Accessor to determine if the user is an administrator. */\n Attribute isAdmin() const noexcept\n {\n return Attribute::make(/* get */ []() -> QVariant\n {\n return QStringLiteral("yes");\n });\n }\n};\n'})}),"\n",(0,t.jsxs)(n.p,{children:["If you would like the accessor to always be appended to your model's vector, map, and JSON representations, you may add the attribute name to the ",(0,t.jsx)(n.code,{children:"u_appends"}),' data member set of your model. Note that attribute names are typically referenced using their "snake_case" serialized representation, even though the accessor\'s method name is defined using "camelCase":']}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! Map of mutator names to methods. */\n inline static const QHash u_mutators {\n {"is_admin", &User::isAdmin},\n };\n\n /*! The attributes that should be appended during serialization. */\n std::set u_appends {"is_admin"};\n};\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Once the attribute has been added to the ",(0,t.jsx)(n.code,{children:"u_appends"})," set, it will be included in both the model's vector, map, and JSON representations. Attributes in the ",(0,t.jsx)(n.code,{children:"u_appends"})," set will also respect the ",(0,t.jsx)(n.code,{children:"u_visible"})," and ",(0,t.jsx)(n.code,{children:"u_hidden"})," attribute settings configured on the model."]}),"\n",(0,t.jsxs)(n.p,{children:["Special note should be given to the ",(0,t.jsx)(n.code,{children:"u_mutators"})," static data member map, which maps accessors' attribute names to its methods. This data member is ",(0,t.jsx)(n.strong,{children:"required"})," because C++ does not currently support reflection."]}),"\n",(0,t.jsx)(n.h4,{id:"appending-at-run-time",children:"Appending At Run Time"}),"\n",(0,t.jsxs)(n.p,{children:["At runtime, you may instruct a model instance to append additional attributes using the ",(0,t.jsx)(n.code,{children:"append"})," method. Or, you may use the ",(0,t.jsx)(n.code,{children:"setAppends"})," method to override the entire set of appended attributes for a given model instance:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'return user.append("is_admin").toList();\n\nreturn user.append({"is_admin", "is_banned"}).toMap();\n\nreturn user.setAppends({"is_admin"}).toJson();\n'})}),"\n",(0,t.jsx)(n.p,{children:"And you can also clear all appends or determine whether an append is defined:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'user.clearAppends();\n\nreturn user.hasAppend("is_admin");\n'})}),"\n",(0,t.jsx)(n.h2,{id:"date-serialization",children:"Date Serialization"}),"\n",(0,t.jsx)(n.h4,{id:"customizing-the-default-date-format",children:"Customizing The Default Date Format"}),"\n",(0,t.jsxs)(n.p,{children:["You may customize the default serialization format by overriding the ",(0,t.jsx)(n.code,{children:"serializeDate"})," and ",(0,t.jsx)(n.code,{children:"serializeDateTime"})," methods. These methods do not affect how your dates are formatted for storage in the database:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'/*! Prepare a date for vector, map, or JSON serialization. */\nQString serializeDate(const QDate date)\n{\n return date.toString("yyyy-MM-dd");\n}\n\n/*! Prepare a datetime for vector, map, or JSON serialization. */\nQString serializeDateTime(const QDateTime &datetime)\n{\n return datetime.toUTC().toString("yyyy-MM-ddTHH:mm:ssZ");\n}\n'})}),"\n",(0,t.jsx)(n.h4,{id:"customizing-the-date-format-per-attribute",children:"Customizing The Date Format Per Attribute"}),"\n",(0,t.jsxs)(n.p,{children:["You may customize the serialization format of individual TinyORM date attributes by specifying the date format in the model's ",(0,t.jsx)(n.a,{href:"/tinyorm/casts#attribute-casting",children:"cast declarations"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-cpp",children:'/*! The attributes that should be cast. */\ninline static std::unordered_map u_casts {\n {"birthday", {CastType::CustomQDate, "yyyy-MM-dd"}},\n {"joined_at", {CastType::CustomQDateTime, "yyyy-MM-dd HH:00"}},\n};\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>a});var t=i(6540);const s={},o=t.createContext(s);function r(e){const n=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),t.createElement(o.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/158.811bb36f.js b/assets/js/158.811bb36f.js new file mode 100644 index 000000000..57ae5e361 --- /dev/null +++ b/assets/js/158.811bb36f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[158],{8158:(r,a,e)=>{e.r(a),e.d(a,{DocSearchModal:()=>o.a1});var o=e(3219)}}]); \ No newline at end of file diff --git a/assets/js/17896441.7e577731.js b/assets/js/17896441.b87ba7c0.js similarity index 57% rename from assets/js/17896441.7e577731.js rename to assets/js/17896441.b87ba7c0.js index 2d8bb4726..6051fca83 100644 --- a/assets/js/17896441.7e577731.js +++ b/assets/js/17896441.b87ba7c0.js @@ -1 +1 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[401],{4086:(e,n,t)=>{t.r(n),t.d(n,{default:()=>jn});var s=t(6540),i=t(9024),a=t(9532),l=t(4848);const o=s.createContext(null);function r(e){let{children:n,content:t}=e;const i=function(e){return(0,s.useMemo)((()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc})),[e])}(t);return(0,l.jsx)(o.Provider,{value:i,children:n})}function c(){const e=(0,s.useContext)(o);if(null===e)throw new a.dV("DocProvider");return e}function d(){const{metadata:e,frontMatter:n,assets:t}=c();return(0,l.jsx)(i.be,{title:e.title,description:e.description,keywords:n.keywords,image:t.image??n.image})}var u=t(4164),m=t(4581),h=t(1312),x=t(8774);function p(e){const{permalink:n,title:t,subLabel:s,isNext:i}=e;return(0,l.jsxs)(x.A,{className:(0,u.A)("pagination-nav__link",i?"pagination-nav__link--next":"pagination-nav__link--prev"),to:n,children:[s&&(0,l.jsx)("div",{className:"pagination-nav__sublabel",children:s}),(0,l.jsx)("div",{className:"pagination-nav__label",children:t})]})}function f(e){const{previous:n,next:t}=e;return(0,l.jsxs)("nav",{className:"pagination-nav docusaurus-mt-lg","aria-label":(0,h.T)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"}),children:[n&&(0,l.jsx)(p,{...n,subLabel:(0,l.jsx)(h.A,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc",children:"Previous"})}),t&&(0,l.jsx)(p,{...t,subLabel:(0,l.jsx)(h.A,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc",children:"Next"}),isNext:!0})]})}function v(){const{metadata:e}=c();return(0,l.jsx)(f,{previous:e.previous,next:e.next})}var g=t(4586),j=t(4070),b=t(7559),A=t(5597),N=t(2252);const C={unreleased:function(e){let{siteTitle:n,versionMetadata:t}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:n,versionLabel:(0,l.jsx)("b",{children:t.label})},children:"This is unreleased documentation for {siteTitle} {versionLabel} version."})},unmaintained:function(e){let{siteTitle:n,versionMetadata:t}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:n,versionLabel:(0,l.jsx)("b",{children:t.label})},children:"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained."})}};function L(e){const n=C[e.versionMetadata.banner];return(0,l.jsx)(n,{...e})}function _(e){let{versionLabel:n,to:t,onClick:s}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:n,latestVersionLink:(0,l.jsx)("b",{children:(0,l.jsx)(x.A,{to:t,onClick:s,children:(0,l.jsx)(h.A,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label",children:"latest version"})})})},children:"For up-to-date documentation, see the {latestVersionLink} ({versionLabel})."})}function T(e){let{className:n,versionMetadata:t}=e;const{siteConfig:{title:s}}=(0,g.A)(),{pluginId:i}=(0,j.vT)({failfast:!0}),{savePreferredVersionName:a}=(0,A.g1)(i),{latestDocSuggestion:o,latestVersionSuggestion:r}=(0,j.HW)(i),c=o??(d=r).docs.find((e=>e.id===d.mainDocId));var d;return(0,l.jsxs)("div",{className:(0,u.A)(n,b.G.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert",children:[(0,l.jsx)("div",{children:(0,l.jsx)(L,{siteTitle:s,versionMetadata:t})}),(0,l.jsx)("div",{className:"margin-top--md",children:(0,l.jsx)(_,{versionLabel:r.label,to:c.path,onClick:()=>a(r.name)})})]})}function y(e){let{className:n}=e;const t=(0,N.r)();return t.banner?(0,l.jsx)(T,{className:n,versionMetadata:t}):null}function k(e){let{className:n}=e;const t=(0,N.r)();return t.badge?(0,l.jsx)("span",{className:(0,u.A)(n,b.G.docs.docVersionBadge,"badge badge--secondary"),children:(0,l.jsx)(h.A,{id:"theme.docs.versionBadge.label",values:{versionLabel:t.label},children:"Version: {versionLabel}"})}):null}const H={tag:"tag_zVej",tagRegular:"tagRegular_sFm0",tagWithCount:"tagWithCount_h2kH"};function w(e){let{permalink:n,label:t,count:s,description:i}=e;return(0,l.jsxs)(x.A,{href:n,title:i,className:(0,u.A)(H.tag,s?H.tagWithCount:H.tagRegular),children:[t,s&&(0,l.jsx)("span",{children:s})]})}const M={tags:"tags_jXut",tag:"tag_QGVx"};function U(e){let{tags:n}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("b",{children:(0,l.jsx)(h.A,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list",children:"Tags:"})}),(0,l.jsx)("ul",{className:(0,u.A)(M.tags,"padding--none","margin-left--sm"),children:n.map((e=>(0,l.jsx)("li",{className:M.tag,children:(0,l.jsx)(w,{...e})},e.permalink)))})]})}const B={iconEdit:"iconEdit_Z9Sw"};function E(e){let{className:n,...t}=e;return(0,l.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,u.A)(B.iconEdit,n),"aria-hidden":"true",...t,children:(0,l.jsx)("g",{children:(0,l.jsx)("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})})})}function I(e){let{editUrl:n}=e;return(0,l.jsxs)(x.A,{to:n,className:b.G.common.editThisPage,children:[(0,l.jsx)(E,{}),(0,l.jsx)(h.A,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}function z(e){void 0===e&&(e={});const{i18n:{currentLocale:n}}=(0,g.A)(),t=function(){const{i18n:{currentLocale:e,localeConfigs:n}}=(0,g.A)();return n[e].calendar}();return new Intl.DateTimeFormat(n,{calendar:t,...e})}function S(e){let{lastUpdatedAt:n}=e;const t=new Date(n),s=z({day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(t);return(0,l.jsx)(h.A,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,l.jsx)("b",{children:(0,l.jsx)("time",{dateTime:t.toISOString(),itemProp:"dateModified",children:s})})},children:" on {date}"})}function V(e){let{lastUpdatedBy:n}=e;return(0,l.jsx)(h.A,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,l.jsx)("b",{children:n})},children:" by {user}"})}function R(e){let{lastUpdatedAt:n,lastUpdatedBy:t}=e;return(0,l.jsxs)("span",{className:b.G.common.lastUpdated,children:[(0,l.jsx)(h.A,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:n?(0,l.jsx)(S,{lastUpdatedAt:n}):"",byUser:t?(0,l.jsx)(V,{lastUpdatedBy:t}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const D={lastUpdated:"lastUpdated_JAkA"};function G(e){let{className:n,editUrl:t,lastUpdatedAt:s,lastUpdatedBy:i}=e;return(0,l.jsxs)("div",{className:(0,u.A)("row",n),children:[(0,l.jsx)("div",{className:"col",children:t&&(0,l.jsx)(I,{editUrl:t})}),(0,l.jsx)("div",{className:(0,u.A)("col",D.lastUpdated),children:(s||i)&&(0,l.jsx)(R,{lastUpdatedAt:s,lastUpdatedBy:i})})]})}function O(){const{metadata:e}=c(),{editUrl:n,lastUpdatedAt:t,lastUpdatedBy:s,tags:i}=e,a=i.length>0,o=!!(n||t||s);return a||o?(0,l.jsxs)("footer",{className:(0,u.A)(b.G.docs.docFooter,"docusaurus-mt-lg"),children:[a&&(0,l.jsx)("div",{className:(0,u.A)("row margin-top--sm",b.G.docs.docFooterTagsRow),children:(0,l.jsx)("div",{className:"col",children:(0,l.jsx)(U,{tags:i})})}),o&&(0,l.jsx)(G,{className:(0,u.A)("margin-top--sm",b.G.docs.docFooterEditMetaRow),editUrl:n,lastUpdatedAt:t,lastUpdatedBy:s})]}):null}var P=t(1422),F=t(6342);function q(e){const n=e.map((e=>({...e,parentIndex:-1,children:[]}))),t=Array(7).fill(-1);n.forEach(((e,n)=>{const s=t.slice(2,e.level);e.parentIndex=Math.max(...s),t[e.level]=n}));const s=[];return n.forEach((e=>{const{parentIndex:t,...i}=e;t>=0?n[t].children.push(i):s.push(i)})),s}function W(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:s}=e;return n.flatMap((e=>{const n=W({toc:e.children,minHeadingLevel:t,maxHeadingLevel:s});return function(e){return e.level>=t&&e.level<=s}(e)?[{...e,children:n}]:n}))}function $(e){const n=e.getBoundingClientRect();return n.top===n.bottom?$(e.parentNode):n}function Z(e,n){let{anchorTopOffset:t}=n;const s=e.find((e=>$(e).top>=t));if(s){return function(e){return e.top>0&&e.bottom{e.current=n?0:document.querySelector(".navbar").clientHeight}),[n]),e}function Y(e){const n=(0,s.useRef)(void 0),t=J();(0,s.useEffect)((()=>{if(!e)return()=>{};const{linkClassName:s,linkActiveClassName:i,minHeadingLevel:a,maxHeadingLevel:l}=e;function o(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(s),o=function(e){let{minHeadingLevel:n,maxHeadingLevel:t}=e;const s=[];for(let i=n;i<=t;i+=1)s.push(`h${i}.anchor`);return Array.from(document.querySelectorAll(s.join()))}({minHeadingLevel:a,maxHeadingLevel:l}),r=Z(o,{anchorTopOffset:t.current}),c=e.find((e=>r&&r.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e)));e.forEach((e=>{!function(e,t){t?(n.current&&n.current!==e&&n.current.classList.remove(i),e.classList.add(i),n.current=e):e.classList.remove(i)}(e,e===c)}))}return document.addEventListener("scroll",o),document.addEventListener("resize",o),o(),()=>{document.removeEventListener("scroll",o),document.removeEventListener("resize",o)}}),[e,t])}function Q(e){let{toc:n,className:t,linkClassName:s,isChild:i}=e;return n.length?(0,l.jsx)("ul",{className:i?void 0:t,children:n.map((e=>(0,l.jsxs)("li",{children:[(0,l.jsx)(x.A,{to:`#${e.id}`,className:s??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,l.jsx)(Q,{isChild:!0,toc:e.children,className:t,linkClassName:s})]},e.id)))}):null}const X=s.memo(Q);function K(e){let{toc:n,className:t="table-of-contents table-of-contents__left-border",linkClassName:i="table-of-contents__link",linkActiveClassName:a,minHeadingLevel:o,maxHeadingLevel:r,...c}=e;const d=(0,F.p)(),u=o??d.tableOfContents.minHeadingLevel,m=r??d.tableOfContents.maxHeadingLevel,h=function(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:i}=e;return(0,s.useMemo)((()=>W({toc:q(n),minHeadingLevel:t,maxHeadingLevel:i})),[n,t,i])}({toc:n,minHeadingLevel:u,maxHeadingLevel:m});return Y((0,s.useMemo)((()=>{if(i&&a)return{linkClassName:i,linkActiveClassName:a,minHeadingLevel:u,maxHeadingLevel:m}}),[i,a,u,m])),(0,l.jsx)(X,{toc:h,className:t,linkClassName:i,...c})}const ee={tocCollapsibleButton:"tocCollapsibleButton_TO0P",tocCollapsibleButtonExpanded:"tocCollapsibleButtonExpanded_MG3E"};function ne(e){let{collapsed:n,...t}=e;return(0,l.jsx)("button",{type:"button",...t,className:(0,u.A)("clean-btn",ee.tocCollapsibleButton,!n&&ee.tocCollapsibleButtonExpanded,t.className),children:(0,l.jsx)(h.A,{id:"theme.TOCCollapsible.toggleButtonLabel",description:"The label used by the button on the collapsible TOC component",children:"On this page"})})}const te={tocCollapsible:"tocCollapsible_ETCw",tocCollapsibleContent:"tocCollapsibleContent_vkbj",tocCollapsibleExpanded:"tocCollapsibleExpanded_sAul"};function se(e){let{toc:n,className:t,minHeadingLevel:s,maxHeadingLevel:i}=e;const{collapsed:a,toggleCollapsed:o}=(0,P.u)({initialState:!0});return(0,l.jsxs)("div",{className:(0,u.A)(te.tocCollapsible,!a&&te.tocCollapsibleExpanded,t),children:[(0,l.jsx)(ne,{collapsed:a,onClick:o}),(0,l.jsx)(P.N,{lazy:!0,className:te.tocCollapsibleContent,collapsed:a,children:(0,l.jsx)(K,{toc:n,minHeadingLevel:s,maxHeadingLevel:i})})]})}const ie={tocMobile:"tocMobile_ITEo"};function ae(){const{toc:e,frontMatter:n}=c();return(0,l.jsx)(se,{toc:e,minHeadingLevel:n.toc_min_heading_level,maxHeadingLevel:n.toc_max_heading_level,className:(0,u.A)(b.G.docs.docTocMobile,ie.tocMobile)})}const le={tableOfContents:"tableOfContents_bqdL",docItemContainer:"docItemContainer_F8PC"},oe="table-of-contents__link toc-highlight",re="table-of-contents__link--active";function ce(e){let{className:n,...t}=e;return(0,l.jsx)("div",{className:(0,u.A)(le.tableOfContents,"thin-scrollbar",n),children:(0,l.jsx)(K,{...t,linkClassName:oe,linkActiveClassName:re})})}function de(){const{toc:e,frontMatter:n}=c();return(0,l.jsx)(ce,{toc:e,minHeadingLevel:n.toc_min_heading_level,maxHeadingLevel:n.toc_max_heading_level,className:b.G.docs.docTocDesktop})}var ue=t(1107),me=t(8453),he=t(5260),xe=t(2364);function pe(e){return(0,l.jsx)("code",{...e})}var fe=t(3427),ve=t(2303);const ge={details:"details_lb9f",isBrowser:"isBrowser_bmU9",collapsibleContent:"collapsibleContent_i85q"};function je(e){return!!e&&("SUMMARY"===e.tagName||je(e.parentElement))}function be(e,n){return!!e&&(e===n||be(e.parentElement,n))}function Ae(e){let{summary:n,children:t,...i}=e;(0,fe.A)().collectAnchor(i.id);const a=(0,ve.A)(),o=(0,s.useRef)(null),{collapsed:r,setCollapsed:c}=(0,P.u)({initialState:!i.open}),[d,m]=(0,s.useState)(i.open),h=s.isValidElement(n)?n:(0,l.jsx)("summary",{children:n??"Details"});return(0,l.jsxs)("details",{...i,ref:o,open:d,"data-collapsed":r,className:(0,u.A)(ge.details,a&&ge.isBrowser,i.className),onMouseDown:e=>{je(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const n=e.target;je(n)&&be(n,o.current)&&(e.preventDefault(),r?(c(!1),m(!0)):c(!0))},children:[h,(0,l.jsx)(P.N,{lazy:!1,collapsed:r,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{c(e),m(!e)},children:(0,l.jsx)("div",{className:ge.collapsibleContent,children:t})})]})}const Ne={details:"details_b_Ee"},Ce="alert alert--info";function Le(e){let{...n}=e;return(0,l.jsx)(Ae,{...n,className:(0,u.A)(Ce,Ne.details,n.className)})}function _e(e){const n=s.Children.toArray(e.children),t=n.find((e=>s.isValidElement(e)&&"summary"===e.type)),i=(0,l.jsx)(l.Fragment,{children:n.filter((e=>e!==t))});return(0,l.jsx)(Le,{...e,summary:t,children:i})}function Te(e){return(0,l.jsx)(ue.A,{...e})}const ye={containsTaskList:"containsTaskList_mC6p"};function ke(e){if(void 0!==e)return(0,u.A)(e,e?.includes("contains-task-list")&&ye.containsTaskList)}const He={img:"img_ev3q"};function we(e){const{mdxAdmonitionTitle:n,rest:t}=function(e){const n=s.Children.toArray(e),t=n.find((e=>s.isValidElement(e)&&"mdxAdmonitionTitle"===e.type)),i=n.filter((e=>e!==t)),a=t?.props.children;return{mdxAdmonitionTitle:a,rest:i.length>0?(0,l.jsx)(l.Fragment,{children:i}):null}}(e.children),i=e.title??n;return{...e,...i&&{title:i},children:t}}const Me={admonition:"admonition_xJq3",admonitionHeading:"admonitionHeading_Gvgb",admonitionIcon:"admonitionIcon_Rf37",admonitionContent:"admonitionContent_BuS1"};function Ue(e){let{type:n,className:t,children:s}=e;return(0,l.jsx)("div",{className:(0,u.A)(b.G.common.admonition,b.G.common.admonitionType(n),Me.admonition,t),children:s})}function Be(e){let{icon:n,title:t}=e;return(0,l.jsxs)("div",{className:Me.admonitionHeading,children:[(0,l.jsx)("span",{className:Me.admonitionIcon,children:n}),t]})}function Ee(e){let{children:n}=e;return n?(0,l.jsx)("div",{className:Me.admonitionContent,children:n}):null}function Ie(e){const{type:n,icon:t,title:s,children:i,className:a}=e;return(0,l.jsxs)(Ue,{type:n,className:a,children:[s||t?(0,l.jsx)(Be,{title:s,icon:t}):null,(0,l.jsx)(Ee,{children:i})]})}function ze(e){return(0,l.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const Se={icon:(0,l.jsx)(ze,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function Ve(e){return(0,l.jsx)(Ie,{...Se,...e,className:(0,u.A)("alert alert--secondary",e.className),children:e.children})}function Re(e){return(0,l.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const De={icon:(0,l.jsx)(Re,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function Ge(e){return(0,l.jsx)(Ie,{...De,...e,className:(0,u.A)("alert alert--success",e.className),children:e.children})}function Oe(e){return(0,l.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const Pe={icon:(0,l.jsx)(Oe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function Fe(e){return(0,l.jsx)(Ie,{...Pe,...e,className:(0,u.A)("alert alert--info",e.className),children:e.children})}function qe(e){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})})}const We={icon:(0,l.jsx)(qe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function $e(e){return(0,l.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const Ze={icon:(0,l.jsx)($e,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const Je={icon:(0,l.jsx)(qe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const Ye={...{note:Ve,tip:Ge,info:Fe,warning:function(e){return(0,l.jsx)(Ie,{...We,...e,className:(0,u.A)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,l.jsx)(Ie,{...Ze,...e,className:(0,u.A)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,l.jsx)(Ve,{title:"secondary",...e}),important:e=>(0,l.jsx)(Fe,{title:"important",...e}),success:e=>(0,l.jsx)(Ge,{title:"success",...e}),caution:function(e){return(0,l.jsx)(Ie,{...Je,...e,className:(0,u.A)("alert alert--warning",e.className),children:e.children})}}};function Qe(e){const n=we(e),t=(s=n.type,Ye[s]||(console.warn(`No admonition component found for admonition type "${s}". Using Info as fallback.`),Ye.info));var s;return(0,l.jsx)(t,{...n})}const Xe={Head:he.A,details:_e,Details:_e,code:function(e){return function(e){return void 0!==e.children&&s.Children.toArray(e.children).every((e=>"string"==typeof e&&!e.includes("\n")))}(e)?(0,l.jsx)(pe,{...e}):(0,l.jsx)(xe.A,{...e})},a:function(e){return(0,l.jsx)(x.A,{...e})},pre:function(e){return(0,l.jsx)(l.Fragment,{children:e.children})},ul:function(e){return(0,l.jsx)("ul",{...e,className:ke(e.className)})},li:function(e){return(0,fe.A)().collectAnchor(e.id),(0,l.jsx)("li",{...e})},img:function(e){return(0,l.jsx)("img",{decoding:"async",loading:"lazy",...e,className:(n=e.className,(0,u.A)(n,He.img))});var n},h1:e=>(0,l.jsx)(Te,{as:"h1",...e}),h2:e=>(0,l.jsx)(Te,{as:"h2",...e}),h3:e=>(0,l.jsx)(Te,{as:"h3",...e}),h4:e=>(0,l.jsx)(Te,{as:"h4",...e}),h5:e=>(0,l.jsx)(Te,{as:"h5",...e}),h6:e=>(0,l.jsx)(Te,{as:"h6",...e}),admonition:Qe,mermaid:()=>null};function Ke(e){let{children:n}=e;return(0,l.jsx)(me.x,{components:Xe,children:n})}function en(e){let{children:n}=e;const t=function(){const{metadata:e,frontMatter:n,contentTitle:t}=c();return n.hide_title||void 0!==t?null:e.title}();return(0,l.jsxs)("div",{className:(0,u.A)(b.G.docs.docMarkdown,"markdown"),children:[t&&(0,l.jsx)("header",{children:(0,l.jsx)(ue.A,{as:"h1",children:t})}),(0,l.jsx)(Ke,{children:n})]})}var nn=t(4142),tn=t(9169),sn=t(6025);function an(e){return(0,l.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,l.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"})})}const ln={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function on(){const e=(0,sn.Ay)("/");return(0,l.jsx)("li",{className:"breadcrumbs__item",children:(0,l.jsx)(x.A,{"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e,children:(0,l.jsx)(an,{className:ln.breadcrumbHomeIcon})})})}const rn={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function cn(e){let{children:n,href:t,isLast:s}=e;const i="breadcrumbs__link";return s?(0,l.jsx)("span",{className:i,itemProp:"name",children:n}):t?(0,l.jsx)(x.A,{className:i,href:t,itemProp:"item",children:(0,l.jsx)("span",{itemProp:"name",children:n})}):(0,l.jsx)("span",{className:i,children:n})}function dn(e){let{children:n,active:t,index:s,addMicrodata:i}=e;return(0,l.jsxs)("li",{...i&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},className:(0,u.A)("breadcrumbs__item",{"breadcrumbs__item--active":t}),children:[n,(0,l.jsx)("meta",{itemProp:"position",content:String(s+1)})]})}function un(){const e=(0,nn.OF)(),n=(0,tn.Dt)();return e?(0,l.jsx)("nav",{className:(0,u.A)(b.G.docs.docBreadcrumbs,rn.breadcrumbsContainer),"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"}),children:(0,l.jsxs)("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList",children:[n&&(0,l.jsx)(on,{}),e.map(((n,t)=>{const s=t===e.length-1,i="category"===n.type&&n.linkUnlisted?void 0:n.href;return(0,l.jsx)(dn,{active:s,index:t,addMicrodata:!!i,children:(0,l.jsx)(cn,{href:i,isLast:s,children:n.label})},t)}))]})}):null}function mn(){return(0,l.jsx)(h.A,{id:"theme.unlistedContent.title",description:"The unlisted content banner title",children:"Unlisted page"})}function hn(){return(0,l.jsx)(h.A,{id:"theme.unlistedContent.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function xn(){return(0,l.jsx)(he.A,{children:(0,l.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}function pn(e){let{className:n}=e;return(0,l.jsx)(Qe,{type:"caution",title:(0,l.jsx)(mn,{}),className:(0,u.A)(n,b.G.common.unlistedBanner),children:(0,l.jsx)(hn,{})})}function fn(e){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(xn,{}),(0,l.jsx)(pn,{...e})]})}const vn={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function gn(e){let{children:n}=e;const t=function(){const{frontMatter:e,toc:n}=c(),t=(0,m.l)(),s=e.hide_table_of_contents,i=!s&&n.length>0;return{hidden:s,mobile:i?(0,l.jsx)(ae,{}):void 0,desktop:!i||"desktop"!==t&&"ssr"!==t?void 0:(0,l.jsx)(de,{})}}(),{metadata:{unlisted:s}}=c();return(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("div",{className:(0,u.A)("col",!t.hidden&&vn.docItemCol),children:[s&&(0,l.jsx)(fn,{}),(0,l.jsx)(y,{}),(0,l.jsxs)("div",{className:vn.docItemContainer,children:[(0,l.jsxs)("article",{children:[(0,l.jsx)(un,{}),(0,l.jsx)(k,{}),t.mobile,(0,l.jsx)(en,{children:n}),(0,l.jsx)(O,{})]}),(0,l.jsx)(v,{})]})]}),t.desktop&&(0,l.jsx)("div",{className:"col col--3",children:t.desktop})]})}function jn(e){const n=`docs-doc-id-${e.content.metadata.id}`,t=e.content;return(0,l.jsx)(r,{content:e.content,children:(0,l.jsxs)(i.e3,{className:n,children:[(0,l.jsx)(d,{}),(0,l.jsx)(gn,{children:(0,l.jsx)(t,{})})]})})}}}]); \ No newline at end of file +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[401],{8222:(e,n,t)=>{t.r(n),t.d(n,{default:()=>Cn});var i=t(6540),s=t(9024),a=t(9532),l=t(4848);const o=i.createContext(null);function r(e){let{children:n,content:t}=e;const s=function(e){return(0,i.useMemo)((()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc})),[e])}(t);return(0,l.jsx)(o.Provider,{value:s,children:n})}function c(){const e=(0,i.useContext)(o);if(null===e)throw new a.dV("DocProvider");return e}function d(){const{metadata:e,frontMatter:n,assets:t}=c();return(0,l.jsx)(s.be,{title:e.title,description:e.description,keywords:n.keywords,image:t.image??n.image})}var u=t(4164),m=t(4581),h=t(1312),x=t(8774);function f(e){const{permalink:n,title:t,subLabel:i,isNext:s}=e;return(0,l.jsxs)(x.A,{className:(0,u.A)("pagination-nav__link",s?"pagination-nav__link--next":"pagination-nav__link--prev"),to:n,children:[i&&(0,l.jsx)("div",{className:"pagination-nav__sublabel",children:i}),(0,l.jsx)("div",{className:"pagination-nav__label",children:t})]})}function p(e){const{previous:n,next:t}=e;return(0,l.jsxs)("nav",{className:"pagination-nav docusaurus-mt-lg","aria-label":(0,h.T)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"}),children:[n&&(0,l.jsx)(f,{...n,subLabel:(0,l.jsx)(h.A,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc",children:"Previous"})}),t&&(0,l.jsx)(f,{...t,subLabel:(0,l.jsx)(h.A,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc",children:"Next"}),isNext:!0})]})}function j(){const{metadata:e}=c();return(0,l.jsx)(p,{previous:e.previous,next:e.next})}var v=t(4586),g=t(4070),b=t(7559),A=t(3886),N=t(3025);const C={unreleased:function(e){let{siteTitle:n,versionMetadata:t}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:n,versionLabel:(0,l.jsx)("b",{children:t.label})},children:"This is unreleased documentation for {siteTitle} {versionLabel} version."})},unmaintained:function(e){let{siteTitle:n,versionMetadata:t}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:n,versionLabel:(0,l.jsx)("b",{children:t.label})},children:"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained."})}};function L(e){const n=C[e.versionMetadata.banner];return(0,l.jsx)(n,{...e})}function _(e){let{versionLabel:n,to:t,onClick:i}=e;return(0,l.jsx)(h.A,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:n,latestVersionLink:(0,l.jsx)("b",{children:(0,l.jsx)(x.A,{to:t,onClick:i,children:(0,l.jsx)(h.A,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label",children:"latest version"})})})},children:"For up-to-date documentation, see the {latestVersionLink} ({versionLabel})."})}function T(e){let{className:n,versionMetadata:t}=e;const{siteConfig:{title:i}}=(0,v.A)(),{pluginId:s}=(0,g.vT)({failfast:!0}),{savePreferredVersionName:a}=(0,A.g1)(s),{latestDocSuggestion:o,latestVersionSuggestion:r}=(0,g.HW)(s),c=o??(d=r).docs.find((e=>e.id===d.mainDocId));var d;return(0,l.jsxs)("div",{className:(0,u.A)(n,b.G.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert",children:[(0,l.jsx)("div",{children:(0,l.jsx)(L,{siteTitle:i,versionMetadata:t})}),(0,l.jsx)("div",{className:"margin-top--md",children:(0,l.jsx)(_,{versionLabel:r.label,to:c.path,onClick:()=>a(r.name)})})]})}function y(e){let{className:n}=e;const t=(0,N.r)();return t.banner?(0,l.jsx)(T,{className:n,versionMetadata:t}):null}function k(e){let{className:n}=e;const t=(0,N.r)();return t.badge?(0,l.jsx)("span",{className:(0,u.A)(n,b.G.docs.docVersionBadge,"badge badge--secondary"),children:(0,l.jsx)(h.A,{id:"theme.docs.versionBadge.label",values:{versionLabel:t.label},children:"Version: {versionLabel}"})}):null}const w={tag:"tag_zVej",tagRegular:"tagRegular_sFm0",tagWithCount:"tagWithCount_h2kH"};function H(e){let{permalink:n,label:t,count:i,description:s}=e;return(0,l.jsxs)(x.A,{href:n,title:s,className:(0,u.A)(w.tag,i?w.tagWithCount:w.tagRegular),children:[t,i&&(0,l.jsx)("span",{children:i})]})}const M={tags:"tags_jXut",tag:"tag_QGVx"};function B(e){let{tags:n}=e;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("b",{children:(0,l.jsx)(h.A,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list",children:"Tags:"})}),(0,l.jsx)("ul",{className:(0,u.A)(M.tags,"padding--none","margin-left--sm"),children:n.map((e=>(0,l.jsx)("li",{className:M.tag,children:(0,l.jsx)(H,{...e})},e.permalink)))})]})}const U={iconEdit:"iconEdit_Z9Sw"};function E(e){let{className:n,...t}=e;return(0,l.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,u.A)(U.iconEdit,n),"aria-hidden":"true",...t,children:(0,l.jsx)("g",{children:(0,l.jsx)("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})})})}function I(e){let{editUrl:n}=e;return(0,l.jsxs)(x.A,{to:n,className:b.G.common.editThisPage,children:[(0,l.jsx)(E,{}),(0,l.jsx)(h.A,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}function V(e){void 0===e&&(e={});const{i18n:{currentLocale:n}}=(0,v.A)(),t=function(){const{i18n:{currentLocale:e,localeConfigs:n}}=(0,v.A)();return n[e].calendar}();return new Intl.DateTimeFormat(n,{calendar:t,...e})}function z(e){let{lastUpdatedAt:n}=e;const t=new Date(n),i=V({day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(t);return(0,l.jsx)(h.A,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,l.jsx)("b",{children:(0,l.jsx)("time",{dateTime:t.toISOString(),itemProp:"dateModified",children:i})})},children:" on {date}"})}function S(e){let{lastUpdatedBy:n}=e;return(0,l.jsx)(h.A,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,l.jsx)("b",{children:n})},children:" by {user}"})}function R(e){let{lastUpdatedAt:n,lastUpdatedBy:t}=e;return(0,l.jsxs)("span",{className:b.G.common.lastUpdated,children:[(0,l.jsx)(h.A,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:n?(0,l.jsx)(z,{lastUpdatedAt:n}):"",byUser:t?(0,l.jsx)(S,{lastUpdatedBy:t}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const D={lastUpdated:"lastUpdated_JAkA"};function G(e){let{className:n,editUrl:t,lastUpdatedAt:i,lastUpdatedBy:s}=e;return(0,l.jsxs)("div",{className:(0,u.A)("row",n),children:[(0,l.jsx)("div",{className:"col",children:t&&(0,l.jsx)(I,{editUrl:t})}),(0,l.jsx)("div",{className:(0,u.A)("col",D.lastUpdated),children:(i||s)&&(0,l.jsx)(R,{lastUpdatedAt:i,lastUpdatedBy:s})})]})}function O(){const{metadata:e}=c(),{editUrl:n,lastUpdatedAt:t,lastUpdatedBy:i,tags:s}=e,a=s.length>0,o=!!(n||t||i);return a||o?(0,l.jsxs)("footer",{className:(0,u.A)(b.G.docs.docFooter,"docusaurus-mt-lg"),children:[a&&(0,l.jsx)("div",{className:(0,u.A)("row margin-top--sm",b.G.docs.docFooterTagsRow),children:(0,l.jsx)("div",{className:"col",children:(0,l.jsx)(B,{tags:s})})}),o&&(0,l.jsx)(G,{className:(0,u.A)("margin-top--sm",b.G.docs.docFooterEditMetaRow),editUrl:n,lastUpdatedAt:t,lastUpdatedBy:i})]}):null}var F=t(1422),P=t(6342);function q(e){const n=e.map((e=>({...e,parentIndex:-1,children:[]}))),t=Array(7).fill(-1);n.forEach(((e,n)=>{const i=t.slice(2,e.level);e.parentIndex=Math.max(...i),t[e.level]=n}));const i=[];return n.forEach((e=>{const{parentIndex:t,...s}=e;t>=0?n[t].children.push(s):i.push(s)})),i}function W(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:i}=e;return n.flatMap((e=>{const n=W({toc:e.children,minHeadingLevel:t,maxHeadingLevel:i});return function(e){return e.level>=t&&e.level<=i}(e)?[{...e,children:n}]:n}))}function $(e){const n=e.getBoundingClientRect();return n.top===n.bottom?$(e.parentNode):n}function Z(e,n){let{anchorTopOffset:t}=n;const i=e.find((e=>$(e).top>=t));if(i){return function(e){return e.top>0&&e.bottom{e.current=n?0:document.querySelector(".navbar").clientHeight}),[n]),e}function Y(e){const n=(0,i.useRef)(void 0),t=J();(0,i.useEffect)((()=>{if(!e)return()=>{};const{linkClassName:i,linkActiveClassName:s,minHeadingLevel:a,maxHeadingLevel:l}=e;function o(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(i),o=function(e){let{minHeadingLevel:n,maxHeadingLevel:t}=e;const i=[];for(let s=n;s<=t;s+=1)i.push(`h${s}.anchor`);return Array.from(document.querySelectorAll(i.join()))}({minHeadingLevel:a,maxHeadingLevel:l}),r=Z(o,{anchorTopOffset:t.current}),c=e.find((e=>r&&r.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e)));e.forEach((e=>{!function(e,t){t?(n.current&&n.current!==e&&n.current.classList.remove(s),e.classList.add(s),n.current=e):e.classList.remove(s)}(e,e===c)}))}return document.addEventListener("scroll",o),document.addEventListener("resize",o),o(),()=>{document.removeEventListener("scroll",o),document.removeEventListener("resize",o)}}),[e,t])}function Q(e){let{toc:n,className:t,linkClassName:i,isChild:s}=e;return n.length?(0,l.jsx)("ul",{className:s?void 0:t,children:n.map((e=>(0,l.jsxs)("li",{children:[(0,l.jsx)(x.A,{to:`#${e.id}`,className:i??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,l.jsx)(Q,{isChild:!0,toc:e.children,className:t,linkClassName:i})]},e.id)))}):null}const X=i.memo(Q);function K(e){let{toc:n,className:t="table-of-contents table-of-contents__left-border",linkClassName:s="table-of-contents__link",linkActiveClassName:a,minHeadingLevel:o,maxHeadingLevel:r,...c}=e;const d=(0,P.p)(),u=o??d.tableOfContents.minHeadingLevel,m=r??d.tableOfContents.maxHeadingLevel,h=function(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:s}=e;return(0,i.useMemo)((()=>W({toc:q(n),minHeadingLevel:t,maxHeadingLevel:s})),[n,t,s])}({toc:n,minHeadingLevel:u,maxHeadingLevel:m});return Y((0,i.useMemo)((()=>{if(s&&a)return{linkClassName:s,linkActiveClassName:a,minHeadingLevel:u,maxHeadingLevel:m}}),[s,a,u,m])),(0,l.jsx)(X,{toc:h,className:t,linkClassName:s,...c})}const ee={tocCollapsibleButton:"tocCollapsibleButton_TO0P",tocCollapsibleButtonExpanded:"tocCollapsibleButtonExpanded_MG3E"};function ne(e){let{collapsed:n,...t}=e;return(0,l.jsx)("button",{type:"button",...t,className:(0,u.A)("clean-btn",ee.tocCollapsibleButton,!n&&ee.tocCollapsibleButtonExpanded,t.className),children:(0,l.jsx)(h.A,{id:"theme.TOCCollapsible.toggleButtonLabel",description:"The label used by the button on the collapsible TOC component",children:"On this page"})})}const te={tocCollapsible:"tocCollapsible_ETCw",tocCollapsibleContent:"tocCollapsibleContent_vkbj",tocCollapsibleExpanded:"tocCollapsibleExpanded_sAul"};function ie(e){let{toc:n,className:t,minHeadingLevel:i,maxHeadingLevel:s}=e;const{collapsed:a,toggleCollapsed:o}=(0,F.u)({initialState:!0});return(0,l.jsxs)("div",{className:(0,u.A)(te.tocCollapsible,!a&&te.tocCollapsibleExpanded,t),children:[(0,l.jsx)(ne,{collapsed:a,onClick:o}),(0,l.jsx)(F.N,{lazy:!0,className:te.tocCollapsibleContent,collapsed:a,children:(0,l.jsx)(K,{toc:n,minHeadingLevel:i,maxHeadingLevel:s})})]})}const se={tocMobile:"tocMobile_ITEo"};function ae(){const{toc:e,frontMatter:n}=c();return(0,l.jsx)(ie,{toc:e,minHeadingLevel:n.toc_min_heading_level,maxHeadingLevel:n.toc_max_heading_level,className:(0,u.A)(b.G.docs.docTocMobile,se.tocMobile)})}const le={tableOfContents:"tableOfContents_bqdL",docItemContainer:"docItemContainer_F8PC"},oe="table-of-contents__link toc-highlight",re="table-of-contents__link--active";function ce(e){let{className:n,...t}=e;return(0,l.jsx)("div",{className:(0,u.A)(le.tableOfContents,"thin-scrollbar",n),children:(0,l.jsx)(K,{...t,linkClassName:oe,linkActiveClassName:re})})}function de(){const{toc:e,frontMatter:n}=c();return(0,l.jsx)(ce,{toc:e,minHeadingLevel:n.toc_min_heading_level,maxHeadingLevel:n.toc_max_heading_level,className:b.G.docs.docTocDesktop})}var ue=t(1107),me=t(8453),he=t(5260),xe=t(2364);function fe(e){return(0,l.jsx)("code",{...e})}var pe=t(3427),je=t(2303);const ve={details:"details_lb9f",isBrowser:"isBrowser_bmU9",collapsibleContent:"collapsibleContent_i85q"};function ge(e){return!!e&&("SUMMARY"===e.tagName||ge(e.parentElement))}function be(e,n){return!!e&&(e===n||be(e.parentElement,n))}function Ae(e){let{summary:n,children:t,...s}=e;(0,pe.A)().collectAnchor(s.id);const a=(0,je.A)(),o=(0,i.useRef)(null),{collapsed:r,setCollapsed:c}=(0,F.u)({initialState:!s.open}),[d,m]=(0,i.useState)(s.open),h=i.isValidElement(n)?n:(0,l.jsx)("summary",{children:n??"Details"});return(0,l.jsxs)("details",{...s,ref:o,open:d,"data-collapsed":r,className:(0,u.A)(ve.details,a&&ve.isBrowser,s.className),onMouseDown:e=>{ge(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const n=e.target;ge(n)&&be(n,o.current)&&(e.preventDefault(),r?(c(!1),m(!0)):c(!0))},children:[h,(0,l.jsx)(F.N,{lazy:!1,collapsed:r,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{c(e),m(!e)},children:(0,l.jsx)("div",{className:ve.collapsibleContent,children:t})})]})}const Ne={details:"details_b_Ee"},Ce="alert alert--info";function Le(e){let{...n}=e;return(0,l.jsx)(Ae,{...n,className:(0,u.A)(Ce,Ne.details,n.className)})}function _e(e){const n=i.Children.toArray(e.children),t=n.find((e=>i.isValidElement(e)&&"summary"===e.type)),s=(0,l.jsx)(l.Fragment,{children:n.filter((e=>e!==t))});return(0,l.jsx)(Le,{...e,summary:t,children:s})}function Te(e){return(0,l.jsx)(ue.A,{...e})}const ye={containsTaskList:"containsTaskList_mC6p"};function ke(e){if(void 0!==e)return(0,u.A)(e,e?.includes("contains-task-list")&&ye.containsTaskList)}const we={img:"img_ev3q"};function He(e){const{mdxAdmonitionTitle:n,rest:t}=function(e){const n=i.Children.toArray(e),t=n.find((e=>i.isValidElement(e)&&"mdxAdmonitionTitle"===e.type)),s=n.filter((e=>e!==t)),a=t?.props.children;return{mdxAdmonitionTitle:a,rest:s.length>0?(0,l.jsx)(l.Fragment,{children:s}):null}}(e.children),s=e.title??n;return{...e,...s&&{title:s},children:t}}const Me={admonition:"admonition_xJq3",admonitionHeading:"admonitionHeading_Gvgb",admonitionIcon:"admonitionIcon_Rf37",admonitionContent:"admonitionContent_BuS1"};function Be(e){let{type:n,className:t,children:i}=e;return(0,l.jsx)("div",{className:(0,u.A)(b.G.common.admonition,b.G.common.admonitionType(n),Me.admonition,t),children:i})}function Ue(e){let{icon:n,title:t}=e;return(0,l.jsxs)("div",{className:Me.admonitionHeading,children:[(0,l.jsx)("span",{className:Me.admonitionIcon,children:n}),t]})}function Ee(e){let{children:n}=e;return n?(0,l.jsx)("div",{className:Me.admonitionContent,children:n}):null}function Ie(e){const{type:n,icon:t,title:i,children:s,className:a}=e;return(0,l.jsxs)(Be,{type:n,className:a,children:[i||t?(0,l.jsx)(Ue,{title:i,icon:t}):null,(0,l.jsx)(Ee,{children:s})]})}function Ve(e){return(0,l.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const ze={icon:(0,l.jsx)(Ve,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function Se(e){return(0,l.jsx)(Ie,{...ze,...e,className:(0,u.A)("alert alert--secondary",e.className),children:e.children})}function Re(e){return(0,l.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const De={icon:(0,l.jsx)(Re,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function Ge(e){return(0,l.jsx)(Ie,{...De,...e,className:(0,u.A)("alert alert--success",e.className),children:e.children})}function Oe(e){return(0,l.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const Fe={icon:(0,l.jsx)(Oe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function Pe(e){return(0,l.jsx)(Ie,{...Fe,...e,className:(0,u.A)("alert alert--info",e.className),children:e.children})}function qe(e){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})})}const We={icon:(0,l.jsx)(qe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function $e(e){return(0,l.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const Ze={icon:(0,l.jsx)($e,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const Je={icon:(0,l.jsx)(qe,{}),title:(0,l.jsx)(h.A,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const Ye={...{note:Se,tip:Ge,info:Pe,warning:function(e){return(0,l.jsx)(Ie,{...We,...e,className:(0,u.A)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,l.jsx)(Ie,{...Ze,...e,className:(0,u.A)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,l.jsx)(Se,{title:"secondary",...e}),important:e=>(0,l.jsx)(Pe,{title:"important",...e}),success:e=>(0,l.jsx)(Ge,{title:"success",...e}),caution:function(e){return(0,l.jsx)(Ie,{...Je,...e,className:(0,u.A)("alert alert--warning",e.className),children:e.children})}}};function Qe(e){const n=He(e),t=(i=n.type,Ye[i]||(console.warn(`No admonition component found for admonition type "${i}". Using Info as fallback.`),Ye.info));var i;return(0,l.jsx)(t,{...n})}const Xe={Head:he.A,details:_e,Details:_e,code:function(e){return function(e){return void 0!==e.children&&i.Children.toArray(e.children).every((e=>"string"==typeof e&&!e.includes("\n")))}(e)?(0,l.jsx)(fe,{...e}):(0,l.jsx)(xe.A,{...e})},a:function(e){return(0,l.jsx)(x.A,{...e})},pre:function(e){return(0,l.jsx)(l.Fragment,{children:e.children})},ul:function(e){return(0,l.jsx)("ul",{...e,className:ke(e.className)})},li:function(e){return(0,pe.A)().collectAnchor(e.id),(0,l.jsx)("li",{...e})},img:function(e){return(0,l.jsx)("img",{decoding:"async",loading:"lazy",...e,className:(n=e.className,(0,u.A)(n,we.img))});var n},h1:e=>(0,l.jsx)(Te,{as:"h1",...e}),h2:e=>(0,l.jsx)(Te,{as:"h2",...e}),h3:e=>(0,l.jsx)(Te,{as:"h3",...e}),h4:e=>(0,l.jsx)(Te,{as:"h4",...e}),h5:e=>(0,l.jsx)(Te,{as:"h5",...e}),h6:e=>(0,l.jsx)(Te,{as:"h6",...e}),admonition:Qe,mermaid:()=>null};function Ke(e){let{children:n}=e;return(0,l.jsx)(me.x,{components:Xe,children:n})}function en(e){let{children:n}=e;const t=function(){const{metadata:e,frontMatter:n,contentTitle:t}=c();return n.hide_title||void 0!==t?null:e.title}();return(0,l.jsxs)("div",{className:(0,u.A)(b.G.docs.docMarkdown,"markdown"),children:[t&&(0,l.jsx)("header",{children:(0,l.jsx)(ue.A,{as:"h1",children:t})}),(0,l.jsx)(Ke,{children:n})]})}var nn=t(6972),tn=t(9169),sn=t(6025);function an(e){return(0,l.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,l.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"})})}const ln={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function on(){const e=(0,sn.Ay)("/");return(0,l.jsx)("li",{className:"breadcrumbs__item",children:(0,l.jsx)(x.A,{"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e,children:(0,l.jsx)(an,{className:ln.breadcrumbHomeIcon})})})}const rn={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function cn(e){let{children:n,href:t,isLast:i}=e;const s="breadcrumbs__link";return i?(0,l.jsx)("span",{className:s,itemProp:"name",children:n}):t?(0,l.jsx)(x.A,{className:s,href:t,itemProp:"item",children:(0,l.jsx)("span",{itemProp:"name",children:n})}):(0,l.jsx)("span",{className:s,children:n})}function dn(e){let{children:n,active:t,index:i,addMicrodata:s}=e;return(0,l.jsxs)("li",{...s&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},className:(0,u.A)("breadcrumbs__item",{"breadcrumbs__item--active":t}),children:[n,(0,l.jsx)("meta",{itemProp:"position",content:String(i+1)})]})}function un(){const e=(0,nn.OF)(),n=(0,tn.Dt)();return e?(0,l.jsx)("nav",{className:(0,u.A)(b.G.docs.docBreadcrumbs,rn.breadcrumbsContainer),"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"}),children:(0,l.jsxs)("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList",children:[n&&(0,l.jsx)(on,{}),e.map(((n,t)=>{const i=t===e.length-1,s="category"===n.type&&n.linkUnlisted?void 0:n.href;return(0,l.jsx)(dn,{active:i,index:t,addMicrodata:!!s,children:(0,l.jsx)(cn,{href:s,isLast:i,children:n.label})},t)}))]})}):null}function mn(){return(0,l.jsx)(h.A,{id:"theme.contentVisibility.unlistedBanner.title",description:"The unlisted content banner title",children:"Unlisted page"})}function hn(){return(0,l.jsx)(h.A,{id:"theme.contentVisibility.unlistedBanner.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function xn(){return(0,l.jsx)(he.A,{children:(0,l.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}function fn(){return(0,l.jsx)(h.A,{id:"theme.contentVisibility.draftBanner.title",description:"The draft content banner title",children:"Draft page"})}function pn(){return(0,l.jsx)(h.A,{id:"theme.contentVisibility.draftBanner.message",description:"The draft content banner message",children:"This page is a draft. It will only be visible in dev and be excluded from the production build."})}function jn(e){let{className:n}=e;return(0,l.jsx)(Qe,{type:"caution",title:(0,l.jsx)(fn,{}),className:(0,u.A)(n,b.G.common.draftBanner),children:(0,l.jsx)(pn,{})})}function vn(e){let{className:n}=e;return(0,l.jsx)(Qe,{type:"caution",title:(0,l.jsx)(mn,{}),className:(0,u.A)(n,b.G.common.unlistedBanner),children:(0,l.jsx)(hn,{})})}function gn(e){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(xn,{}),(0,l.jsx)(vn,{...e})]})}function bn(e){let{metadata:n}=e;const{unlisted:t,frontMatter:i}=n;return(0,l.jsxs)(l.Fragment,{children:[(t||i.unlisted)&&(0,l.jsx)(gn,{}),i.draft&&(0,l.jsx)(jn,{})]})}const An={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function Nn(e){let{children:n}=e;const t=function(){const{frontMatter:e,toc:n}=c(),t=(0,m.l)(),i=e.hide_table_of_contents,s=!i&&n.length>0;return{hidden:i,mobile:s?(0,l.jsx)(ae,{}):void 0,desktop:!s||"desktop"!==t&&"ssr"!==t?void 0:(0,l.jsx)(de,{})}}(),{metadata:i}=c();return(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("div",{className:(0,u.A)("col",!t.hidden&&An.docItemCol),children:[(0,l.jsx)(bn,{metadata:i}),(0,l.jsx)(y,{}),(0,l.jsxs)("div",{className:An.docItemContainer,children:[(0,l.jsxs)("article",{children:[(0,l.jsx)(un,{}),(0,l.jsx)(k,{}),t.mobile,(0,l.jsx)(en,{children:n}),(0,l.jsx)(O,{})]}),(0,l.jsx)(j,{})]})]}),t.desktop&&(0,l.jsx)("div",{className:"col col--3",children:t.desktop})]})}function Cn(e){const n=`docs-doc-id-${e.content.metadata.id}`,t=e.content;return(0,l.jsx)(r,{content:e.content,children:(0,l.jsxs)(s.e3,{className:n,children:[(0,l.jsx)(d,{}),(0,l.jsx)(Nn,{children:(0,l.jsx)(t,{})})]})})}}}]); \ No newline at end of file diff --git a/assets/js/1a4e3797.1fc0de54.js b/assets/js/1a4e3797.1fc0de54.js deleted file mode 100644 index e5907fab4..000000000 --- a/assets/js/1a4e3797.1fc0de54.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see 1a4e3797.1fc0de54.js.LICENSE.txt */ -(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[138],{2733:e=>{function t(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function n(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},t.prototype.emit=function(e){var t,s,a,c,o,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||n(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i(s=this._events[e]))return!1;if(r(s))switch(arguments.length){case 1:s.call(this);break;case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:c=Array.prototype.slice.call(arguments,1),s.apply(this,c)}else if(n(s))for(c=Array.prototype.slice.call(arguments,1),a=(u=s.slice()).length,o=0;o0&&this._events[e].length>a&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},t.prototype.removeListener=function(e,t){var i,s,a,c;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(i=this._events[e]).length,s=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(n(i)){for(c=a;c-- >0;)if(i[c]===t||i[c].listener&&i[c].listener===t){s=c;break}if(s<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)}},4103:(e,t,r)=>{"use strict";var n=r(6571),i=r(9127),s=r(2223),a=r(3371),c=r(7691);function o(e,t,r,i){return new n(e,t,r,i)}o.version=r(6938),o.AlgoliaSearchHelper=n,o.SearchParameters=a,o.RecommendParameters=i,o.SearchResults=c,o.RecommendResults=s,e.exports=o},6732:(e,t,r)=>{"use strict";var n=r(2733);function i(e,t,r){this.main=e,this.fn=t,this.recommendFn=r,this.lastResults=null,this.lastRecommendResults=null}r(3014)(i,n),i.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},i.prototype.getModifiedState=function(e){return this.fn(e)},i.prototype.getModifiedRecommendState=function(e){return this.recommendFn(e)},e.exports=i},9127:e=>{"use strict";function t(e){e=e||{},this.params=e.params||[]}t.prototype={constructor:t,addParams:function(e){var r=this.params.slice();return r.push(e),new t({params:r})},removeParams:function(e){return new t({params:this.params.filter((function(t){return t.$$id!==e}))})},addFrequentlyBoughtTogether:function(e){return this.addParams(Object.assign({},e,{model:"bought-together"}))},addRelatedProducts:function(e){return this.addParams(Object.assign({},e,{model:"related-products"}))},addTrendingItems:function(e){return this.addParams(Object.assign({},e,{model:"trending-items"}))},addTrendingFacets:function(e){return this.addParams(Object.assign({},e,{model:"trending-facets"}))},addLookingSimilar:function(e){return this.addParams(Object.assign({},e,{model:"looking-similar"}))},_buildQueries:function(e,t){return this.params.filter((function(e){return void 0===t[e.$$id]})).map((function(t){var r=Object.assign({},t,{indexName:e});return delete r.$$id,r}))}},e.exports=t},2223:e=>{"use strict";function t(e,t){this._state=e,this._rawResults={};var r=this;e.params.forEach((function(e){var n=e.$$id;r[n]=t[n],r._rawResults[n]=t[n]}))}t.prototype={constructor:t},e.exports=t},1673:(e,t,r)=>{"use strict";var n=r(9110),i=r(317),s=r(1383),a={addRefinement:function(e,t,r){if(a.isRefined(e,t,r))return e;var i=""+r,s=e[t]?e[t].concat(i):[i],c={};return c[t]=s,n({},c,e)},removeRefinement:function(e,t,r){if(void 0===r)return a.clearRefinement(e,(function(e,r){return t===r}));var n=""+r;return a.clearRefinement(e,(function(e,r){return t===r&&n===e}))},toggleRefinement:function(e,t,r){if(void 0===r)throw new Error("toggleRefinement should be used with a value");return a.isRefined(e,t,r)?a.removeRefinement(e,t,r):a.addRefinement(e,t,r)},clearRefinement:function(e,t,r){if(void 0===t)return i(e)?{}:e;if("string"==typeof t)return s(e,[t]);if("function"==typeof t){var n=!1,a=Object.keys(e).reduce((function(i,s){var a=e[s]||[],c=a.filter((function(e){return!t(e,s,r)}));return c.length!==a.length&&(n=!0),i[s]=c,i}),{});return n?a:e}},isRefined:function(e,t,r){var n=Boolean(e[t])&&e[t].length>0;if(void 0===r||!n)return n;var i=""+r;return-1!==e[t].indexOf(i)}};e.exports=a},3371:(e,t,r)=>{"use strict";var n=r(9110),i=r(849),s=r(4843),a=r(4728),c=r(317),o=r(1383),u=r(7507),h=r(2208),f=r(1673);function l(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((function(e,r){return l(t[r],e)})):e===t}function m(e){var t=e?m._parseNumbers(e):{};void 0===t.userToken||h(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var r=this;Object.keys(t).forEach((function(e){var n=-1!==m.PARAMETERS.indexOf(e),i=void 0!==t[e];!n&&i&&(r[e]=t[e])}))}m.PARAMETERS=Object.keys(new m),m._parseNumbers=function(e){if(e instanceof m)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach((function(r){var n=e[r];if("string"==typeof n){var i=parseFloat(n);t[r]=isNaN(i)?n:i}})),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map((function(e){return Array.isArray(e)?e.map((function(e){return parseFloat(e)})):e}))),e.numericRefinements){var r={};Object.keys(e.numericRefinements).forEach((function(t){var n=e.numericRefinements[t]||{};r[t]={},Object.keys(n).forEach((function(e){var i=n[e].map((function(e){return Array.isArray(e)?e.map((function(e){return"string"==typeof e?parseFloat(e):e})):"string"==typeof e?parseFloat(e):e}));r[t][e]=i}))})),t.numericRefinements=r}return a(e,t)},m.make=function(e){var t=new m(e);return(e.hierarchicalFacets||[]).forEach((function(e){if(e.rootPath){var r=t.getHierarchicalRefinement(e.name);r.length>0&&0!==r[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),0===(r=t.getHierarchicalRefinement(e.name)).length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}})),t},m.validate=function(e,t){var r=t||{};return e.tagFilters&&r.tagRefinements&&r.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&r.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&r.numericRefinements&&c(r.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):c(e.numericRefinements)&&r.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},m.prototype={constructor:m,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:f.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:f.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:f.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:f.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,r){var n=u(r);if(this.isNumericRefined(e,t,n))return this;var i=a({},this.numericRefinements);return i[e]=a({},i[e]),i[e][t]?(i[e][t]=i[e][t].slice(),i[e][t].push(n)):i[e][t]=[n],this.setQueryParameters({numericRefinements:i})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsRefinements[e]||[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)&&this.disjunctiveFacetsRefinements[e]||[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsExcludes[e]||[]},removeNumericRefinement:function(e,t,r){var n=r;return void 0!==n?this.isNumericRefined(e,t,n)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,i){return i===e&&r.op===t&&l(r.val,u(n))}))}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,n){return n===e&&r.op===t}))}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(t,r){return r===e}))}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return c(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return o(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,r=this.numericRefinements,n=Object.keys(r).reduce((function(n,i){var s=r[i],a={};return s=s||{},Object.keys(s).forEach((function(r){var n=s[r]||[],c=[];n.forEach((function(t){e({val:t,op:r},i,"numeric")||c.push(t)})),c.length!==n.length&&(t=!0),a[r]=c})),n[i]=a,n}),{});return t?n:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:f.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:f.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:f.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter((function(t){return t!==e}))}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter((function(t){return t!==e}))}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter((function(t){return t.name!==e}))}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:f.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:f.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:f.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter((function(t){return t!==e}))};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:f.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:f.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:f.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),i={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+r))?-1===t.indexOf(r)?i[e]=[]:i[e]=[t.slice(0,t.lastIndexOf(r))]:i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},i,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var r={};return r[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},r,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:n({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&f.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var r=this.getHierarchicalRefinement(e);return t?-1!==r.indexOf(t):r.length>0},isNumericRefined:function(e,t,r){if(void 0===r&&void 0===t)return Boolean(this.numericRefinements[e]);var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===r||!n)return n;var s,a,c=u(r),o=void 0!==(s=this.numericRefinements[e][t],a=c,i(s,(function(e){return l(e,a)})));return n&&o},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=s(Object.keys(this.numericRefinements).filter((function(t){return Object.keys(e.numericRefinements[t]).length>0})),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter((function(t){return e.disjunctiveFacetsRefinements[t].length>0})).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return s(this.hierarchicalFacets.map((function(e){return e.name})),Object.keys(this.hierarchicalFacetsRefinements).filter((function(t){return e.hierarchicalFacetsRefinements[t].length>0}))).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter((function(t){return-1===e.indexOf(t)}))},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},r=this;return Object.keys(this).forEach((function(n){var i=r[n];-1===e.indexOf(n)&&void 0!==i&&(t[n]=i)})),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var r={};return r[e]=t,this.setQueryParameters(r)},setQueryParameters:function(e){if(!e)return this;var t=m.validate(this,e);if(t)throw t;var r=this,n=m._parseNumbers(e),i=Object.keys(this).reduce((function(e,t){return e[t]=r[t],e}),{}),s=Object.keys(n).reduce((function(e,t){var r=void 0!==e[t],i=void 0!==n[t];return r&&!i?o(e,[t]):(i&&(e[t]=n[t]),e)}),i);return new this.constructor(s)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return i(this.hierarchicalFacets,(function(t){return t.name===e}))},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(r).map((function(e){return e.trim()}))},toString:function(){return JSON.stringify(this,null,2)}},e.exports=m},6673:(e,t,r)=>{"use strict";e.exports=function(e){return function(t,r){var n=e.hierarchicalFacets[r],u=e.hierarchicalFacetsRefinements[n.name]&&e.hierarchicalFacetsRefinements[n.name][0]||"",h=e._getHierarchicalFacetSeparator(n),f=e._getHierarchicalRootPath(n),l=e._getHierarchicalShowParentLevel(n),m=s(e._getHierarchicalFacetSortBy(n)),d=t.every((function(e){return e.exhaustive})),p=function(e,t,r,n,s){return function(u,h,f){var l=u;if(f>0){var m=0;for(l=u;m{"use strict";var n=r(8965),i=r(9110),s=r(2909),a=r(849),c=r(3917),o=r(7577),u=r(4728),h=r(8601),f=s.escapeFacetValue,l=s.unescapeFacetValue,m=r(6673);function d(e){var t={};return e.forEach((function(e,r){t[e]=r})),t}function p(e,t,r){t&&t[r]&&(e.stats=t[r])}function g(e,t,r){var s=t[0];this._rawResults=t;var o=this;Object.keys(s).forEach((function(e){o[e]=s[e]}));var h=u({persistHierarchicalRootCount:!1},r);Object.keys(h).forEach((function(e){o[e]=h[e]})),this.processingTimeMS=t.reduce((function(e,t){return void 0===t.processingTimeMS?e:e+t.processingTimeMS}),0),this.disjunctiveFacets=[],this.hierarchicalFacets=e.hierarchicalFacets.map((function(){return[]})),this.facets=[];var f=e.getRefinedDisjunctiveFacets(),g=d(e.facets),v=d(e.disjunctiveFacets),y=1,R=s.facets||{};Object.keys(R).forEach((function(t){var r,n,i=R[t],u=(r=e.hierarchicalFacets,n=t,a(r,(function(e){return(e.attributes||[]).indexOf(n)>-1})));if(u){var h=u.attributes.indexOf(t),f=c(e.hierarchicalFacets,(function(e){return e.name===u.name}));o.hierarchicalFacets[f][h]={attribute:t,data:i,exhaustive:s.exhaustiveFacetsCount}}else{var l,m=-1!==e.disjunctiveFacets.indexOf(t),d=-1!==e.facets.indexOf(t);m&&(l=v[t],o.disjunctiveFacets[l]={name:t,data:i,exhaustive:s.exhaustiveFacetsCount},p(o.disjunctiveFacets[l],s.facets_stats,t)),d&&(l=g[t],o.facets[l]={name:t,data:i,exhaustive:s.exhaustiveFacetsCount},p(o.facets[l],s.facets_stats,t))}})),this.hierarchicalFacets=n(this.hierarchicalFacets),f.forEach((function(r){var n=t[y],a=n&&n.facets?n.facets:{},h=e.getHierarchicalFacetByName(r);Object.keys(a).forEach((function(t){var r,f=a[t];if(h){r=c(e.hierarchicalFacets,(function(e){return e.name===h.name}));var m=c(o.hierarchicalFacets[r],(function(e){return e.attribute===t}));if(-1===m)return;o.hierarchicalFacets[r][m].data=u({},o.hierarchicalFacets[r][m].data,f)}else{r=v[t];var d=s.facets&&s.facets[t]||{};o.disjunctiveFacets[r]={name:t,data:i({},f,d),exhaustive:n.exhaustiveFacetsCount},p(o.disjunctiveFacets[r],n.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach((function(n){!o.disjunctiveFacets[r].data[n]&&e.disjunctiveFacetsRefinements[t].indexOf(l(n))>-1&&(o.disjunctiveFacets[r].data[n]=0)}))}})),y++})),e.getRefinedHierarchicalFacets().forEach((function(r){var n=e.getHierarchicalFacetByName(r),s=e._getHierarchicalFacetSeparator(n),a=e.getHierarchicalRefinement(r);0===a.length||a[0].split(s).length<2||t.slice(y).forEach((function(t){var r=t&&t.facets?t.facets:{};Object.keys(r).forEach((function(t){var u=r[t],h=c(e.hierarchicalFacets,(function(e){return e.name===n.name})),f=c(o.hierarchicalFacets[h],(function(e){return e.attribute===t}));if(-1!==f){var l={};if(a.length>0&&!o.persistHierarchicalRootCount){var m=a[0].split(s)[0];l[m]=o.hierarchicalFacets[h][f].data[m]}o.hierarchicalFacets[h][f].data=i(l,u,o.hierarchicalFacets[h][f].data)}})),y++}))})),Object.keys(e.facetsExcludes).forEach((function(t){var r=e.facetsExcludes[t],n=g[t];o.facets[n]={name:t,data:R[t],exhaustive:s.exhaustiveFacetsCount},r.forEach((function(e){o.facets[n]=o.facets[n]||{name:t},o.facets[n].data=o.facets[n].data||{},o.facets[n].data[e]=0}))})),this.hierarchicalFacets=this.hierarchicalFacets.map(m(e)),this.facets=n(this.facets),this.disjunctiveFacets=n(this.disjunctiveFacets),this._state=e}function v(e,t){function r(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var n=a(e.facets,r);return n?Object.keys(n.data).map((function(r){var i=f(r);return{name:r,escapedValue:i,count:n.data[r],isRefined:e._state.isFacetRefined(t,i),isExcluded:e._state.isExcludeRefined(t,r)}})):[]}if(e._state.isDisjunctiveFacet(t)){var i=a(e.disjunctiveFacets,r);return i?Object.keys(i.data).map((function(r){var n=f(r);return{name:r,escapedValue:n,count:i.data[r],isRefined:e._state.isDisjunctiveFacetRefined(t,n)}})):[]}if(e._state.isHierarchicalFacet(t)){var s=a(e.hierarchicalFacets,r);if(!s)return s;var c=e._state.getHierarchicalFacetByName(t),o=e._state._getHierarchicalFacetSeparator(c),u=l(e._state.getHierarchicalRefinement(t)[0]||"");0===u.indexOf(c.rootPath)&&(u=u.replace(c.rootPath+o,""));var h=u.split(o);return h.unshift(t),y(s,h,0),s}}function y(e,t,r){e.isRefined=e.name===(t[r]&&t[r].trim()),e.data&&e.data.forEach((function(e){y(e,t,r+1)}))}function R(e,t,r,n){if(n=n||0,Array.isArray(t))return e(t,r[n]);if(!t.data||0===t.data.length)return t;var s=t.data.map((function(t){return R(e,t,r,n+1)})),a=e(s,r[n]);return i({data:a},t)}function F(e,t){var r=a(e,(function(e){return e.name===t}));return r&&r.stats}function b(e,t,r,n,i){var s=a(i,(function(e){return e.name===r})),c=s&&s.data&&s.data[n]?s.data[n]:0,o=s&&s.exhaustive||!1;return{type:t,attributeName:r,name:n,count:c,exhaustive:o}}g.prototype.getFacetByName=function(e){function t(t){return t.name===e}return a(this.facets,t)||a(this.disjunctiveFacets,t)||a(this.hierarchicalFacets,t)},g.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],g.prototype.getFacetValues=function(e,t){var r=v(this,e);if(r){var n,s=i({},t,{sortBy:g.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),a=this;if(Array.isArray(r))n=[e];else n=a._state.getHierarchicalFacetByName(r.name).attributes;return R((function(e,t){if(s.facetOrdering){var r=function(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}(a,t);if(r)return function(e,t){var r=[],n=[],i=(t.order||[]).reduce((function(e,t,r){return e[t]=r,e}),{});e.forEach((function(e){var t=e.path||e.name;void 0!==i[t]?r[i[t]]=e:n.push(e)})),r=r.filter((function(e){return e}));var s,a=t.sortRemainingBy;return"hidden"===a?r:(s="alpha"===a?[["path","name"],["asc","asc"]]:[["count"],["desc"]],r.concat(h(n,s[0],s[1])))}(e,r)}if(Array.isArray(s.sortBy)){var n=o(s.sortBy,g.DEFAULT_SORT);return h(e,n[0],n[1])}if("function"==typeof s.sortBy)return function(e,t){return t.sort(e)}(s.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")}),r,n)}},g.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?F(this.facets,e):this._state.isDisjunctiveFacet(e)?F(this.disjunctiveFacets,e):void 0},g.prototype.getRefinements=function(){var e=this._state,t=this,r=[];return Object.keys(e.facetsRefinements).forEach((function(n){e.facetsRefinements[n].forEach((function(i){r.push(b(e,"facet",n,i,t.facets))}))})),Object.keys(e.facetsExcludes).forEach((function(n){e.facetsExcludes[n].forEach((function(i){r.push(b(e,"exclude",n,i,t.facets))}))})),Object.keys(e.disjunctiveFacetsRefinements).forEach((function(n){e.disjunctiveFacetsRefinements[n].forEach((function(i){r.push(b(e,"disjunctive",n,i,t.disjunctiveFacets))}))})),Object.keys(e.hierarchicalFacetsRefinements).forEach((function(n){e.hierarchicalFacetsRefinements[n].forEach((function(i){r.push(function(e,t,r,n){var i=e.getHierarchicalFacetByName(t),s=e._getHierarchicalFacetSeparator(i),c=r.split(s),o=a(n,(function(e){return e.name===t})),u=c.reduce((function(e,t){var r=e&&a(e.data,(function(e){return e.name===t}));return void 0!==r?r:e}),o),h=u&&u.count||0,f=u&&u.exhaustive||!1,l=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:l,count:h,exhaustive:f}}(e,n,i,t.hierarchicalFacets))}))})),Object.keys(e.numericRefinements).forEach((function(t){var n=e.numericRefinements[t];Object.keys(n).forEach((function(e){n[e].forEach((function(n){r.push({type:"numeric",attributeName:t,name:n,numericValue:n,operator:e})}))}))})),e.tagRefinements.forEach((function(e){r.push({type:"tag",attributeName:"_tags",name:e})})),r},e.exports=g},6571:(e,t,r)=>{"use strict";var n=r(2733),i=r(6732),s=r(2909).escapeFacetValue,a=r(3014),c=r(4728),o=r(317),u=r(1383),h=r(9127),f=r(2223),l=r(9228),m=r(3371),d=r(7691),p=r(7749),g=r(6938);function v(e,t,r,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.setClient(e);var i=r||{};i.index=t,this.state=m.make(i),this.recommendState=new h({params:i.recommendState}),this.lastResults=null,this.lastRecommendResults=null,this._queryId=0,this._recommendQueryId=0,this._lastQueryIdReceived=-1,this._lastRecommendQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0,this._currentNbRecommendQueries=0,this._searchResultsOptions=n,this._recommendCache={}}function y(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function R(){return this.state.page}a(v,n),v.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},v.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},v.prototype.recommend=function(){return this._recommend(),this},v.prototype.getQuery=function(){var e=this.state;return l._getHitsSearchParams(e)},v.prototype.searchOnce=function(e,t){var r=e?this.state.setQueryParameters(e):this.state,n=l._getQueries(r.index,r),i=this;if(this._currentNbQueries++,this.emit("searchOnce",{state:r}),!t)return this.client.search(n).then((function(e){return i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),{content:new d(r,e.results),state:r,_originalResponse:e}}),(function(e){throw i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),e}));this.client.search(n).then((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(null,new d(r,e.results),r)})).catch((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(e,null,r)}))},v.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,r=this.derivedHelpers[0];if(!r)return Promise.resolve([]);var n=r.getModifiedState(t),i=c({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:u(l._getHitsSearchParams(n),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),s="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(s);var a=this.client.initIndex(n.index);if("function"!=typeof a.findAnswers)throw new Error(s);return a.findAnswers(n.query,e.queryLanguages,i)},v.prototype.searchForFacetValues=function(e,t,r,n){var i="function"==typeof this.client.searchForFacetValues,a="function"==typeof this.client.initIndex;if(!i&&!a&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var c=this.state.setQueryParameters(n||{}),o=c.isDisjunctiveFacet(e),u=l.getSearchForFacetQuery(e,t,r,c);this._currentNbQueries++;var h,f=this;return i?h=this.client.searchForFacetValues([{indexName:c.index,params:u}]):a?h=this.client.initIndex(c.index).searchForFacetValues(u):(delete u.facetName,h=this.client.search([{type:"facet",facet:e,indexName:c.index,params:u}]).then((function(e){return e.results[0]}))),this.emit("searchForFacetValues",{state:c,facet:e,query:t}),h.then((function(t){return f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),(t=Array.isArray(t)?t[0]:t).facetHits.forEach((function(t){t.escapedValue=s(t.value),t.isRefined=o?c.isDisjunctiveFacetRefined(e,t.escapedValue):c.isFacetRefined(e,t.escapedValue)})),t}),(function(e){throw f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),e}))},v.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},v.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},v.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},v.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},v.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addNumericRefinement=function(e,t,r){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,r),isPageReset:!0}),this},v.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},v.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},v.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},v.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},v.prototype.addFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.addFrequentlyBoughtTogether(e)}),this},v.prototype.addRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.addRelatedProducts(e)}),this},v.prototype.addTrendingItems=function(e){return this._recommendChange({state:this.recommendState.addTrendingItems(e)}),this},v.prototype.addTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.addTrendingFacets(e)}),this},v.prototype.addLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.addLookingSimilar(e)}),this},v.prototype.removeNumericRefinement=function(e,t,r){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,r),isPageReset:!0}),this},v.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},v.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},v.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},v.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},v.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},v.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},v.prototype.removeFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeTrendingItems=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},v.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},v.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},v.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},v.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},v.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},v.prototype.setCurrentPage=y,v.prototype.setPage=y,v.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},v.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},v.prototype.setState=function(e){return this._change({state:m.make(e),isPageReset:!1}),this},v.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new m(e),this},v.prototype.hasRefinements=function(e){return!!o(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},v.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},v.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},v.prototype.hasTag=function(e){return this.state.isTagRefined(e)},v.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},v.prototype.getIndex=function(){return this.state.index},v.prototype.getCurrentPage=R,v.prototype.getPage=R,v.prototype.getTags=function(){return this.state.tagRefinements},v.prototype.getRefinements=function(e){var t=[];if(this.state.isConjunctiveFacet(e))this.state.getConjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"conjunctive"})})),this.state.getExcludeRefinements(e).forEach((function(e){t.push({value:e,type:"exclude"})}));else if(this.state.isDisjunctiveFacet(e)){this.state.getDisjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"disjunctive"})}))}var r=this.state.getNumericRefinements(e);return Object.keys(r).forEach((function(e){var n=r[e];t.push({value:n,operator:e,type:"numeric"})})),t},v.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},v.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},v.prototype._search=function(e){var t=this.state,r=[],n=[];e.onlyWithDerivedHelpers||(n=l._getQueries(t.index,t),r.push({state:t,queriesCount:n.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var i=this.derivedHelpers.map((function(e){var n=e.getModifiedState(t),i=n.index?l._getQueries(n.index,n):[];return r.push({state:n,queriesCount:i.length,helper:e}),e.emit("search",{state:n,results:e.lastResults}),i})),s=Array.prototype.concat.apply(n,i),a=this._queryId++;if(this._currentNbQueries++,!s.length)return Promise.resolve({results:[]}).then(this._dispatchAlgoliaResponse.bind(this,r,a));try{this.client.search(s).then(this._dispatchAlgoliaResponse.bind(this,r,a)).catch(this._dispatchAlgoliaError.bind(this,a))}catch(c){this.emit("error",{error:c})}},v.prototype._recommend=function(){var e=this.state,t=this.recommendState,r=this.getIndex(),n=[{state:t,index:r,helper:this}],i=t.params.map((function(e){return e.$$id}));this.emit("fetch",{recommend:{state:t,results:this.lastRecommendResults}});var s=this._recommendCache,a=this.derivedHelpers.map((function(t){var r=t.getModifiedState(e).index;if(!r)return[];var a=t.getModifiedRecommendState(new h);return n.push({state:a,index:r,helper:t}),i=Array.prototype.concat.apply(i,a.params.map((function(e){return e.$$id}))),t.emit("fetch",{recommend:{state:a,results:t.lastRecommendResults}}),a._buildQueries(r,s)})),c=Array.prototype.concat.apply(this.recommendState._buildQueries(r,s),a);if(0!==c.length)if(c.length>0&&void 0===this.client.getRecommendations)console.warn("Please update algoliasearch/lite to the latest version in order to use recommend widgets.");else{var o=this._recommendQueryId++;this._currentNbRecommendQueries++;try{this.client.getRecommendations(c).then(this._dispatchRecommendResponse.bind(this,o,n,i)).catch(this._dispatchRecommendError.bind(this,o))}catch(u){this.emit("error",{error:u})}}},v.prototype._dispatchAlgoliaResponse=function(e,t,r){var n=this;if(!(t0},v.prototype._change=function(e){var t=e.state,r=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:r}))},v.prototype._recommendChange=function(e){var t=e.state;t!==this.recommendState&&(this.recommendState=t,this.emit("recommend:change",{search:{results:this.lastResults,state:this.state},recommend:{results:this.lastRecommendResults,state:this.recommendState}}))},v.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},v.prototype.setClient=function(e){return this.client===e||("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.client=e),this},v.prototype.getClient=function(){return this.client},v.prototype.derive=function(e,t){var r=new i(this,e,t);return this.derivedHelpers.push(r),r},v.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},v.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},e.exports=v},8965:e=>{"use strict";e.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},9110:e=>{"use strict";e.exports=function(){return Array.prototype.slice.call(arguments).reduceRight((function(e,t){return Object.keys(Object(t)).forEach((function(r){void 0!==t[r]&&(void 0!==e[r]&&delete e[r],e[r]=t[r])})),e}),{})}},2909:e=>{"use strict";e.exports={escapeFacetValue:function(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")},unescapeFacetValue:function(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}}},849:e=>{"use strict";e.exports=function(e,t){if(Array.isArray(e))for(var r=0;r{"use strict";e.exports=function(e,t){if(!Array.isArray(e))return-1;for(var r=0;r{e.exports=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])}},7577:(e,t,r)=>{"use strict";var n=r(849);e.exports=function(e,t){var r=(t||[]).map((function(e){return e.split(":")}));return e.reduce((function(e,t){var i=t.split(":"),s=n(r,(function(e){return e[0]===i[0]}));return i.length>1||!s?(e[0].push(i[0]),e[1].push(i[1]),e):(e[0].push(s[0]),e[1].push(s[1]),e)}),[[],[]])}},3014:e=>{"use strict";e.exports=function(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},4843:e=>{"use strict";e.exports=function(e,t){return e.filter((function(r,n){return t.indexOf(r)>-1&&e.indexOf(r)===n}))}},4728:e=>{"use strict";function t(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function r(e,n){if(e===n)return e;for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&"__proto__"!==i&&"constructor"!==i){var s=n[i],a=e[i];void 0!==a&&void 0===s||(t(a)&&t(s)?e[i]=r(a,s):e[i]="object"==typeof(c=s)&&null!==c?r(Array.isArray(c)?[]:{},c):c)}var c;return e}e.exports=function(e){t(e)||(e={});for(var n=1,i=arguments.length;n{"use strict";e.exports=function(e){return e&&Object.keys(e).length>0}},1383:e=>{"use strict";e.exports=function(e,t){if(null===e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}},8601:e=>{"use strict";function t(e,t){if(e!==t){var r=void 0!==e,n=null===e,i=void 0!==t,s=null===t;if(!s&&e>t||n&&i||!r)return 1;if(!n&&e=n.length?s:"desc"===n[i]?-s:s}return e.index-r.index})),i.map((function(e){return e.value}))}},7507:e=>{"use strict";e.exports=function e(t){if("number"==typeof t)return t;if("string"==typeof t)return parseFloat(t);if(Array.isArray(t))return t.map(e);throw new Error("The value should be a number, a parsable string or an array of those.")}},9228:(e,t,r)=>{"use strict";var n=r(4728);function i(e){return Object.keys(e).sort().reduce((function(t,r){return t[r]=e[r],t}),{})}var s={_getQueries:function(e,t){var r=[];return r.push({indexName:e,params:s._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach((function(n){r.push({indexName:e,params:s._getDisjunctiveFacetSearchParams(t,n)})})),t.getRefinedHierarchicalFacets().forEach((function(n){var i=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(i);if(a.length>0&&a[0].split(c).length>1){var o=a[0].split(c).slice(0,-1).reduce((function(e,t,r){return e.concat({attribute:i.attributes[r],value:0===r?t:[e[e.length-1].value,t].join(c)})}),[]);o.forEach((function(n,a){var c=s._getDisjunctiveFacetSearchParams(t,n.attribute,0===a);function u(e){return i.attributes.some((function(t){return t===e.split(":")[0]}))}var h=(c.facetFilters||[]).reduce((function(e,t){if(Array.isArray(t)){var r=t.filter((function(e){return!u(e)}));r.length>0&&e.push(r)}return"string"!=typeof t||u(t)||e.push(t),e}),[]),f=o[a-1];c.facetFilters=a>0?h.concat(f.attribute+":"+f.value):h.length>0?h:void 0,r.push({indexName:e,params:c})}))}})),r},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(s._getHitsHierarchicalFacetsAttributes(e)).sort(),r=s._getFacetFilters(e),a=s._getNumericFilters(e),c=s._getTagFilters(e),o={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:c};return r.length>0&&(o.facetFilters=r),a.length>0&&(o.numericFilters=a),i(n({},e.getQueryParams(),o))},_getDisjunctiveFacetSearchParams:function(e,t,r){var a=s._getFacetFilters(e,t,r),c=s._getNumericFilters(e,t),o=s._getTagFilters(e),u={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};o.length>0&&(u.tagFilters=o);var h=e.getHierarchicalFacetByName(t);return u.facets=h?s._getDisjunctiveHierarchicalFacetAttribute(e,h,r):t,c.length>0&&(u.numericFilters=c),a.length>0&&(u.facetFilters=a),i(n({},e.getQueryParams(),u))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var r=[];return Object.keys(e.numericRefinements).forEach((function(n){var i=e.numericRefinements[n]||{};Object.keys(i).forEach((function(e){var s=i[e]||[];t!==n&&s.forEach((function(t){if(Array.isArray(t)){var i=t.map((function(t){return n+e+t}));r.push(i)}else r.push(n+e+t)}))}))})),r},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,r){var n=[],i=e.facetsRefinements||{};Object.keys(i).sort().forEach((function(e){(i[e]||[]).slice().sort().forEach((function(t){n.push(e+":"+t)}))}));var s=e.facetsExcludes||{};Object.keys(s).sort().forEach((function(e){(s[e]||[]).sort().forEach((function(t){n.push(e+":-"+t)}))}));var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).sort().forEach((function(e){var r=a[e]||[];if(e!==t&&r&&0!==r.length){var i=[];r.slice().sort().forEach((function(t){i.push(e+":"+t)})),n.push(i)}}));var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).sort().forEach((function(i){var s=(c[i]||[])[0];if(void 0!==s){var a,o,u=e.getHierarchicalFacetByName(i),h=e._getHierarchicalFacetSeparator(u),f=e._getHierarchicalRootPath(u);if(t===i){if(-1===s.indexOf(h)||!f&&!0===r||f&&f.split(h).length===s.split(h).length)return;f?(o=f.split(h).length-1,s=f):(o=s.split(h).length-2,s=s.slice(0,s.lastIndexOf(h))),a=u.attributes[o]}else o=s.split(h).length-1,a=u.attributes[o];a&&n.push([a+":"+s])}})),n},_getHitsHierarchicalFacetsAttributes:function(e){return e.hierarchicalFacets.reduce((function(t,r){var n=e.getHierarchicalRefinement(r.name)[0];if(!n)return t.push(r.attributes[0]),t;var i=e._getHierarchicalFacetSeparator(r),s=n.split(i).length,a=r.attributes.slice(0,s+1);return t.concat(a)}),[])},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,r){var n=e._getHierarchicalFacetSeparator(t);if(!0===r){var i=e._getHierarchicalRootPath(t),s=0;return i&&(s=i.split(n).length),[t.attributes[s]]}var a=(e.getHierarchicalRefinement(t.name)[0]||"").split(n).length-1;return t.attributes.slice(0,a+1)},getSearchForFacetQuery:function(e,t,r,a){var c=a.isDisjunctiveFacet(e)?a.clearRefinements(e):a,o={facetQuery:t,facetName:e};return"number"==typeof r&&(o.maxFacetHits=r),i(n({},s._getHitsSearchParams(c),o))}};e.exports=s},2208:e=>{"use strict";e.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},7749:(e,t,r)=>{"use strict";var n=r(849),i=r(8657);e.exports=function(e){var t={};return e.forEach((function(e){e.forEach((function(e,r){t[e.objectID]?t[e.objectID]={indexSum:t[e.objectID].indexSum+r,count:t[e.objectID].count+1}:t[e.objectID]={indexSum:r,count:1}}))})),function(e,t){var r=[];return Object.keys(e).forEach((function(n){e[n].count<2&&(e[n].indexSum+=100),r.push({objectID:n,avgOfIndices:e[n].indexSum/t})})),r.sort((function(e,t){return e.avgOfIndices>t.avgOfIndices?1:-1}))}(t,e.length).reduce((function(t,r){var s=n(i(e),(function(e){return e.objectID===r.objectID}));return s?t.concat(s):t}),[])}},6938:e=>{"use strict";e.exports="3.21.0"},3643:function(e){e.exports=function(){"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,i=!1,s=void 0;try{for(var a,c=e[Symbol.iterator]();!(n=(a=c.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,s=e}finally{try{n||null==c.return||c.return()}finally{if(i)throw s}}return r}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then((function(){c();var t=JSON.stringify(e);return s()[t]})).then((function(e){return Promise.all([e?e.value:t(),void 0!==e])})).then((function(e){var t=i(e,2),n=t[0],s=t[1];return Promise.all([n,s||r.miss(n)])})).then((function(e){return i(e,1)[0]}))},set:function(e,t){return Promise.resolve().then((function(){var i=s();return i[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},n().setItem(r,JSON.stringify(i)),t}))},delete:function(e){return Promise.resolve().then((function(){var t=s();delete t[JSON.stringify(e)],n().setItem(r,JSON.stringify(t))}))},clear:function(){return Promise.resolve().then((function(){n().removeItem(r)}))}}}function c(e){var t=s(e.caches),r=t.shift();return void 0===r?{get:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return t().then((function(e){return Promise.all([e,r.miss(e)])})).then((function(e){return i(e,1)[0]}))},set:function(e,t){return Promise.resolve(t)},delete:function(e){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return r.get(e,n,i).catch((function(){return c({caches:t}).get(e,n,i)}))},set:function(e,n){return r.set(e,n).catch((function(){return c({caches:t}).set(e,n)}))},delete:function(e){return r.delete(e).catch((function(){return c({caches:t}).delete(e)}))},clear:function(){return r.clear().catch((function(){return c({caches:t}).clear()}))}}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serializable:!0},t={};return{get:function(r,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);var a=n(),c=i&&i.miss||function(){return Promise.resolve()};return a.then((function(e){return c(e)})).then((function(){return a}))},set:function(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete:function(e){return delete t[JSON.stringify(e)],Promise.resolve()},clear:function(){return t={},Promise.resolve()}}}function u(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function h(e,t){return t?(Object.keys(t).forEach((function(r){e[r]=t[r](e)})),e):e}function f(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var d={Read:1,Write:2,Any:3},p=1,g=2,v=3;function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;return r(r({},e),{},{status:t,lastUpdate:Date.now()})}function R(e){return"string"==typeof e?{protocol:"https",url:e,accept:d.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||d.Any}}var F="GET",b="POST";function j(e,t){return Promise.all(t.map((function(t){return e.get(t,(function(){return Promise.resolve(y(t))}))}))).then((function(e){var r=e.filter((function(e){return function(e){return e.status===p||Date.now()-e.lastUpdate>12e4}(e)})),n=e.filter((function(e){return function(e){return e.status===v&&Date.now()-e.lastUpdate<=12e4}(e)})),i=[].concat(s(r),s(n));return{getTimeout:function(e,t){return(0===n.length&&0===e?1:n.length+3+e)*t},statelessHosts:i.length>0?i.map((function(e){return R(e)})):t}}))}function _(e,t,n,i){var a=[],c=function(e,t){if(e.method!==F&&(void 0!==e.data||void 0!==t.data)){var n=Array.isArray(e.data)?e.data:r(r({},e.data),t.data);return JSON.stringify(n)}}(n,i),o=function(e,t){var n=r(r({},e.headers),t.headers),i={};return Object.keys(n).forEach((function(e){var t=n[e];i[e.toLowerCase()]=t})),i}(e,i),u=n.method,h=n.method!==F?{}:r(r({},n.data),i.data),f=r(r(r({"x-algolia-agent":e.userAgent.value},e.queryParameters),h),i.queryParameters),l=0,m=function t(r,s){var h=r.pop();if(void 0===h)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:O(a)};var m={data:c,headers:o,method:u,url:x(h,n.path,f),connectTimeout:s(l,e.timeouts.connect),responseTimeout:s(l,i.timeout)},d=function(e){var t={request:m,response:e,host:h,triesLeft:r.length};return a.push(t),t},p={onSuccess:function(e){return function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e)},onRetry:function(n){var i=d(n);return n.isTimedOut&&l++,Promise.all([e.logger.info("Retryable failure",w(i)),e.hostsCache.set(h,y(h,n.isTimedOut?v:g))]).then((function(){return t(r,s)}))},onFail:function(e){throw d(e),function(e,t){var r=e.content,n=e.status,i=r;try{i=JSON.parse(r).message}catch(e){}return function(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}(i,n,t)}(e,O(a))}};return e.requester.send(m).then((function(e){return function(e,t){return function(e){var t=e.status;return e.isTimedOut||function(e){var t=e.isTimedOut,r=e.status;return!t&&!~~r}(e)||2!=~~(t/100)&&4!=~~(t/100)}(e)?t.onRetry(e):2==~~(e.status/100)?t.onSuccess(e):t.onFail(e)}(e,p)}))};return j(e.hostsCache,t).then((function(e){return m(s(e.statelessHosts).reverse(),e.getTimeout)}))}function P(e){var t={value:"Algolia for JavaScript (".concat(e,")"),add:function(e){var r="; ".concat(e.segment).concat(void 0!==e.version?" (".concat(e.version,")"):"");return-1===t.value.indexOf(r)&&(t.value="".concat(t.value).concat(r)),t}};return t}function x(e,t,r){var n=E(r),i="".concat(e.protocol,"://").concat(e.url,"/").concat("/"===t.charAt(0)?t.substr(1):t);return n.length&&(i+="?".concat(n)),i}function E(e){return Object.keys(e).map((function(t){return f("%s=%s",t,(r=e[t],"[object Object]"===Object.prototype.toString.call(r)||"[object Array]"===Object.prototype.toString.call(r)?JSON.stringify(e[t]):e[t]));var r})).join("&")}function O(e){return e.map((function(e){return w(e)}))}function w(e){var t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return r(r({},e),{},{request:r(r({},e.request),{},{headers:r(r({},e.request.headers),t)})})}var S=function(e){var t=e.appId,n=function(e,t,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:function(){return e===l.WithinHeaders?n:{}},queryParameters:function(){return e===l.WithinQueryParameters?n:{}}}}(void 0!==e.authMode?e.authMode:l.WithinHeaders,t,e.apiKey),s=function(e){var t=e.hostsCache,r=e.logger,n=e.requester,s=e.requestsCache,a=e.responsesCache,c=e.timeouts,o=e.userAgent,u=e.hosts,h=e.queryParameters,f={hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:c,userAgent:o,headers:e.headers,queryParameters:h,hosts:u.map((function(e){return R(e)})),read:function(e,t){var r=m(t,f.timeouts.read),n=function(){return _(f,f.hosts.filter((function(e){return!!(e.accept&d.Read)})),e,r)};if(!0!==(void 0!==r.cacheable?r.cacheable:e.cacheable))return n();var s={request:e,mappedRequestOptions:r,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(s,(function(){return f.requestsCache.get(s,(function(){return f.requestsCache.set(s,n()).then((function(e){return Promise.all([f.requestsCache.delete(s),e])}),(function(e){return Promise.all([f.requestsCache.delete(s),Promise.reject(e)])})).then((function(e){var t=i(e,2);return t[0],t[1]}))}))}),{miss:function(e){return f.responsesCache.set(s,e)}})},write:function(e,t){return _(f,f.hosts.filter((function(e){return!!(e.accept&d.Write)})),e,m(t,f.timeouts.write))}};return f}(r(r({hosts:[{url:"".concat(t,"-dsn.algolia.net"),accept:d.Read},{url:"".concat(t,".algolia.net"),accept:d.Write}].concat(u([{url:"".concat(t,"-1.algolianet.com")},{url:"".concat(t,"-2.algolianet.com")},{url:"".concat(t,"-3.algolianet.com")}]))},e),{},{headers:r(r(r({},n.headers()),{"content-type":"application/x-www-form-urlencoded"}),e.headers),queryParameters:r(r({},n.queryParameters()),e.queryParameters)}));return h({transporter:s,appId:t,addAlgoliaAgent:function(e,t){s.userAgent.add({segment:e,version:t})},clearCache:function(){return Promise.all([s.requestsCache.clear(),s.responsesCache.clear()]).then((function(){}))}},e.methods)},A=function(e){return function(t,r){return t.method===F?e.transporter.read(t,r):e.transporter.write(t,r)}},N=function(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h({transporter:e.transporter,appId:e.appId,indexName:t},r.methods)}},T=function(e){return function(t,n){var i=t.map((function(e){return r(r({},e),{},{params:E(e.params||{})})}));return e.transporter.read({method:b,path:"1/indexes/*/queries",data:{requests:i},cacheable:!0},n)}},H=function(e){return function(t,i){return Promise.all(t.map((function(t){var s=t.params,a=s.facetName,c=s.facetQuery,o=n(s,["facetName","facetQuery"]);return N(e)(t.indexName,{methods:{searchForFacetValues:I}}).searchForFacetValues(a,c,r(r({},i),o))})))}},Q=function(e){return function(t,r,n){return e.transporter.read({method:b,path:f("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n)}},C=function(e){return function(t,r){return e.transporter.read({method:b,path:f("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r)}},I=function(e){return function(t,r,n){return e.transporter.read({method:b,path:f("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n)}},D=1,k=2,q=3,L=function(e){return function(t,n){var i=t.map((function(e){return r(r({},e),{},{threshold:e.threshold||0})}));return e.transporter.read({method:b,path:"1/indexes/*/recommendations",data:{requests:i},cacheable:!0},n)}};function V(e,t,n){var i,s={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:function(e){return new Promise((function(t){var r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((function(t){return r.setRequestHeader(t,e.headers[t])}));var n,i=function(e,n){return setTimeout((function(){r.abort(),t({status:0,content:n,isTimedOut:!0})}),1e3*e)},s=i(e.connectTimeout,"Connection timeout");r.onreadystatechange=function(){r.readyState>r.OPENED&&void 0===n&&(clearTimeout(s),n=i(e.responseTimeout,"Socket timeout"))},r.onerror=function(){0===r.status&&(clearTimeout(s),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=function(){clearTimeout(s),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},logger:(i=q,{debug:function(e,t){return D>=i&&console.debug(e,t),Promise.resolve()},info:function(e,t){return k>=i&&console.info(e,t),Promise.resolve()},error:function(e,t){return console.error(e,t),Promise.resolve()}}),responsesCache:o(),requestsCache:o({serializable:!1}),hostsCache:c({caches:[a({key:"".concat("4.23.3","-").concat(e)}),o()]}),userAgent:P("4.23.3").add({segment:"Browser",version:"lite"}),authMode:l.WithinQueryParameters};return S(r(r(r({},s),n),{},{methods:{search:T,searchForFacetValues:H,multipleQueries:T,multipleSearchForFacetValues:H,customRequest:A,initIndex:function(e){return function(t){return N(e)(t,{methods:{search:C,searchForFacetValues:I,findAnswers:Q}})}},getRecommendations:L}}))}return V.version="4.23.3",V}()},9057:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>T});var n=r(6540),i=r(4164),s=r(4103),a=r.n(s),c=r(3643),o=r.n(c),u=r(8193),h=r(5260),f=r(8774),l=r(4070),m=r(4586);const d=["zero","one","two","few","many","other"];function p(e){return d.filter((t=>e.includes(t)))}const g={locale:"en",pluralForms:p(["one","other"]),select:e=>1===e?"one":"other"};function v(){const{i18n:{currentLocale:e}}=(0,m.A)();return(0,n.useMemo)((()=>{try{return function(e){const t=new Intl.PluralRules(e);return{locale:e,pluralForms:p(t.resolvedOptions().pluralCategories),select:e=>t.select(e)}}(e)}catch(t){return console.error(`Failed to use Intl.PluralRules for locale "${e}".\nDocusaurus will fallback to the default (English) implementation.\nError: ${t.message}\n`),g}}),[e])}function y(){const e=v();return{selectMessage:(t,r)=>function(e,t,r){const n=e.split("|");if(1===n.length)return n[0];n.length>r.pluralForms.length&&console.error(`For locale=${r.locale}, a maximum of ${r.pluralForms.length} plural forms are expected (${r.pluralForms.join(",")}), but the message contains ${n.length}: ${e}`);const i=r.select(t),s=r.pluralForms.indexOf(i);return n[Math.min(s,n.length-1)]}(r,t,e)}}var R=r(4255),F=r(9532),b=r(9024),j=r(481),_=r(1312),P=r(8126),x=r(1062),E=r(9201),O=r(1107);const w={searchQueryInput:"searchQueryInput_u2C7",searchVersionInput:"searchVersionInput_m0Ui",searchResultsColumn:"searchResultsColumn_JPFH",algoliaLogo:"algoliaLogo_rT1R",algoliaLogoPathFill:"algoliaLogoPathFill_WdUC",searchResultItem:"searchResultItem_Tv2o",searchResultItemHeading:"searchResultItemHeading_KbCB",searchResultItemPath:"searchResultItemPath_lhe1",searchResultItemSummary:"searchResultItemSummary_AEaO",searchQueryColumn:"searchQueryColumn_RTkw",searchVersionColumn:"searchVersionColumn_ypXd",searchLogoColumn:"searchLogoColumn_rJIA",loadingSpinner:"loadingSpinner_XVxU","loading-spin":"loading-spin_vzvp",loader:"loader_vvXV"};var S=r(4848);function A(e){let{docsSearchVersionsHelpers:t}=e;const r=Object.entries(t.allDocsData).filter((e=>{let[,t]=e;return t.versions.length>1}));return(0,S.jsx)("div",{className:(0,i.A)("col","col--3","padding-left--none",w.searchVersionColumn),children:r.map((e=>{let[n,i]=e;const s=r.length>1?`${n}: `:"";return(0,S.jsx)("select",{onChange:e=>t.setSearchVersion(n,e.target.value),defaultValue:t.searchVersions[n],className:w.searchVersionInput,children:i.versions.map(((e,t)=>(0,S.jsx)("option",{label:`${s}${e.label}`,value:e.name},t)))},n)}))})}function N(){const{i18n:{currentLocale:e}}=(0,m.A)(),{algolia:{appId:t,apiKey:r,indexName:s,contextualSearch:c}}=(0,P.c)(),d=(0,x.C)(),p=function(){const{selectMessage:e}=y();return t=>e(t,(0,_.T)({id:"theme.SearchPage.documentsFound.plurals",description:'Pluralized label for "{count} documents found". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"One document found|{count} documents found"},{count:t}))}(),g=function(){const e=(0,l.Gy)(),[t,r]=(0,n.useState)((()=>Object.entries(e).reduce(((e,t)=>{let[r,n]=t;return{...e,[r]:n.versions[0].name}}),{}))),i=Object.values(e).some((e=>e.versions.length>1));return{allDocsData:e,versioningEnabled:i,searchVersions:t,setSearchVersion:(e,t)=>r((r=>({...r,[e]:t})))}}(),[v,b]=(0,R.b)(),N={items:[],query:null,totalResults:null,totalPages:null,lastPage:null,hasMore:null,loading:null},[T,H]=(0,n.useReducer)(((e,t)=>{switch(t.type){case"reset":return N;case"loading":return{...e,loading:!0};case"update":return v!==t.value.query?e:{...t.value,items:0===t.value.lastPage?t.value.items:e.items.concat(t.value.items)};case"advance":{const t=e.totalPages>e.lastPage+1;return{...e,lastPage:t?e.lastPage+1:e.lastPage,hasMore:t}}default:return e}}),N),Q=c?["language","docusaurus_tag"]:[],C=o()(t,r),I=a()(C,s,{hitsPerPage:15,advancedSyntax:!0,disjunctiveFacets:Q});I.on("result",(e=>{let{results:{query:t,hits:r,page:n,nbHits:i,nbPages:s}}=e;if(""===t||!Array.isArray(r))return void H({type:"reset"});const a=e=>e.replace(/algolia-docsearch-suggestion--highlight/g,"search-result-match"),c=r.map((e=>{let{url:t,_highlightResult:{hierarchy:r},_snippetResult:n={}}=e;const i=Object.keys(r).map((e=>a(r[e].value)));return{title:i.pop(),url:d(t),summary:n.content?`${a(n.content.value)}...`:"",breadcrumbs:i}}));H({type:"update",value:{items:c,query:t,totalResults:i,totalPages:s,lastPage:n,hasMore:s>n+1,loading:!1}})}));const[D,k]=(0,n.useState)(null),q=(0,n.useRef)(0),L=(0,n.useRef)(u.A.canUseIntersectionObserver&&new IntersectionObserver((e=>{const{isIntersecting:t,boundingClientRect:{y:r}}=e[0];t&&q.current>r&&H({type:"advance"}),q.current=r}),{threshold:1})),V=()=>v?(0,_.T)({id:"theme.SearchPage.existingResultsTitle",message:'Search results for "{query}"',description:"The search page title for non-empty query"},{query:v}):(0,_.T)({id:"theme.SearchPage.emptyResultsTitle",message:"Search the documentation",description:"The search page title for empty query"}),B=(0,F._q)((function(t){void 0===t&&(t=0),c&&(I.addDisjunctiveFacetRefinement("docusaurus_tag","default"),I.addDisjunctiveFacetRefinement("language",e),Object.entries(g.searchVersions).forEach((e=>{let[t,r]=e;I.addDisjunctiveFacetRefinement("docusaurus_tag",`docs-${t}-${r}`)}))),I.setQuery(v).setPage(t).search()}));return(0,n.useEffect)((()=>{if(!D)return;const e=L.current;return e?(e.observe(D),()=>e.unobserve(D)):()=>!0}),[D]),(0,n.useEffect)((()=>{H({type:"reset"}),v&&(H({type:"loading"}),setTimeout((()=>{B()}),300))}),[v,g.searchVersions,B]),(0,n.useEffect)((()=>{T.lastPage&&0!==T.lastPage&&B(T.lastPage)}),[B,T.lastPage]),(0,S.jsxs)(E.A,{children:[(0,S.jsxs)(h.A,{children:[(0,S.jsx)("title",{children:(0,j.s)(V())}),(0,S.jsx)("meta",{property:"robots",content:"noindex, follow"})]}),(0,S.jsxs)("div",{className:"container margin-vert--lg",children:[(0,S.jsx)(O.A,{as:"h1",children:V()}),(0,S.jsxs)("form",{className:"row",onSubmit:e=>e.preventDefault(),children:[(0,S.jsx)("div",{className:(0,i.A)("col",w.searchQueryColumn,{"col--9":g.versioningEnabled,"col--12":!g.versioningEnabled}),children:(0,S.jsx)("input",{type:"search",name:"q",className:w.searchQueryInput,placeholder:(0,_.T)({id:"theme.SearchPage.inputPlaceholder",message:"Type your search here",description:"The placeholder for search page input"}),"aria-label":(0,_.T)({id:"theme.SearchPage.inputLabel",message:"Search",description:"The ARIA label for search page input"}),onChange:e=>b(e.target.value),value:v,autoComplete:"off",autoFocus:!0})}),c&&g.versioningEnabled&&(0,S.jsx)(A,{docsSearchVersionsHelpers:g})]}),(0,S.jsxs)("div",{className:"row",children:[(0,S.jsx)("div",{className:(0,i.A)("col","col--8",w.searchResultsColumn),children:!!T.totalResults&&p(T.totalResults)}),(0,S.jsx)("div",{className:(0,i.A)("col","col--4","text--right",w.searchLogoColumn),children:(0,S.jsx)(f.A,{to:"https://www.algolia.com/","aria-label":(0,_.T)({id:"theme.SearchPage.algoliaLabel",message:"Search by Algolia",description:"The ARIA label for Algolia mention"}),children:(0,S.jsx)("svg",{viewBox:"0 0 168 24",className:w.algoliaLogo,children:(0,S.jsxs)("g",{fill:"none",children:[(0,S.jsx)("path",{className:w.algoliaLogoPathFill,d:"M120.925 18.804c-4.386.02-4.386-3.54-4.386-4.106l-.007-13.336 2.675-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-10.846-2.18c.821 0 1.43-.047 1.855-.129v-2.719a6.334 6.334 0 0 0-1.574-.199 5.7 5.7 0 0 0-.897.069 2.699 2.699 0 0 0-.814.24c-.24.116-.439.28-.582.491-.15.212-.219.335-.219.656 0 .628.219.991.616 1.23s.938.362 1.615.362zm-.233-9.7c.883 0 1.629.109 2.231.328.602.218 1.088.525 1.444.915.363.396.609.922.76 1.483.157.56.232 1.175.232 1.85v6.874a32.5 32.5 0 0 1-1.868.314c-.834.123-1.772.185-2.813.185-.69 0-1.327-.069-1.895-.198a4.001 4.001 0 0 1-1.471-.636 3.085 3.085 0 0 1-.951-1.134c-.226-.465-.343-1.12-.343-1.803 0-.656.13-1.073.384-1.525a3.24 3.24 0 0 1 1.047-1.106c.445-.287.95-.492 1.532-.615a8.8 8.8 0 0 1 1.82-.185 8.404 8.404 0 0 1 1.972.24v-.438c0-.307-.035-.6-.11-.874a1.88 1.88 0 0 0-.384-.73 1.784 1.784 0 0 0-.724-.493 3.164 3.164 0 0 0-1.143-.205c-.616 0-1.177.075-1.69.164a7.735 7.735 0 0 0-1.26.307l-.321-2.192c.335-.117.834-.233 1.478-.349a10.98 10.98 0 0 1 2.073-.178zm52.842 9.626c.822 0 1.43-.048 1.854-.13V13.7a6.347 6.347 0 0 0-1.574-.199c-.294 0-.595.021-.896.069a2.7 2.7 0 0 0-.814.24 1.46 1.46 0 0 0-.582.491c-.15.212-.218.335-.218.656 0 .628.218.991.615 1.23.404.245.938.362 1.615.362zm-.226-9.694c.883 0 1.629.108 2.231.327.602.219 1.088.526 1.444.915.355.39.609.923.759 1.483a6.8 6.8 0 0 1 .233 1.852v6.873c-.41.088-1.034.19-1.868.314-.834.123-1.772.184-2.813.184-.69 0-1.327-.068-1.895-.198a4.001 4.001 0 0 1-1.471-.635 3.085 3.085 0 0 1-.951-1.134c-.226-.465-.343-1.12-.343-1.804 0-.656.13-1.073.384-1.524.26-.45.608-.82 1.047-1.107.445-.286.95-.491 1.532-.614a8.803 8.803 0 0 1 2.751-.13c.329.034.671.096 1.04.185v-.437a3.3 3.3 0 0 0-.109-.875 1.873 1.873 0 0 0-.384-.731 1.784 1.784 0 0 0-.724-.492 3.165 3.165 0 0 0-1.143-.205c-.616 0-1.177.075-1.69.164a7.75 7.75 0 0 0-1.26.307l-.321-2.193c.335-.116.834-.232 1.478-.348a11.633 11.633 0 0 1 2.073-.177zm-8.034-1.271a1.626 1.626 0 0 1-1.628-1.62c0-.895.725-1.62 1.628-1.62.904 0 1.63.725 1.63 1.62 0 .895-.733 1.62-1.63 1.62zm1.348 13.22h-2.689V7.27l2.69-.423v11.956zm-4.714 0c-4.386.02-4.386-3.54-4.386-4.107l-.008-13.336 2.676-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-8.698-5.903c0-1.156-.253-2.119-.746-2.788-.493-.677-1.183-1.01-2.067-1.01-.882 0-1.574.333-2.065 1.01-.493.676-.733 1.632-.733 2.788 0 1.168.246 1.953.74 2.63.492.683 1.183 1.018 2.066 1.018.882 0 1.574-.342 2.067-1.019.492-.683.738-1.46.738-2.63zm2.737-.007c0 .902-.13 1.584-.397 2.33a5.52 5.52 0 0 1-1.128 1.906 4.986 4.986 0 0 1-1.752 1.223c-.685.286-1.739.45-2.265.45-.528-.006-1.574-.157-2.252-.45a5.096 5.096 0 0 1-1.744-1.223c-.487-.527-.863-1.162-1.137-1.906a6.345 6.345 0 0 1-.41-2.33c0-.902.123-1.77.397-2.508a5.554 5.554 0 0 1 1.15-1.892 5.133 5.133 0 0 1 1.75-1.216c.679-.287 1.425-.423 2.232-.423.808 0 1.553.142 2.237.423a4.88 4.88 0 0 1 1.753 1.216 5.644 5.644 0 0 1 1.135 1.892c.287.738.431 1.606.431 2.508zm-20.138 0c0 1.12.246 2.363.738 2.882.493.52 1.13.78 1.91.78.424 0 .828-.062 1.204-.178.377-.116.677-.253.917-.417V9.33a10.476 10.476 0 0 0-1.766-.226c-.971-.028-1.71.37-2.23 1.004-.513.636-.773 1.75-.773 2.788zm7.438 5.274c0 1.824-.466 3.156-1.404 4.004-.936.846-2.367 1.27-4.296 1.27-.705 0-2.17-.137-3.34-.396l.431-2.118c.98.205 2.272.26 2.95.26 1.074 0 1.84-.219 2.299-.656.459-.437.684-1.086.684-1.948v-.437a8.07 8.07 0 0 1-1.047.397c-.43.13-.93.198-1.492.198-.739 0-1.41-.116-2.018-.349a4.206 4.206 0 0 1-1.567-1.025c-.431-.45-.774-1.017-1.013-1.694-.24-.677-.363-1.885-.363-2.773 0-.834.13-1.88.384-2.577.26-.696.629-1.298 1.129-1.796.493-.498 1.095-.881 1.8-1.162a6.605 6.605 0 0 1 2.428-.457c.87 0 1.67.109 2.45.24.78.129 1.444.265 1.985.415V18.17zM6.972 6.677v1.627c-.712-.446-1.52-.67-2.425-.67-.585 0-1.045.13-1.38.391a1.24 1.24 0 0 0-.502 1.03c0 .425.164.765.494 1.02.33.256.835.532 1.516.83.447.192.795.356 1.045.495.25.138.537.332.862.582.324.25.563.548.718.894.154.345.23.741.23 1.188 0 .947-.334 1.691-1.004 2.234-.67.542-1.537.814-2.601.814-1.18 0-2.16-.229-2.936-.686v-1.708c.84.628 1.814.942 2.92.942.585 0 1.048-.136 1.388-.407.34-.271.51-.646.51-1.125 0-.287-.1-.55-.302-.79-.203-.24-.42-.42-.655-.542-.234-.123-.585-.29-1.053-.503a61.27 61.27 0 0 1-.582-.271 13.67 13.67 0 0 1-.55-.287 4.275 4.275 0 0 1-.567-.351 6.92 6.92 0 0 1-.455-.4c-.18-.17-.31-.34-.39-.51-.08-.17-.155-.37-.224-.598a2.553 2.553 0 0 1-.104-.742c0-.915.333-1.638.998-2.17.664-.532 1.523-.798 2.576-.798.968 0 1.793.17 2.473.51zm7.468 5.696v-.287c-.022-.607-.187-1.088-.495-1.444-.309-.357-.75-.535-1.324-.535-.532 0-.99.194-1.373.583-.382.388-.622.949-.717 1.683h3.909zm1.005 2.792v1.404c-.596.34-1.383.51-2.362.51-1.255 0-2.255-.377-3-1.132-.744-.755-1.116-1.744-1.116-2.968 0-1.297.34-2.316 1.021-3.055.68-.74 1.548-1.11 2.6-1.11 1.033 0 1.852.323 2.458.966.606.644.91 1.572.91 2.784 0 .33-.033.676-.096 1.038h-5.314c.107.702.405 1.239.894 1.611.49.372 1.106.558 1.85.558.862 0 1.58-.202 2.155-.606zm6.605-1.77h-1.212c-.596 0-1.045.116-1.349.35-.303.234-.454.532-.454.894 0 .372.117.664.35.877.235.213.575.32 1.022.32.51 0 .912-.142 1.204-.424.293-.281.44-.651.44-1.108v-.91zm-4.068-2.554V9.325c.627-.361 1.457-.542 2.489-.542 2.116 0 3.175 1.026 3.175 3.08V17h-1.548v-.957c-.415.68-1.143 1.02-2.186 1.02-.766 0-1.38-.22-1.843-.661-.462-.442-.694-1.003-.694-1.684 0-.776.293-1.38.878-1.81.585-.431 1.404-.647 2.457-.647h1.34V11.8c0-.554-.133-.971-.399-1.253-.266-.282-.707-.423-1.324-.423a4.07 4.07 0 0 0-2.345.718zm9.333-1.93v1.42c.394-1 1.101-1.5 2.123-1.5.148 0 .313.016.494.048v1.531a1.885 1.885 0 0 0-.75-.143c-.542 0-.989.24-1.34.718-.351.479-.527 1.048-.527 1.707V17h-1.563V8.91h1.563zm5.01 4.084c.022.82.272 1.492.75 2.019.479.526 1.15.79 2.01.79.639 0 1.235-.176 1.788-.527v1.404c-.521.319-1.186.479-1.995.479-1.265 0-2.276-.4-3.031-1.197-.755-.798-1.133-1.792-1.133-2.984 0-1.16.38-2.151 1.14-2.975.761-.825 1.79-1.237 3.088-1.237.702 0 1.346.149 1.93.447v1.436a3.242 3.242 0 0 0-1.77-.495c-.84 0-1.513.266-2.019.798-.505.532-.758 1.213-.758 2.042zM40.24 5.72v4.579c.458-1 1.293-1.5 2.505-1.5.787 0 1.42.245 1.899.734.479.49.718 1.17.718 2.042V17h-1.564v-5.106c0-.553-.14-.98-.422-1.284-.282-.303-.652-.455-1.11-.455-.531 0-1.002.202-1.411.606-.41.405-.615 1.022-.615 1.851V17h-1.563V5.72h1.563zm14.966 10.02c.596 0 1.096-.253 1.5-.758.404-.506.606-1.157.606-1.955 0-.915-.202-1.62-.606-2.114-.404-.495-.92-.742-1.548-.742-.553 0-1.05.224-1.491.67-.442.447-.662 1.133-.662 2.058 0 .958.212 1.67.638 2.138.425.469.946.703 1.563.703zM53.004 5.72v4.42c.574-.894 1.388-1.341 2.44-1.341 1.022 0 1.857.383 2.506 1.149.649.766.973 1.781.973 3.047 0 1.138-.309 2.109-.925 2.912-.617.803-1.463 1.205-2.537 1.205-1.075 0-1.894-.447-2.457-1.34V17h-1.58V5.72h1.58zm9.908 11.104l-3.223-7.913h1.739l1.005 2.632 1.26 3.415c.096-.32.48-1.458 1.15-3.415l.909-2.632h1.66l-2.92 7.866c-.777 2.074-1.963 3.11-3.559 3.11a2.92 2.92 0 0 1-.734-.079v-1.34c.17.042.351.064.543.064 1.032 0 1.755-.57 2.17-1.708z"}),(0,S.jsx)("path",{fill:"#5468FF",d:"M78.988.938h16.594a2.968 2.968 0 0 1 2.966 2.966V20.5a2.967 2.967 0 0 1-2.966 2.964H78.988a2.967 2.967 0 0 1-2.966-2.964V3.897A2.961 2.961 0 0 1 78.988.938z"}),(0,S.jsx)("path",{fill:"white",d:"M89.632 5.967v-.772a.978.978 0 0 0-.978-.977h-2.28a.978.978 0 0 0-.978.977v.793c0 .088.082.15.171.13a7.127 7.127 0 0 1 1.984-.28c.65 0 1.295.088 1.917.259.082.02.164-.04.164-.13m-6.248 1.01l-.39-.389a.977.977 0 0 0-1.382 0l-.465.465a.973.973 0 0 0 0 1.38l.383.383c.062.061.15.047.205-.014.226-.307.472-.601.746-.874.281-.28.568-.526.883-.751.068-.042.075-.137.02-.2m4.16 2.453v3.341c0 .096.104.165.192.117l2.97-1.537c.068-.034.089-.117.055-.184a3.695 3.695 0 0 0-3.08-1.866c-.068 0-.136.054-.136.13m0 8.048a4.489 4.489 0 0 1-4.49-4.482 4.488 4.488 0 0 1 4.49-4.482 4.488 4.488 0 0 1 4.489 4.482 4.484 4.484 0 0 1-4.49 4.482m0-10.85a6.363 6.363 0 1 0 0 12.729 6.37 6.37 0 0 0 6.372-6.368 6.358 6.358 0 0 0-6.371-6.36"})]})})})})]}),T.items.length>0?(0,S.jsx)("main",{children:T.items.map(((e,t)=>{let{title:r,url:n,summary:s,breadcrumbs:a}=e;return(0,S.jsxs)("article",{className:w.searchResultItem,children:[(0,S.jsx)(O.A,{as:"h2",className:w.searchResultItemHeading,children:(0,S.jsx)(f.A,{to:n,dangerouslySetInnerHTML:{__html:r}})}),a.length>0&&(0,S.jsx)("nav",{"aria-label":"breadcrumbs",children:(0,S.jsx)("ul",{className:(0,i.A)("breadcrumbs",w.searchResultItemPath),children:a.map(((e,t)=>(0,S.jsx)("li",{className:"breadcrumbs__item",dangerouslySetInnerHTML:{__html:e}},t)))})}),s&&(0,S.jsx)("p",{className:w.searchResultItemSummary,dangerouslySetInnerHTML:{__html:s}})]},t)}))}):[v&&!T.loading&&(0,S.jsx)("p",{children:(0,S.jsx)(_.A,{id:"theme.SearchPage.noResultsText",description:"The paragraph for empty search result",children:"No results were found"})},"no-results"),!!T.loading&&(0,S.jsx)("div",{className:w.loadingSpinner},"spinner")],T.hasMore&&(0,S.jsx)("div",{className:w.loader,ref:k,children:(0,S.jsx)(_.A,{id:"theme.SearchPage.fetchingNewResults",description:"The paragraph for fetching new search results",children:"Fetching new results..."})})]})]})}function T(){return(0,S.jsx)(b.e3,{className:"search-page-wrapper",children:(0,S.jsx)(N,{})})}}}]); \ No newline at end of file diff --git a/assets/js/1a4e3797.1fc0de54.js.LICENSE.txt b/assets/js/1a4e3797.1fc0de54.js.LICENSE.txt deleted file mode 100644 index 92dc1757f..000000000 --- a/assets/js/1a4e3797.1fc0de54.js.LICENSE.txt +++ /dev/null @@ -1 +0,0 @@ -/*! algoliasearch-lite.umd.js | 4.23.3 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */ diff --git a/assets/js/1a4e3797.675e6533.js b/assets/js/1a4e3797.675e6533.js new file mode 100644 index 000000000..68b0434cb --- /dev/null +++ b/assets/js/1a4e3797.675e6533.js @@ -0,0 +1,2 @@ +/*! For license information please see 1a4e3797.675e6533.js.LICENSE.txt */ +(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[138],{2733:e=>{function t(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function n(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},t.prototype.emit=function(e){var t,s,a,c,o,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||n(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i(s=this._events[e]))return!1;if(r(s))switch(arguments.length){case 1:s.call(this);break;case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:c=Array.prototype.slice.call(arguments,1),s.apply(this,c)}else if(n(s))for(c=Array.prototype.slice.call(arguments,1),a=(u=s.slice()).length,o=0;o0&&this._events[e].length>a&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){if(!r(t))throw TypeError("listener must be a function");var n=!1;function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},t.prototype.removeListener=function(e,t){var i,s,a,c;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(i=this._events[e]).length,s=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(n(i)){for(c=a;c-- >0;)if(i[c]===t||i[c].listener&&i[c].listener===t){s=c;break}if(s<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)}},4103:(e,t,r)=>{"use strict";var n=r(6571),i=r(9127),s=r(2223),a=r(3371),c=r(7691);function o(e,t,r,i){return new n(e,t,r,i)}o.version=r(6938),o.AlgoliaSearchHelper=n,o.SearchParameters=a,o.RecommendParameters=i,o.SearchResults=c,o.RecommendResults=s,e.exports=o},6732:(e,t,r)=>{"use strict";var n=r(2733);function i(e,t,r){this.main=e,this.fn=t,this.recommendFn=r,this.lastResults=null,this.lastRecommendResults=null}r(3014)(i,n),i.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},i.prototype.getModifiedState=function(e){return this.fn(e)},i.prototype.getModifiedRecommendState=function(e){return this.recommendFn(e)},e.exports=i},9127:e=>{"use strict";function t(e){e=e||{},this.params=e.params||[]}t.prototype={constructor:t,addParams:function(e){var r=this.params.slice();return r.push(e),new t({params:r})},removeParams:function(e){return new t({params:this.params.filter((function(t){return t.$$id!==e}))})},addFrequentlyBoughtTogether:function(e){return this.addParams(Object.assign({},e,{model:"bought-together"}))},addRelatedProducts:function(e){return this.addParams(Object.assign({},e,{model:"related-products"}))},addTrendingItems:function(e){return this.addParams(Object.assign({},e,{model:"trending-items"}))},addTrendingFacets:function(e){return this.addParams(Object.assign({},e,{model:"trending-facets"}))},addLookingSimilar:function(e){return this.addParams(Object.assign({},e,{model:"looking-similar"}))},_buildQueries:function(e,t){return this.params.filter((function(e){return void 0===t[e.$$id]})).map((function(t){var r=Object.assign({},t,{indexName:e,threshold:t.threshold||0});return delete r.$$id,r}))}},e.exports=t},2223:e=>{"use strict";function t(e,t){this._state=e,this._rawResults={};var r=this;e.params.forEach((function(e){var n=e.$$id;r[n]=t[n],r._rawResults[n]=t[n]}))}t.prototype={constructor:t},e.exports=t},1673:(e,t,r)=>{"use strict";var n=r(9110),i=r(317),s=r(1383),a={addRefinement:function(e,t,r){if(a.isRefined(e,t,r))return e;var i=""+r,s=e[t]?e[t].concat(i):[i],c={};return c[t]=s,n({},c,e)},removeRefinement:function(e,t,r){if(void 0===r)return a.clearRefinement(e,(function(e,r){return t===r}));var n=""+r;return a.clearRefinement(e,(function(e,r){return t===r&&n===e}))},toggleRefinement:function(e,t,r){if(void 0===r)throw new Error("toggleRefinement should be used with a value");return a.isRefined(e,t,r)?a.removeRefinement(e,t,r):a.addRefinement(e,t,r)},clearRefinement:function(e,t,r){if(void 0===t)return i(e)?{}:e;if("string"==typeof t)return s(e,[t]);if("function"==typeof t){var n=!1,a=Object.keys(e).reduce((function(i,s){var a=e[s]||[],c=a.filter((function(e){return!t(e,s,r)}));return c.length!==a.length&&(n=!0),i[s]=c,i}),{});return n?a:e}},isRefined:function(e,t,r){var n=Boolean(e[t])&&e[t].length>0;if(void 0===r||!n)return n;var i=""+r;return-1!==e[t].indexOf(i)}};e.exports=a},3371:(e,t,r)=>{"use strict";var n=r(9110),i=r(849),s=r(4843),a=r(4728),c=r(317),o=r(1383),u=r(7507),h=r(2208),f=r(1673);function l(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((function(e,r){return l(t[r],e)})):e===t}function m(e){var t=e?m._parseNumbers(e):{};void 0===t.userToken||h(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var r=this;Object.keys(t).forEach((function(e){var n=-1!==m.PARAMETERS.indexOf(e),i=void 0!==t[e];!n&&i&&(r[e]=t[e])}))}m.PARAMETERS=Object.keys(new m),m._parseNumbers=function(e){if(e instanceof m)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach((function(r){var n=e[r];if("string"==typeof n){var i=parseFloat(n);t[r]=isNaN(i)?n:i}})),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map((function(e){return Array.isArray(e)?e.map((function(e){return parseFloat(e)})):e}))),e.numericRefinements){var r={};Object.keys(e.numericRefinements).forEach((function(t){var n=e.numericRefinements[t]||{};r[t]={},Object.keys(n).forEach((function(e){var i=n[e].map((function(e){return Array.isArray(e)?e.map((function(e){return"string"==typeof e?parseFloat(e):e})):"string"==typeof e?parseFloat(e):e}));r[t][e]=i}))})),t.numericRefinements=r}return a(e,t)},m.make=function(e){var t=new m(e);return(e.hierarchicalFacets||[]).forEach((function(e){if(e.rootPath){var r=t.getHierarchicalRefinement(e.name);r.length>0&&0!==r[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),0===(r=t.getHierarchicalRefinement(e.name)).length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}})),t},m.validate=function(e,t){var r=t||{};return e.tagFilters&&r.tagRefinements&&r.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&r.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&r.numericRefinements&&c(r.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):c(e.numericRefinements)&&r.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},m.prototype={constructor:m,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:f.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:f.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:f.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:f.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,r){var n=u(r);if(this.isNumericRefined(e,t,n))return this;var i=a({},this.numericRefinements);return i[e]=a({},i[e]),i[e][t]?(i[e][t]=i[e][t].slice(),i[e][t].push(n)):i[e][t]=[n],this.setQueryParameters({numericRefinements:i})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsRefinements[e]||[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)&&this.disjunctiveFacetsRefinements[e]||[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsExcludes[e]||[]},removeNumericRefinement:function(e,t,r){var n=r;return void 0!==n?this.isNumericRefined(e,t,n)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,i){return i===e&&r.op===t&&l(r.val,u(n))}))}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,n){return n===e&&r.op===t}))}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(t,r){return r===e}))}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return c(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return o(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,r=this.numericRefinements,n=Object.keys(r).reduce((function(n,i){var s=r[i],a={};return s=s||{},Object.keys(s).forEach((function(r){var n=s[r]||[],c=[];n.forEach((function(t){e({val:t,op:r},i,"numeric")||c.push(t)})),c.length!==n.length&&(t=!0),a[r]=c})),n[i]=a,n}),{});return t?n:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:f.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:f.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:f.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter((function(t){return t!==e}))}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter((function(t){return t!==e}))}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter((function(t){return t.name!==e}))}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:f.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:f.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:f.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter((function(t){return t!==e}))};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:f.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:f.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:f.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),i={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+r))?-1===t.indexOf(r)?i[e]=[]:i[e]=[t.slice(0,t.lastIndexOf(r))]:i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},i,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var r={};return r[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:n({},r,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:n({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&f.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var r=this.getHierarchicalRefinement(e);return t?-1!==r.indexOf(t):r.length>0},isNumericRefined:function(e,t,r){if(void 0===r&&void 0===t)return Boolean(this.numericRefinements[e]);var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===r||!n)return n;var s,a,c=u(r),o=void 0!==(s=this.numericRefinements[e][t],a=c,i(s,(function(e){return l(e,a)})));return n&&o},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=s(Object.keys(this.numericRefinements).filter((function(t){return Object.keys(e.numericRefinements[t]).length>0})),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter((function(t){return e.disjunctiveFacetsRefinements[t].length>0})).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return s(this.hierarchicalFacets.map((function(e){return e.name})),Object.keys(this.hierarchicalFacetsRefinements).filter((function(t){return e.hierarchicalFacetsRefinements[t].length>0}))).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter((function(t){return-1===e.indexOf(t)}))},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},r=this;return Object.keys(this).forEach((function(n){var i=r[n];-1===e.indexOf(n)&&void 0!==i&&(t[n]=i)})),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var r={};return r[e]=t,this.setQueryParameters(r)},setQueryParameters:function(e){if(!e)return this;var t=m.validate(this,e);if(t)throw t;var r=this,n=m._parseNumbers(e),i=Object.keys(this).reduce((function(e,t){return e[t]=r[t],e}),{}),s=Object.keys(n).reduce((function(e,t){var r=void 0!==e[t],i=void 0!==n[t];return r&&!i?o(e,[t]):(i&&(e[t]=n[t]),e)}),i);return new this.constructor(s)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return i(this.hierarchicalFacets,(function(t){return t.name===e}))},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var r=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(r).map((function(e){return e.trim()}))},toString:function(){return JSON.stringify(this,null,2)}},e.exports=m},6673:(e,t,r)=>{"use strict";e.exports=function(e){return function(t,r){var n=e.hierarchicalFacets[r],u=e.hierarchicalFacetsRefinements[n.name]&&e.hierarchicalFacetsRefinements[n.name][0]||"",h=e._getHierarchicalFacetSeparator(n),f=e._getHierarchicalRootPath(n),l=e._getHierarchicalShowParentLevel(n),m=s(e._getHierarchicalFacetSortBy(n)),d=t.every((function(e){return e.exhaustive})),p=function(e,t,r,n,s){return function(u,h,f){var l=u;if(f>0){var m=0;for(l=u;m{"use strict";var n=r(8965),i=r(9110),s=r(2909),a=r(849),c=r(3917),o=r(7577),u=r(4728),h=r(8601),f=s.escapeFacetValue,l=s.unescapeFacetValue,m=r(6673);function d(e){var t={};return e.forEach((function(e,r){t[e]=r})),t}function p(e,t,r){t&&t[r]&&(e.stats=t[r])}function g(e,t,r){var s=t[0]||{};this._rawResults=t;var o=this;Object.keys(s).forEach((function(e){o[e]=s[e]}));var h=u({persistHierarchicalRootCount:!1},r);Object.keys(h).forEach((function(e){o[e]=h[e]})),this.processingTimeMS=t.reduce((function(e,t){return void 0===t.processingTimeMS?e:e+t.processingTimeMS}),0),this.disjunctiveFacets=[],this.hierarchicalFacets=e.hierarchicalFacets.map((function(){return[]})),this.facets=[];var f=e.getRefinedDisjunctiveFacets(),g=d(e.facets),v=d(e.disjunctiveFacets),y=1,R=s.facets||{};Object.keys(R).forEach((function(t){var r,n,i=R[t],u=(r=e.hierarchicalFacets,n=t,a(r,(function(e){return(e.attributes||[]).indexOf(n)>-1})));if(u){var h=u.attributes.indexOf(t),f=c(e.hierarchicalFacets,(function(e){return e.name===u.name}));o.hierarchicalFacets[f][h]={attribute:t,data:i,exhaustive:s.exhaustiveFacetsCount}}else{var l,m=-1!==e.disjunctiveFacets.indexOf(t),d=-1!==e.facets.indexOf(t);m&&(l=v[t],o.disjunctiveFacets[l]={name:t,data:i,exhaustive:s.exhaustiveFacetsCount},p(o.disjunctiveFacets[l],s.facets_stats,t)),d&&(l=g[t],o.facets[l]={name:t,data:i,exhaustive:s.exhaustiveFacetsCount},p(o.facets[l],s.facets_stats,t))}})),this.hierarchicalFacets=n(this.hierarchicalFacets),f.forEach((function(r){var n=t[y],a=n&&n.facets?n.facets:{},h=e.getHierarchicalFacetByName(r);Object.keys(a).forEach((function(t){var r,f=a[t];if(h){r=c(e.hierarchicalFacets,(function(e){return e.name===h.name}));var m=c(o.hierarchicalFacets[r],(function(e){return e.attribute===t}));if(-1===m)return;o.hierarchicalFacets[r][m].data=u({},o.hierarchicalFacets[r][m].data,f)}else{r=v[t];var d=s.facets&&s.facets[t]||{};o.disjunctiveFacets[r]={name:t,data:i({},f,d),exhaustive:n.exhaustiveFacetsCount},p(o.disjunctiveFacets[r],n.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach((function(n){!o.disjunctiveFacets[r].data[n]&&e.disjunctiveFacetsRefinements[t].indexOf(l(n))>-1&&(o.disjunctiveFacets[r].data[n]=0)}))}})),y++})),e.getRefinedHierarchicalFacets().forEach((function(r){var n=e.getHierarchicalFacetByName(r),s=e._getHierarchicalFacetSeparator(n),a=e.getHierarchicalRefinement(r);0===a.length||a[0].split(s).length<2||t.slice(y).forEach((function(t){var r=t&&t.facets?t.facets:{};Object.keys(r).forEach((function(t){var u=r[t],h=c(e.hierarchicalFacets,(function(e){return e.name===n.name})),f=c(o.hierarchicalFacets[h],(function(e){return e.attribute===t}));if(-1!==f){var l={};if(a.length>0&&!o.persistHierarchicalRootCount){var m=a[0].split(s)[0];l[m]=o.hierarchicalFacets[h][f].data[m]}o.hierarchicalFacets[h][f].data=i(l,u,o.hierarchicalFacets[h][f].data)}})),y++}))})),Object.keys(e.facetsExcludes).forEach((function(t){var r=e.facetsExcludes[t],n=g[t];o.facets[n]={name:t,data:R[t],exhaustive:s.exhaustiveFacetsCount},r.forEach((function(e){o.facets[n]=o.facets[n]||{name:t},o.facets[n].data=o.facets[n].data||{},o.facets[n].data[e]=0}))})),this.hierarchicalFacets=this.hierarchicalFacets.map(m(e)),this.facets=n(this.facets),this.disjunctiveFacets=n(this.disjunctiveFacets),this._state=e}function v(e,t){function r(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var n=a(e.facets,r);return n?Object.keys(n.data).map((function(r){var i=f(r);return{name:r,escapedValue:i,count:n.data[r],isRefined:e._state.isFacetRefined(t,i),isExcluded:e._state.isExcludeRefined(t,r)}})):[]}if(e._state.isDisjunctiveFacet(t)){var i=a(e.disjunctiveFacets,r);return i?Object.keys(i.data).map((function(r){var n=f(r);return{name:r,escapedValue:n,count:i.data[r],isRefined:e._state.isDisjunctiveFacetRefined(t,n)}})):[]}if(e._state.isHierarchicalFacet(t)){var s=a(e.hierarchicalFacets,r);if(!s)return s;var c=e._state.getHierarchicalFacetByName(t),o=e._state._getHierarchicalFacetSeparator(c),u=l(e._state.getHierarchicalRefinement(t)[0]||"");0===u.indexOf(c.rootPath)&&(u=u.replace(c.rootPath+o,""));var h=u.split(o);return h.unshift(t),y(s,h,0),s}}function y(e,t,r){e.isRefined=e.name===(t[r]&&t[r].trim()),e.data&&e.data.forEach((function(e){y(e,t,r+1)}))}function R(e,t,r,n){if(n=n||0,Array.isArray(t))return e(t,r[n]);if(!t.data||0===t.data.length)return t;var s=t.data.map((function(t){return R(e,t,r,n+1)})),a=e(s,r[n]);return i({data:a},t)}function F(e,t){var r=a(e,(function(e){return e.name===t}));return r&&r.stats}function b(e,t,r,n,i){var s=a(i,(function(e){return e.name===r})),c=s&&s.data&&s.data[n]?s.data[n]:0,o=s&&s.exhaustive||!1;return{type:t,attributeName:r,name:n,count:c,exhaustive:o}}g.prototype.getFacetByName=function(e){function t(t){return t.name===e}return a(this.facets,t)||a(this.disjunctiveFacets,t)||a(this.hierarchicalFacets,t)},g.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],g.prototype.getFacetValues=function(e,t){var r=v(this,e);if(r){var n,s=i({},t,{sortBy:g.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),a=this;if(Array.isArray(r))n=[e];else n=a._state.getHierarchicalFacetByName(r.name).attributes;return R((function(e,t){if(s.facetOrdering){var r=function(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}(a,t);if(r)return function(e,t){var r=[],n=[],i=t.hide||[],s=(t.order||[]).reduce((function(e,t,r){return e[t]=r,e}),{});e.forEach((function(e){var t=e.path||e.name,a=i.indexOf(t)>-1;a||void 0===s[t]?a||n.push(e):r[s[t]]=e})),r=r.filter((function(e){return e}));var a,c=t.sortRemainingBy;return"hidden"===c?r:(a="alpha"===c?[["path","name"],["asc","asc"]]:[["count"],["desc"]],r.concat(h(n,a[0],a[1])))}(e,r)}if(Array.isArray(s.sortBy)){var n=o(s.sortBy,g.DEFAULT_SORT);return h(e,n[0],n[1])}if("function"==typeof s.sortBy)return function(e,t){return t.sort(e)}(s.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")}),r,n)}},g.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?F(this.facets,e):this._state.isDisjunctiveFacet(e)?F(this.disjunctiveFacets,e):void 0},g.prototype.getRefinements=function(){var e=this._state,t=this,r=[];return Object.keys(e.facetsRefinements).forEach((function(n){e.facetsRefinements[n].forEach((function(i){r.push(b(e,"facet",n,i,t.facets))}))})),Object.keys(e.facetsExcludes).forEach((function(n){e.facetsExcludes[n].forEach((function(i){r.push(b(e,"exclude",n,i,t.facets))}))})),Object.keys(e.disjunctiveFacetsRefinements).forEach((function(n){e.disjunctiveFacetsRefinements[n].forEach((function(i){r.push(b(e,"disjunctive",n,i,t.disjunctiveFacets))}))})),Object.keys(e.hierarchicalFacetsRefinements).forEach((function(n){e.hierarchicalFacetsRefinements[n].forEach((function(i){r.push(function(e,t,r,n){var i=e.getHierarchicalFacetByName(t),s=e._getHierarchicalFacetSeparator(i),c=r.split(s),o=a(n,(function(e){return e.name===t})),u=c.reduce((function(e,t){var r=e&&a(e.data,(function(e){return e.name===t}));return void 0!==r?r:e}),o),h=u&&u.count||0,f=u&&u.exhaustive||!1,l=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:l,count:h,exhaustive:f}}(e,n,i,t.hierarchicalFacets))}))})),Object.keys(e.numericRefinements).forEach((function(t){var n=e.numericRefinements[t];Object.keys(n).forEach((function(e){n[e].forEach((function(n){r.push({type:"numeric",attributeName:t,name:n,numericValue:n,operator:e})}))}))})),e.tagRefinements.forEach((function(e){r.push({type:"tag",attributeName:"_tags",name:e})})),r},e.exports=g},6571:(e,t,r)=>{"use strict";var n=r(2733),i=r(6732),s=r(2909).escapeFacetValue,a=r(3014),c=r(4728),o=r(317),u=r(1383),h=r(9127),f=r(2223),l=r(9228),m=r(3371),d=r(7691),p=r(7749),g=r(6938);function v(e,t,r,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.setClient(e);var i=r||{};i.index=t,this.state=m.make(i),this.recommendState=new h({params:i.recommendState}),this.lastResults=null,this.lastRecommendResults=null,this._queryId=0,this._recommendQueryId=0,this._lastQueryIdReceived=-1,this._lastRecommendQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0,this._currentNbRecommendQueries=0,this._searchResultsOptions=n,this._recommendCache={}}function y(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function R(){return this.state.page}a(v,n),v.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},v.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},v.prototype.recommend=function(){return this._recommend(),this},v.prototype.getQuery=function(){var e=this.state;return l._getHitsSearchParams(e)},v.prototype.searchOnce=function(e,t){var r=e?this.state.setQueryParameters(e):this.state,n=l._getQueries(r.index,r),i=this;if(this._currentNbQueries++,this.emit("searchOnce",{state:r}),!t)return this.client.search(n).then((function(e){return i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),{content:new d(r,e.results),state:r,_originalResponse:e}}),(function(e){throw i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),e}));this.client.search(n).then((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(null,new d(r,e.results),r)})).catch((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(e,null,r)}))},v.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,r=this.derivedHelpers[0];if(!r)return Promise.resolve([]);var n=r.getModifiedState(t),i=c({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:u(l._getHitsSearchParams(n),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),s="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(s);var a=this.client.initIndex(n.index);if("function"!=typeof a.findAnswers)throw new Error(s);return a.findAnswers(n.query,e.queryLanguages,i)},v.prototype.searchForFacetValues=function(e,t,r,n){var i="function"==typeof this.client.searchForFacetValues,a="function"==typeof this.client.initIndex;if(!i&&!a&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var c=this.state.setQueryParameters(n||{}),o=c.isDisjunctiveFacet(e),u=l.getSearchForFacetQuery(e,t,r,c);this._currentNbQueries++;var h,f=this;return i?h=this.client.searchForFacetValues([{indexName:c.index,params:u}]):a?h=this.client.initIndex(c.index).searchForFacetValues(u):(delete u.facetName,h=this.client.search([{type:"facet",facet:e,indexName:c.index,params:u}]).then((function(e){return e.results[0]}))),this.emit("searchForFacetValues",{state:c,facet:e,query:t}),h.then((function(t){return f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),(t=Array.isArray(t)?t[0]:t).facetHits.forEach((function(t){t.escapedValue=s(t.value),t.isRefined=o?c.isDisjunctiveFacetRefined(e,t.escapedValue):c.isFacetRefined(e,t.escapedValue)})),t}),(function(e){throw f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),e}))},v.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},v.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},v.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},v.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},v.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addNumericRefinement=function(e,t,r){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,r),isPageReset:!0}),this},v.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},v.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},v.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},v.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},v.prototype.addFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.addFrequentlyBoughtTogether(e)}),this},v.prototype.addRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.addRelatedProducts(e)}),this},v.prototype.addTrendingItems=function(e){return this._recommendChange({state:this.recommendState.addTrendingItems(e)}),this},v.prototype.addTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.addTrendingFacets(e)}),this},v.prototype.addLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.addLookingSimilar(e)}),this},v.prototype.removeNumericRefinement=function(e,t,r){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,r),isPageReset:!0}),this},v.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},v.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},v.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},v.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},v.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},v.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},v.prototype.removeFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeTrendingItems=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.removeLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},v.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},v.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},v.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},v.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},v.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},v.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},v.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},v.prototype.setCurrentPage=y,v.prototype.setPage=y,v.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},v.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},v.prototype.setState=function(e){return this._change({state:m.make(e),isPageReset:!1}),this},v.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new m(e),this},v.prototype.hasRefinements=function(e){return!!o(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},v.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},v.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},v.prototype.hasTag=function(e){return this.state.isTagRefined(e)},v.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},v.prototype.getIndex=function(){return this.state.index},v.prototype.getCurrentPage=R,v.prototype.getPage=R,v.prototype.getTags=function(){return this.state.tagRefinements},v.prototype.getRefinements=function(e){var t=[];if(this.state.isConjunctiveFacet(e))this.state.getConjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"conjunctive"})})),this.state.getExcludeRefinements(e).forEach((function(e){t.push({value:e,type:"exclude"})}));else if(this.state.isDisjunctiveFacet(e)){this.state.getDisjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"disjunctive"})}))}var r=this.state.getNumericRefinements(e);return Object.keys(r).forEach((function(e){var n=r[e];t.push({value:n,operator:e,type:"numeric"})})),t},v.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},v.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},v.prototype._search=function(e){var t=this.state,r=[],n=[];e.onlyWithDerivedHelpers||(n=l._getQueries(t.index,t),r.push({state:t,queriesCount:n.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var i=this.derivedHelpers.map((function(e){var n=e.getModifiedState(t),i=n.index?l._getQueries(n.index,n):[];return r.push({state:n,queriesCount:i.length,helper:e}),e.emit("search",{state:n,results:e.lastResults}),i})),s=Array.prototype.concat.apply(n,i),a=this._queryId++;if(this._currentNbQueries++,!s.length)return Promise.resolve({results:[]}).then(this._dispatchAlgoliaResponse.bind(this,r,a));try{this.client.search(s).then(this._dispatchAlgoliaResponse.bind(this,r,a)).catch(this._dispatchAlgoliaError.bind(this,a))}catch(c){this.emit("error",{error:c})}},v.prototype._recommend=function(){var e=this.state,t=this.recommendState,r=this.getIndex(),n=[{state:t,index:r,helper:this}],i=t.params.map((function(e){return e.$$id}));this.emit("fetch",{recommend:{state:t,results:this.lastRecommendResults}});var s=this._recommendCache,a=this.derivedHelpers.map((function(t){var r=t.getModifiedState(e).index;if(!r)return[];var a=t.getModifiedRecommendState(new h);return n.push({state:a,index:r,helper:t}),i=Array.prototype.concat.apply(i,a.params.map((function(e){return e.$$id}))),t.emit("fetch",{recommend:{state:a,results:t.lastRecommendResults}}),a._buildQueries(r,s)})),c=Array.prototype.concat.apply(this.recommendState._buildQueries(r,s),a);if(0!==c.length)if(c.length>0&&void 0===this.client.getRecommendations)console.warn("Please update algoliasearch/lite to the latest version in order to use recommend widgets.");else{var o=this._recommendQueryId++;this._currentNbRecommendQueries++;try{this.client.getRecommendations(c).then(this._dispatchRecommendResponse.bind(this,o,n,i)).catch(this._dispatchRecommendError.bind(this,o))}catch(u){this.emit("error",{error:u})}}},v.prototype._dispatchAlgoliaResponse=function(e,t,r){var n=this;if(!(t0},v.prototype._change=function(e){var t=e.state,r=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:r}))},v.prototype._recommendChange=function(e){var t=e.state;t!==this.recommendState&&(this.recommendState=t,this.emit("recommend:change",{search:{results:this.lastResults,state:this.state},recommend:{results:this.lastRecommendResults,state:this.recommendState}}))},v.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},v.prototype.setClient=function(e){return this.client===e||("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.client=e),this},v.prototype.getClient=function(){return this.client},v.prototype.derive=function(e,t){var r=new i(this,e,t);return this.derivedHelpers.push(r),r},v.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},v.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},e.exports=v},8965:e=>{"use strict";e.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},9110:e=>{"use strict";e.exports=function(){return Array.prototype.slice.call(arguments).reduceRight((function(e,t){return Object.keys(Object(t)).forEach((function(r){void 0!==t[r]&&(void 0!==e[r]&&delete e[r],e[r]=t[r])})),e}),{})}},2909:e=>{"use strict";e.exports={escapeFacetValue:function(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")},unescapeFacetValue:function(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}}},849:e=>{"use strict";e.exports=function(e,t){if(Array.isArray(e))for(var r=0;r{"use strict";e.exports=function(e,t){if(!Array.isArray(e))return-1;for(var r=0;r{e.exports=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])}},7577:(e,t,r)=>{"use strict";var n=r(849);e.exports=function(e,t){var r=(t||[]).map((function(e){return e.split(":")}));return e.reduce((function(e,t){var i=t.split(":"),s=n(r,(function(e){return e[0]===i[0]}));return i.length>1||!s?(e[0].push(i[0]),e[1].push(i[1]),e):(e[0].push(s[0]),e[1].push(s[1]),e)}),[[],[]])}},3014:e=>{"use strict";e.exports=function(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},4843:e=>{"use strict";e.exports=function(e,t){return e.filter((function(r,n){return t.indexOf(r)>-1&&e.indexOf(r)===n}))}},4728:e=>{"use strict";function t(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function r(e,n){if(e===n)return e;for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)&&"__proto__"!==i&&"constructor"!==i){var s=n[i],a=e[i];void 0!==a&&void 0===s||(t(a)&&t(s)?e[i]=r(a,s):e[i]="object"==typeof(c=s)&&null!==c?r(Array.isArray(c)?[]:{},c):c)}var c;return e}e.exports=function(e){t(e)||(e={});for(var n=1,i=arguments.length;n{"use strict";e.exports=function(e){return e&&Object.keys(e).length>0}},1383:e=>{"use strict";e.exports=function(e,t){if(null===e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}},8601:e=>{"use strict";function t(e,t){if(e!==t){var r=void 0!==e,n=null===e,i=void 0!==t,s=null===t;if(!s&&e>t||n&&i||!r)return 1;if(!n&&e=n.length?s:"desc"===n[i]?-s:s}return e.index-r.index})),i.map((function(e){return e.value}))}},7507:e=>{"use strict";e.exports=function e(t){if("number"==typeof t)return t;if("string"==typeof t)return parseFloat(t);if(Array.isArray(t))return t.map(e);throw new Error("The value should be a number, a parsable string or an array of those.")}},9228:(e,t,r)=>{"use strict";var n=r(4728);function i(e){return Object.keys(e).sort().reduce((function(t,r){return t[r]=e[r],t}),{})}var s={_getQueries:function(e,t){var r=[];return r.push({indexName:e,params:s._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach((function(n){r.push({indexName:e,params:s._getDisjunctiveFacetSearchParams(t,n)})})),t.getRefinedHierarchicalFacets().forEach((function(n){var i=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(i);if(a.length>0&&a[0].split(c).length>1){var o=a[0].split(c).slice(0,-1).reduce((function(e,t,r){return e.concat({attribute:i.attributes[r],value:0===r?t:[e[e.length-1].value,t].join(c)})}),[]);o.forEach((function(n,a){var c=s._getDisjunctiveFacetSearchParams(t,n.attribute,0===a);function u(e){return i.attributes.some((function(t){return t===e.split(":")[0]}))}var h=(c.facetFilters||[]).reduce((function(e,t){if(Array.isArray(t)){var r=t.filter((function(e){return!u(e)}));r.length>0&&e.push(r)}return"string"!=typeof t||u(t)||e.push(t),e}),[]),f=o[a-1];a>0?c.facetFilters=h.concat(f.attribute+":"+f.value):h.length>0?c.facetFilters=h:delete c.facetFilters,r.push({indexName:e,params:c})}))}})),r},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(s._getHitsHierarchicalFacetsAttributes(e)).sort(),r=s._getFacetFilters(e),a=s._getNumericFilters(e),c=s._getTagFilters(e),o={};return t.length>0&&(o.facets=t.indexOf("*")>-1?["*"]:t),c.length>0&&(o.tagFilters=c),r.length>0&&(o.facetFilters=r),a.length>0&&(o.numericFilters=a),i(n({},e.getQueryParams(),o))},_getDisjunctiveFacetSearchParams:function(e,t,r){var a=s._getFacetFilters(e,t,r),c=s._getNumericFilters(e,t),o=s._getTagFilters(e),u={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};o.length>0&&(u.tagFilters=o);var h=e.getHierarchicalFacetByName(t);return u.facets=h?s._getDisjunctiveHierarchicalFacetAttribute(e,h,r):t,c.length>0&&(u.numericFilters=c),a.length>0&&(u.facetFilters=a),i(n({},e.getQueryParams(),u))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var r=[];return Object.keys(e.numericRefinements).forEach((function(n){var i=e.numericRefinements[n]||{};Object.keys(i).forEach((function(e){var s=i[e]||[];t!==n&&s.forEach((function(t){if(Array.isArray(t)){var i=t.map((function(t){return n+e+t}));r.push(i)}else r.push(n+e+t)}))}))})),r},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,r){var n=[],i=e.facetsRefinements||{};Object.keys(i).sort().forEach((function(e){(i[e]||[]).slice().sort().forEach((function(t){n.push(e+":"+t)}))}));var s=e.facetsExcludes||{};Object.keys(s).sort().forEach((function(e){(s[e]||[]).sort().forEach((function(t){n.push(e+":-"+t)}))}));var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).sort().forEach((function(e){var r=a[e]||[];if(e!==t&&r&&0!==r.length){var i=[];r.slice().sort().forEach((function(t){i.push(e+":"+t)})),n.push(i)}}));var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).sort().forEach((function(i){var s=(c[i]||[])[0];if(void 0!==s){var a,o,u=e.getHierarchicalFacetByName(i),h=e._getHierarchicalFacetSeparator(u),f=e._getHierarchicalRootPath(u);if(t===i){if(-1===s.indexOf(h)||!f&&!0===r||f&&f.split(h).length===s.split(h).length)return;f?(o=f.split(h).length-1,s=f):(o=s.split(h).length-2,s=s.slice(0,s.lastIndexOf(h))),a=u.attributes[o]}else o=s.split(h).length-1,a=u.attributes[o];a&&n.push([a+":"+s])}})),n},_getHitsHierarchicalFacetsAttributes:function(e){return e.hierarchicalFacets.reduce((function(t,r){var n=e.getHierarchicalRefinement(r.name)[0];if(!n)return t.push(r.attributes[0]),t;var i=e._getHierarchicalFacetSeparator(r),s=n.split(i).length,a=r.attributes.slice(0,s+1);return t.concat(a)}),[])},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,r){var n=e._getHierarchicalFacetSeparator(t);if(!0===r){var i=e._getHierarchicalRootPath(t),s=0;return i&&(s=i.split(n).length),[t.attributes[s]]}var a=(e.getHierarchicalRefinement(t.name)[0]||"").split(n).length-1;return t.attributes.slice(0,a+1)},getSearchForFacetQuery:function(e,t,r,a){var c=a.isDisjunctiveFacet(e)?a.clearRefinements(e):a,o={facetQuery:t,facetName:e};return"number"==typeof r&&(o.maxFacetHits=r),i(n({},s._getHitsSearchParams(c),o))}};e.exports=s},2208:e=>{"use strict";e.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},7749:(e,t,r)=>{"use strict";var n=r(849),i=r(8657);e.exports=function(e){var t={};return e.forEach((function(e){e.forEach((function(e,r){t[e.objectID]?t[e.objectID]={indexSum:t[e.objectID].indexSum+r,count:t[e.objectID].count+1}:t[e.objectID]={indexSum:r,count:1}}))})),function(e,t){var r=[];return Object.keys(e).forEach((function(n){e[n].count<2&&(e[n].indexSum+=100),r.push({objectID:n,avgOfIndices:e[n].indexSum/t})})),r.sort((function(e,t){return e.avgOfIndices>t.avgOfIndices?1:-1}))}(t,e.length).reduce((function(t,r){var s=n(i(e),(function(e){return e.objectID===r.objectID}));return s?t.concat(s):t}),[])}},6938:e=>{"use strict";e.exports="3.22.3"},3643:function(e){e.exports=function(){"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var r=[],n=!0,i=!1,s=void 0;try{for(var a,c=e[Symbol.iterator]();!(n=(a=c.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,s=e}finally{try{n||null==c.return||c.return()}finally{if(i)throw s}}return r}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then((function(){c();var t=JSON.stringify(e);return s()[t]})).then((function(e){return Promise.all([e?e.value:t(),void 0!==e])})).then((function(e){var t=i(e,2),n=t[0],s=t[1];return Promise.all([n,s||r.miss(n)])})).then((function(e){return i(e,1)[0]}))},set:function(e,t){return Promise.resolve().then((function(){var i=s();return i[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},n().setItem(r,JSON.stringify(i)),t}))},delete:function(e){return Promise.resolve().then((function(){var t=s();delete t[JSON.stringify(e)],n().setItem(r,JSON.stringify(t))}))},clear:function(){return Promise.resolve().then((function(){n().removeItem(r)}))}}}function c(e){var t=s(e.caches),r=t.shift();return void 0===r?{get:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return t().then((function(e){return Promise.all([e,r.miss(e)])})).then((function(e){return i(e,1)[0]}))},set:function(e,t){return Promise.resolve(t)},delete:function(e){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return r.get(e,n,i).catch((function(){return c({caches:t}).get(e,n,i)}))},set:function(e,n){return r.set(e,n).catch((function(){return c({caches:t}).set(e,n)}))},delete:function(e){return r.delete(e).catch((function(){return c({caches:t}).delete(e)}))},clear:function(){return r.clear().catch((function(){return c({caches:t}).clear()}))}}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serializable:!0},t={};return{get:function(r,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);var a=n(),c=i&&i.miss||function(){return Promise.resolve()};return a.then((function(e){return c(e)})).then((function(){return a}))},set:function(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete:function(e){return delete t[JSON.stringify(e)],Promise.resolve()},clear:function(){return t={},Promise.resolve()}}}function u(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function h(e,t){return t?(Object.keys(t).forEach((function(r){e[r]=t[r](e)})),e):e}function f(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var d={Read:1,Write:2,Any:3},p=1,g=2,v=3;function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;return r(r({},e),{},{status:t,lastUpdate:Date.now()})}function R(e){return"string"==typeof e?{protocol:"https",url:e,accept:d.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||d.Any}}var F="GET",b="POST";function j(e,t){return Promise.all(t.map((function(t){return e.get(t,(function(){return Promise.resolve(y(t))}))}))).then((function(e){var r=e.filter((function(e){return function(e){return e.status===p||Date.now()-e.lastUpdate>12e4}(e)})),n=e.filter((function(e){return function(e){return e.status===v&&Date.now()-e.lastUpdate<=12e4}(e)})),i=[].concat(s(r),s(n));return{getTimeout:function(e,t){return(0===n.length&&0===e?1:n.length+3+e)*t},statelessHosts:i.length>0?i.map((function(e){return R(e)})):t}}))}function _(e,t,n,i){var a=[],c=function(e,t){if(e.method!==F&&(void 0!==e.data||void 0!==t.data)){var n=Array.isArray(e.data)?e.data:r(r({},e.data),t.data);return JSON.stringify(n)}}(n,i),o=function(e,t){var n=r(r({},e.headers),t.headers),i={};return Object.keys(n).forEach((function(e){var t=n[e];i[e.toLowerCase()]=t})),i}(e,i),u=n.method,h=n.method!==F?{}:r(r({},n.data),i.data),f=r(r(r({"x-algolia-agent":e.userAgent.value},e.queryParameters),h),i.queryParameters),l=0,m=function t(r,s){var h=r.pop();if(void 0===h)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support .",transporterStackTrace:O(a)};var m={data:c,headers:o,method:u,url:x(h,n.path,f),connectTimeout:s(l,e.timeouts.connect),responseTimeout:s(l,i.timeout)},d=function(e){var t={request:m,response:e,host:h,triesLeft:r.length};return a.push(t),t},p={onSuccess:function(e){return function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e)},onRetry:function(n){var i=d(n);return n.isTimedOut&&l++,Promise.all([e.logger.info("Retryable failure",w(i)),e.hostsCache.set(h,y(h,n.isTimedOut?v:g))]).then((function(){return t(r,s)}))},onFail:function(e){throw d(e),function(e,t){var r=e.content,n=e.status,i=r;try{i=JSON.parse(r).message}catch(e){}return function(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}(i,n,t)}(e,O(a))}};return e.requester.send(m).then((function(e){return function(e,t){return function(e){var t=e.status;return e.isTimedOut||function(e){var t=e.isTimedOut,r=e.status;return!t&&!~~r}(e)||2!=~~(t/100)&&4!=~~(t/100)}(e)?t.onRetry(e):2==~~(e.status/100)?t.onSuccess(e):t.onFail(e)}(e,p)}))};return j(e.hostsCache,t).then((function(e){return m(s(e.statelessHosts).reverse(),e.getTimeout)}))}function P(e){var t={value:"Algolia for JavaScript (".concat(e,")"),add:function(e){var r="; ".concat(e.segment).concat(void 0!==e.version?" (".concat(e.version,")"):"");return-1===t.value.indexOf(r)&&(t.value="".concat(t.value).concat(r)),t}};return t}function x(e,t,r){var n=E(r),i="".concat(e.protocol,"://").concat(e.url,"/").concat("/"===t.charAt(0)?t.substr(1):t);return n.length&&(i+="?".concat(n)),i}function E(e){return Object.keys(e).map((function(t){return f("%s=%s",t,(r=e[t],"[object Object]"===Object.prototype.toString.call(r)||"[object Array]"===Object.prototype.toString.call(r)?JSON.stringify(e[t]):e[t]));var r})).join("&")}function O(e){return e.map((function(e){return w(e)}))}function w(e){var t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return r(r({},e),{},{request:r(r({},e.request),{},{headers:r(r({},e.request.headers),t)})})}var S=function(e){var t=e.appId,n=function(e,t,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:function(){return e===l.WithinHeaders?n:{}},queryParameters:function(){return e===l.WithinQueryParameters?n:{}}}}(void 0!==e.authMode?e.authMode:l.WithinHeaders,t,e.apiKey),s=function(e){var t=e.hostsCache,r=e.logger,n=e.requester,s=e.requestsCache,a=e.responsesCache,c=e.timeouts,o=e.userAgent,u=e.hosts,h=e.queryParameters,f={hostsCache:t,logger:r,requester:n,requestsCache:s,responsesCache:a,timeouts:c,userAgent:o,headers:e.headers,queryParameters:h,hosts:u.map((function(e){return R(e)})),read:function(e,t){var r=m(t,f.timeouts.read),n=function(){return _(f,f.hosts.filter((function(e){return!!(e.accept&d.Read)})),e,r)};if(!0!==(void 0!==r.cacheable?r.cacheable:e.cacheable))return n();var s={request:e,mappedRequestOptions:r,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(s,(function(){return f.requestsCache.get(s,(function(){return f.requestsCache.set(s,n()).then((function(e){return Promise.all([f.requestsCache.delete(s),e])}),(function(e){return Promise.all([f.requestsCache.delete(s),Promise.reject(e)])})).then((function(e){var t=i(e,2);return t[0],t[1]}))}))}),{miss:function(e){return f.responsesCache.set(s,e)}})},write:function(e,t){return _(f,f.hosts.filter((function(e){return!!(e.accept&d.Write)})),e,m(t,f.timeouts.write))}};return f}(r(r({hosts:[{url:"".concat(t,"-dsn.algolia.net"),accept:d.Read},{url:"".concat(t,".algolia.net"),accept:d.Write}].concat(u([{url:"".concat(t,"-1.algolianet.com")},{url:"".concat(t,"-2.algolianet.com")},{url:"".concat(t,"-3.algolianet.com")}]))},e),{},{headers:r(r(r({},n.headers()),{"content-type":"application/x-www-form-urlencoded"}),e.headers),queryParameters:r(r({},n.queryParameters()),e.queryParameters)}));return h({transporter:s,appId:t,addAlgoliaAgent:function(e,t){s.userAgent.add({segment:e,version:t})},clearCache:function(){return Promise.all([s.requestsCache.clear(),s.responsesCache.clear()]).then((function(){}))}},e.methods)},A=function(e){return function(t,r){return t.method===F?e.transporter.read(t,r):e.transporter.write(t,r)}},N=function(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h({transporter:e.transporter,appId:e.appId,indexName:t},r.methods)}},T=function(e){return function(t,n){var i=t.map((function(e){return r(r({},e),{},{params:E(e.params||{})})}));return e.transporter.read({method:b,path:"1/indexes/*/queries",data:{requests:i},cacheable:!0},n)}},H=function(e){return function(t,i){return Promise.all(t.map((function(t){var s=t.params,a=s.facetName,c=s.facetQuery,o=n(s,["facetName","facetQuery"]);return N(e)(t.indexName,{methods:{searchForFacetValues:I}}).searchForFacetValues(a,c,r(r({},i),o))})))}},Q=function(e){return function(t,r,n){return e.transporter.read({method:b,path:f("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n)}},C=function(e){return function(t,r){return e.transporter.read({method:b,path:f("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r)}},I=function(e){return function(t,r,n){return e.transporter.read({method:b,path:f("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n)}},D=1,k=2,q=3,L=function(e){return function(t,n){var i=t.map((function(e){return r(r({},e),{},{threshold:e.threshold||0})}));return e.transporter.read({method:b,path:"1/indexes/*/recommendations",data:{requests:i},cacheable:!0},n)}};function V(e,t,n){var i,s={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:function(e){return new Promise((function(t){var r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((function(t){return r.setRequestHeader(t,e.headers[t])}));var n,i=function(e,n){return setTimeout((function(){r.abort(),t({status:0,content:n,isTimedOut:!0})}),1e3*e)},s=i(e.connectTimeout,"Connection timeout");r.onreadystatechange=function(){r.readyState>r.OPENED&&void 0===n&&(clearTimeout(s),n=i(e.responseTimeout,"Socket timeout"))},r.onerror=function(){0===r.status&&(clearTimeout(s),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=function(){clearTimeout(s),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},logger:(i=q,{debug:function(e,t){return D>=i&&console.debug(e,t),Promise.resolve()},info:function(e,t){return k>=i&&console.info(e,t),Promise.resolve()},error:function(e,t){return console.error(e,t),Promise.resolve()}}),responsesCache:o(),requestsCache:o({serializable:!1}),hostsCache:c({caches:[a({key:"".concat("4.24.0","-").concat(e)}),o()]}),userAgent:P("4.24.0").add({segment:"Browser",version:"lite"}),authMode:l.WithinQueryParameters};return S(r(r(r({},s),n),{},{methods:{search:T,searchForFacetValues:H,multipleQueries:T,multipleSearchForFacetValues:H,customRequest:A,initIndex:function(e){return function(t){return N(e)(t,{methods:{search:C,searchForFacetValues:I,findAnswers:Q}})}},getRecommendations:L}}))}return V.version="4.24.0",V}()},9057:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>T});var n=r(6540),i=r(4164),s=r(4103),a=r.n(s),c=r(3643),o=r.n(c),u=r(8193),h=r(5260),f=r(8774),l=r(4070),m=r(4586);const d=["zero","one","two","few","many","other"];function p(e){return d.filter((t=>e.includes(t)))}const g={locale:"en",pluralForms:p(["one","other"]),select:e=>1===e?"one":"other"};function v(){const{i18n:{currentLocale:e}}=(0,m.A)();return(0,n.useMemo)((()=>{try{return function(e){const t=new Intl.PluralRules(e);return{locale:e,pluralForms:p(t.resolvedOptions().pluralCategories),select:e=>t.select(e)}}(e)}catch(t){return console.error(`Failed to use Intl.PluralRules for locale "${e}".\nDocusaurus will fallback to the default (English) implementation.\nError: ${t.message}\n`),g}}),[e])}function y(){const e=v();return{selectMessage:(t,r)=>function(e,t,r){const n=e.split("|");if(1===n.length)return n[0];n.length>r.pluralForms.length&&console.error(`For locale=${r.locale}, a maximum of ${r.pluralForms.length} plural forms are expected (${r.pluralForms.join(",")}), but the message contains ${n.length}: ${e}`);const i=r.select(t),s=r.pluralForms.indexOf(i);return n[Math.min(s,n.length-1)]}(r,t,e)}}var R=r(4255),F=r(9532),b=r(9024),j=r(481),_=r(1312),P=r(8126),x=r(1062),E=r(1957),O=r(1107);const w={searchQueryInput:"searchQueryInput_u2C7",searchVersionInput:"searchVersionInput_m0Ui",searchResultsColumn:"searchResultsColumn_JPFH",algoliaLogo:"algoliaLogo_rT1R",algoliaLogoPathFill:"algoliaLogoPathFill_WdUC",searchResultItem:"searchResultItem_Tv2o",searchResultItemHeading:"searchResultItemHeading_KbCB",searchResultItemPath:"searchResultItemPath_lhe1",searchResultItemSummary:"searchResultItemSummary_AEaO",searchQueryColumn:"searchQueryColumn_RTkw",searchVersionColumn:"searchVersionColumn_ypXd",searchLogoColumn:"searchLogoColumn_rJIA",loadingSpinner:"loadingSpinner_XVxU","loading-spin":"loading-spin_vzvp",loader:"loader_vvXV"};var S=r(4848);function A(e){let{docsSearchVersionsHelpers:t}=e;const r=Object.entries(t.allDocsData).filter((e=>{let[,t]=e;return t.versions.length>1}));return(0,S.jsx)("div",{className:(0,i.A)("col","col--3","padding-left--none",w.searchVersionColumn),children:r.map((e=>{let[n,i]=e;const s=r.length>1?`${n}: `:"";return(0,S.jsx)("select",{onChange:e=>t.setSearchVersion(n,e.target.value),defaultValue:t.searchVersions[n],className:w.searchVersionInput,children:i.versions.map(((e,t)=>(0,S.jsx)("option",{label:`${s}${e.label}`,value:e.name},t)))},n)}))})}function N(){const{i18n:{currentLocale:e}}=(0,m.A)(),{algolia:{appId:t,apiKey:r,indexName:s,contextualSearch:c}}=(0,P.c)(),d=(0,x.C)(),p=function(){const{selectMessage:e}=y();return t=>e(t,(0,_.T)({id:"theme.SearchPage.documentsFound.plurals",description:'Pluralized label for "{count} documents found". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',message:"One document found|{count} documents found"},{count:t}))}(),g=function(){const e=(0,l.Gy)(),[t,r]=(0,n.useState)((()=>Object.entries(e).reduce(((e,t)=>{let[r,n]=t;return{...e,[r]:n.versions[0].name}}),{}))),i=Object.values(e).some((e=>e.versions.length>1));return{allDocsData:e,versioningEnabled:i,searchVersions:t,setSearchVersion:(e,t)=>r((r=>({...r,[e]:t})))}}(),[v,b]=(0,R.b)(),N={items:[],query:null,totalResults:null,totalPages:null,lastPage:null,hasMore:null,loading:null},[T,H]=(0,n.useReducer)(((e,t)=>{switch(t.type){case"reset":return N;case"loading":return{...e,loading:!0};case"update":return v!==t.value.query?e:{...t.value,items:0===t.value.lastPage?t.value.items:e.items.concat(t.value.items)};case"advance":{const t=e.totalPages>e.lastPage+1;return{...e,lastPage:t?e.lastPage+1:e.lastPage,hasMore:t}}default:return e}}),N),Q=c?["language","docusaurus_tag"]:[],C=o()(t,r),I=a()(C,s,{hitsPerPage:15,advancedSyntax:!0,disjunctiveFacets:Q});I.on("result",(e=>{let{results:{query:t,hits:r,page:n,nbHits:i,nbPages:s}}=e;if(""===t||!Array.isArray(r))return void H({type:"reset"});const a=e=>e.replace(/algolia-docsearch-suggestion--highlight/g,"search-result-match"),c=r.map((e=>{let{url:t,_highlightResult:{hierarchy:r},_snippetResult:n={}}=e;const i=Object.keys(r).map((e=>a(r[e].value)));return{title:i.pop(),url:d(t),summary:n.content?`${a(n.content.value)}...`:"",breadcrumbs:i}}));H({type:"update",value:{items:c,query:t,totalResults:i,totalPages:s,lastPage:n,hasMore:s>n+1,loading:!1}})}));const[D,k]=(0,n.useState)(null),q=(0,n.useRef)(0),L=(0,n.useRef)(u.A.canUseIntersectionObserver&&new IntersectionObserver((e=>{const{isIntersecting:t,boundingClientRect:{y:r}}=e[0];t&&q.current>r&&H({type:"advance"}),q.current=r}),{threshold:1})),V=()=>v?(0,_.T)({id:"theme.SearchPage.existingResultsTitle",message:'Search results for "{query}"',description:"The search page title for non-empty query"},{query:v}):(0,_.T)({id:"theme.SearchPage.emptyResultsTitle",message:"Search the documentation",description:"The search page title for empty query"}),B=(0,F._q)((function(t){void 0===t&&(t=0),c&&(I.addDisjunctiveFacetRefinement("docusaurus_tag","default"),I.addDisjunctiveFacetRefinement("language",e),Object.entries(g.searchVersions).forEach((e=>{let[t,r]=e;I.addDisjunctiveFacetRefinement("docusaurus_tag",`docs-${t}-${r}`)}))),I.setQuery(v).setPage(t).search()}));return(0,n.useEffect)((()=>{if(!D)return;const e=L.current;return e?(e.observe(D),()=>e.unobserve(D)):()=>!0}),[D]),(0,n.useEffect)((()=>{H({type:"reset"}),v&&(H({type:"loading"}),setTimeout((()=>{B()}),300))}),[v,g.searchVersions,B]),(0,n.useEffect)((()=>{T.lastPage&&0!==T.lastPage&&B(T.lastPage)}),[B,T.lastPage]),(0,S.jsxs)(E.A,{children:[(0,S.jsxs)(h.A,{children:[(0,S.jsx)("title",{children:(0,j.s)(V())}),(0,S.jsx)("meta",{property:"robots",content:"noindex, follow"})]}),(0,S.jsxs)("div",{className:"container margin-vert--lg",children:[(0,S.jsx)(O.A,{as:"h1",children:V()}),(0,S.jsxs)("form",{className:"row",onSubmit:e=>e.preventDefault(),children:[(0,S.jsx)("div",{className:(0,i.A)("col",w.searchQueryColumn,{"col--9":g.versioningEnabled,"col--12":!g.versioningEnabled}),children:(0,S.jsx)("input",{type:"search",name:"q",className:w.searchQueryInput,placeholder:(0,_.T)({id:"theme.SearchPage.inputPlaceholder",message:"Type your search here",description:"The placeholder for search page input"}),"aria-label":(0,_.T)({id:"theme.SearchPage.inputLabel",message:"Search",description:"The ARIA label for search page input"}),onChange:e=>b(e.target.value),value:v,autoComplete:"off",autoFocus:!0})}),c&&g.versioningEnabled&&(0,S.jsx)(A,{docsSearchVersionsHelpers:g})]}),(0,S.jsxs)("div",{className:"row",children:[(0,S.jsx)("div",{className:(0,i.A)("col","col--8",w.searchResultsColumn),children:!!T.totalResults&&p(T.totalResults)}),(0,S.jsx)("div",{className:(0,i.A)("col","col--4","text--right",w.searchLogoColumn),children:(0,S.jsx)(f.A,{to:"https://www.algolia.com/","aria-label":(0,_.T)({id:"theme.SearchPage.algoliaLabel",message:"Search by Algolia",description:"The ARIA label for Algolia mention"}),children:(0,S.jsx)("svg",{viewBox:"0 0 168 24",className:w.algoliaLogo,children:(0,S.jsxs)("g",{fill:"none",children:[(0,S.jsx)("path",{className:w.algoliaLogoPathFill,d:"M120.925 18.804c-4.386.02-4.386-3.54-4.386-4.106l-.007-13.336 2.675-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-10.846-2.18c.821 0 1.43-.047 1.855-.129v-2.719a6.334 6.334 0 0 0-1.574-.199 5.7 5.7 0 0 0-.897.069 2.699 2.699 0 0 0-.814.24c-.24.116-.439.28-.582.491-.15.212-.219.335-.219.656 0 .628.219.991.616 1.23s.938.362 1.615.362zm-.233-9.7c.883 0 1.629.109 2.231.328.602.218 1.088.525 1.444.915.363.396.609.922.76 1.483.157.56.232 1.175.232 1.85v6.874a32.5 32.5 0 0 1-1.868.314c-.834.123-1.772.185-2.813.185-.69 0-1.327-.069-1.895-.198a4.001 4.001 0 0 1-1.471-.636 3.085 3.085 0 0 1-.951-1.134c-.226-.465-.343-1.12-.343-1.803 0-.656.13-1.073.384-1.525a3.24 3.24 0 0 1 1.047-1.106c.445-.287.95-.492 1.532-.615a8.8 8.8 0 0 1 1.82-.185 8.404 8.404 0 0 1 1.972.24v-.438c0-.307-.035-.6-.11-.874a1.88 1.88 0 0 0-.384-.73 1.784 1.784 0 0 0-.724-.493 3.164 3.164 0 0 0-1.143-.205c-.616 0-1.177.075-1.69.164a7.735 7.735 0 0 0-1.26.307l-.321-2.192c.335-.117.834-.233 1.478-.349a10.98 10.98 0 0 1 2.073-.178zm52.842 9.626c.822 0 1.43-.048 1.854-.13V13.7a6.347 6.347 0 0 0-1.574-.199c-.294 0-.595.021-.896.069a2.7 2.7 0 0 0-.814.24 1.46 1.46 0 0 0-.582.491c-.15.212-.218.335-.218.656 0 .628.218.991.615 1.23.404.245.938.362 1.615.362zm-.226-9.694c.883 0 1.629.108 2.231.327.602.219 1.088.526 1.444.915.355.39.609.923.759 1.483a6.8 6.8 0 0 1 .233 1.852v6.873c-.41.088-1.034.19-1.868.314-.834.123-1.772.184-2.813.184-.69 0-1.327-.068-1.895-.198a4.001 4.001 0 0 1-1.471-.635 3.085 3.085 0 0 1-.951-1.134c-.226-.465-.343-1.12-.343-1.804 0-.656.13-1.073.384-1.524.26-.45.608-.82 1.047-1.107.445-.286.95-.491 1.532-.614a8.803 8.803 0 0 1 2.751-.13c.329.034.671.096 1.04.185v-.437a3.3 3.3 0 0 0-.109-.875 1.873 1.873 0 0 0-.384-.731 1.784 1.784 0 0 0-.724-.492 3.165 3.165 0 0 0-1.143-.205c-.616 0-1.177.075-1.69.164a7.75 7.75 0 0 0-1.26.307l-.321-2.193c.335-.116.834-.232 1.478-.348a11.633 11.633 0 0 1 2.073-.177zm-8.034-1.271a1.626 1.626 0 0 1-1.628-1.62c0-.895.725-1.62 1.628-1.62.904 0 1.63.725 1.63 1.62 0 .895-.733 1.62-1.63 1.62zm1.348 13.22h-2.689V7.27l2.69-.423v11.956zm-4.714 0c-4.386.02-4.386-3.54-4.386-4.107l-.008-13.336 2.676-.424v13.254c0 .322 0 2.358 1.718 2.364v2.248zm-8.698-5.903c0-1.156-.253-2.119-.746-2.788-.493-.677-1.183-1.01-2.067-1.01-.882 0-1.574.333-2.065 1.01-.493.676-.733 1.632-.733 2.788 0 1.168.246 1.953.74 2.63.492.683 1.183 1.018 2.066 1.018.882 0 1.574-.342 2.067-1.019.492-.683.738-1.46.738-2.63zm2.737-.007c0 .902-.13 1.584-.397 2.33a5.52 5.52 0 0 1-1.128 1.906 4.986 4.986 0 0 1-1.752 1.223c-.685.286-1.739.45-2.265.45-.528-.006-1.574-.157-2.252-.45a5.096 5.096 0 0 1-1.744-1.223c-.487-.527-.863-1.162-1.137-1.906a6.345 6.345 0 0 1-.41-2.33c0-.902.123-1.77.397-2.508a5.554 5.554 0 0 1 1.15-1.892 5.133 5.133 0 0 1 1.75-1.216c.679-.287 1.425-.423 2.232-.423.808 0 1.553.142 2.237.423a4.88 4.88 0 0 1 1.753 1.216 5.644 5.644 0 0 1 1.135 1.892c.287.738.431 1.606.431 2.508zm-20.138 0c0 1.12.246 2.363.738 2.882.493.52 1.13.78 1.91.78.424 0 .828-.062 1.204-.178.377-.116.677-.253.917-.417V9.33a10.476 10.476 0 0 0-1.766-.226c-.971-.028-1.71.37-2.23 1.004-.513.636-.773 1.75-.773 2.788zm7.438 5.274c0 1.824-.466 3.156-1.404 4.004-.936.846-2.367 1.27-4.296 1.27-.705 0-2.17-.137-3.34-.396l.431-2.118c.98.205 2.272.26 2.95.26 1.074 0 1.84-.219 2.299-.656.459-.437.684-1.086.684-1.948v-.437a8.07 8.07 0 0 1-1.047.397c-.43.13-.93.198-1.492.198-.739 0-1.41-.116-2.018-.349a4.206 4.206 0 0 1-1.567-1.025c-.431-.45-.774-1.017-1.013-1.694-.24-.677-.363-1.885-.363-2.773 0-.834.13-1.88.384-2.577.26-.696.629-1.298 1.129-1.796.493-.498 1.095-.881 1.8-1.162a6.605 6.605 0 0 1 2.428-.457c.87 0 1.67.109 2.45.24.78.129 1.444.265 1.985.415V18.17zM6.972 6.677v1.627c-.712-.446-1.52-.67-2.425-.67-.585 0-1.045.13-1.38.391a1.24 1.24 0 0 0-.502 1.03c0 .425.164.765.494 1.02.33.256.835.532 1.516.83.447.192.795.356 1.045.495.25.138.537.332.862.582.324.25.563.548.718.894.154.345.23.741.23 1.188 0 .947-.334 1.691-1.004 2.234-.67.542-1.537.814-2.601.814-1.18 0-2.16-.229-2.936-.686v-1.708c.84.628 1.814.942 2.92.942.585 0 1.048-.136 1.388-.407.34-.271.51-.646.51-1.125 0-.287-.1-.55-.302-.79-.203-.24-.42-.42-.655-.542-.234-.123-.585-.29-1.053-.503a61.27 61.27 0 0 1-.582-.271 13.67 13.67 0 0 1-.55-.287 4.275 4.275 0 0 1-.567-.351 6.92 6.92 0 0 1-.455-.4c-.18-.17-.31-.34-.39-.51-.08-.17-.155-.37-.224-.598a2.553 2.553 0 0 1-.104-.742c0-.915.333-1.638.998-2.17.664-.532 1.523-.798 2.576-.798.968 0 1.793.17 2.473.51zm7.468 5.696v-.287c-.022-.607-.187-1.088-.495-1.444-.309-.357-.75-.535-1.324-.535-.532 0-.99.194-1.373.583-.382.388-.622.949-.717 1.683h3.909zm1.005 2.792v1.404c-.596.34-1.383.51-2.362.51-1.255 0-2.255-.377-3-1.132-.744-.755-1.116-1.744-1.116-2.968 0-1.297.34-2.316 1.021-3.055.68-.74 1.548-1.11 2.6-1.11 1.033 0 1.852.323 2.458.966.606.644.91 1.572.91 2.784 0 .33-.033.676-.096 1.038h-5.314c.107.702.405 1.239.894 1.611.49.372 1.106.558 1.85.558.862 0 1.58-.202 2.155-.606zm6.605-1.77h-1.212c-.596 0-1.045.116-1.349.35-.303.234-.454.532-.454.894 0 .372.117.664.35.877.235.213.575.32 1.022.32.51 0 .912-.142 1.204-.424.293-.281.44-.651.44-1.108v-.91zm-4.068-2.554V9.325c.627-.361 1.457-.542 2.489-.542 2.116 0 3.175 1.026 3.175 3.08V17h-1.548v-.957c-.415.68-1.143 1.02-2.186 1.02-.766 0-1.38-.22-1.843-.661-.462-.442-.694-1.003-.694-1.684 0-.776.293-1.38.878-1.81.585-.431 1.404-.647 2.457-.647h1.34V11.8c0-.554-.133-.971-.399-1.253-.266-.282-.707-.423-1.324-.423a4.07 4.07 0 0 0-2.345.718zm9.333-1.93v1.42c.394-1 1.101-1.5 2.123-1.5.148 0 .313.016.494.048v1.531a1.885 1.885 0 0 0-.75-.143c-.542 0-.989.24-1.34.718-.351.479-.527 1.048-.527 1.707V17h-1.563V8.91h1.563zm5.01 4.084c.022.82.272 1.492.75 2.019.479.526 1.15.79 2.01.79.639 0 1.235-.176 1.788-.527v1.404c-.521.319-1.186.479-1.995.479-1.265 0-2.276-.4-3.031-1.197-.755-.798-1.133-1.792-1.133-2.984 0-1.16.38-2.151 1.14-2.975.761-.825 1.79-1.237 3.088-1.237.702 0 1.346.149 1.93.447v1.436a3.242 3.242 0 0 0-1.77-.495c-.84 0-1.513.266-2.019.798-.505.532-.758 1.213-.758 2.042zM40.24 5.72v4.579c.458-1 1.293-1.5 2.505-1.5.787 0 1.42.245 1.899.734.479.49.718 1.17.718 2.042V17h-1.564v-5.106c0-.553-.14-.98-.422-1.284-.282-.303-.652-.455-1.11-.455-.531 0-1.002.202-1.411.606-.41.405-.615 1.022-.615 1.851V17h-1.563V5.72h1.563zm14.966 10.02c.596 0 1.096-.253 1.5-.758.404-.506.606-1.157.606-1.955 0-.915-.202-1.62-.606-2.114-.404-.495-.92-.742-1.548-.742-.553 0-1.05.224-1.491.67-.442.447-.662 1.133-.662 2.058 0 .958.212 1.67.638 2.138.425.469.946.703 1.563.703zM53.004 5.72v4.42c.574-.894 1.388-1.341 2.44-1.341 1.022 0 1.857.383 2.506 1.149.649.766.973 1.781.973 3.047 0 1.138-.309 2.109-.925 2.912-.617.803-1.463 1.205-2.537 1.205-1.075 0-1.894-.447-2.457-1.34V17h-1.58V5.72h1.58zm9.908 11.104l-3.223-7.913h1.739l1.005 2.632 1.26 3.415c.096-.32.48-1.458 1.15-3.415l.909-2.632h1.66l-2.92 7.866c-.777 2.074-1.963 3.11-3.559 3.11a2.92 2.92 0 0 1-.734-.079v-1.34c.17.042.351.064.543.064 1.032 0 1.755-.57 2.17-1.708z"}),(0,S.jsx)("path",{fill:"#5468FF",d:"M78.988.938h16.594a2.968 2.968 0 0 1 2.966 2.966V20.5a2.967 2.967 0 0 1-2.966 2.964H78.988a2.967 2.967 0 0 1-2.966-2.964V3.897A2.961 2.961 0 0 1 78.988.938z"}),(0,S.jsx)("path",{fill:"white",d:"M89.632 5.967v-.772a.978.978 0 0 0-.978-.977h-2.28a.978.978 0 0 0-.978.977v.793c0 .088.082.15.171.13a7.127 7.127 0 0 1 1.984-.28c.65 0 1.295.088 1.917.259.082.02.164-.04.164-.13m-6.248 1.01l-.39-.389a.977.977 0 0 0-1.382 0l-.465.465a.973.973 0 0 0 0 1.38l.383.383c.062.061.15.047.205-.014.226-.307.472-.601.746-.874.281-.28.568-.526.883-.751.068-.042.075-.137.02-.2m4.16 2.453v3.341c0 .096.104.165.192.117l2.97-1.537c.068-.034.089-.117.055-.184a3.695 3.695 0 0 0-3.08-1.866c-.068 0-.136.054-.136.13m0 8.048a4.489 4.489 0 0 1-4.49-4.482 4.488 4.488 0 0 1 4.49-4.482 4.488 4.488 0 0 1 4.489 4.482 4.484 4.484 0 0 1-4.49 4.482m0-10.85a6.363 6.363 0 1 0 0 12.729 6.37 6.37 0 0 0 6.372-6.368 6.358 6.358 0 0 0-6.371-6.36"})]})})})})]}),T.items.length>0?(0,S.jsx)("main",{children:T.items.map(((e,t)=>{let{title:r,url:n,summary:s,breadcrumbs:a}=e;return(0,S.jsxs)("article",{className:w.searchResultItem,children:[(0,S.jsx)(O.A,{as:"h2",className:w.searchResultItemHeading,children:(0,S.jsx)(f.A,{to:n,dangerouslySetInnerHTML:{__html:r}})}),a.length>0&&(0,S.jsx)("nav",{"aria-label":"breadcrumbs",children:(0,S.jsx)("ul",{className:(0,i.A)("breadcrumbs",w.searchResultItemPath),children:a.map(((e,t)=>(0,S.jsx)("li",{className:"breadcrumbs__item",dangerouslySetInnerHTML:{__html:e}},t)))})}),s&&(0,S.jsx)("p",{className:w.searchResultItemSummary,dangerouslySetInnerHTML:{__html:s}})]},t)}))}):[v&&!T.loading&&(0,S.jsx)("p",{children:(0,S.jsx)(_.A,{id:"theme.SearchPage.noResultsText",description:"The paragraph for empty search result",children:"No results were found"})},"no-results"),!!T.loading&&(0,S.jsx)("div",{className:w.loadingSpinner},"spinner")],T.hasMore&&(0,S.jsx)("div",{className:w.loader,ref:k,children:(0,S.jsx)(_.A,{id:"theme.SearchPage.fetchingNewResults",description:"The paragraph for fetching new search results",children:"Fetching new results..."})})]})]})}function T(){return(0,S.jsx)(b.e3,{className:"search-page-wrapper",children:(0,S.jsx)(N,{})})}}}]); \ No newline at end of file diff --git a/assets/js/1a4e3797.675e6533.js.LICENSE.txt b/assets/js/1a4e3797.675e6533.js.LICENSE.txt new file mode 100644 index 000000000..bfc7620fe --- /dev/null +++ b/assets/js/1a4e3797.675e6533.js.LICENSE.txt @@ -0,0 +1 @@ +/*! algoliasearch-lite.umd.js | 4.24.0 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */ diff --git a/assets/js/21dc2778.1bac1858.js b/assets/js/21dc2778.1bac1858.js new file mode 100644 index 000000000..4faafa494 --- /dev/null +++ b/assets/js/21dc2778.1bac1858.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[295],{8478:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>u,default:()=>b,frontMatter:()=>m,metadata:()=>x,toc:()=>j});var l=i(4848),t=i(8453),s=i(8774),d=i(6684),a=i(2364),o=i(9365),r=i(1470),c=i(7324),h=i(6694);const m={sidebar_position:2,sidebar_label:"Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",keywords:["c++ orm","database","migrations","tinyorm"]},u="Database: Migrations",x={id:"database/migrations",title:"Database: Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",source:"@site/docs/database/migrations.mdx",sourceDirName:"database",slug:"/database/migrations",permalink:"/database/migrations",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",keywords:["c++ orm","database","migrations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Query Builder",permalink:"/database/query-builder"},next:{title:"Seeding",permalink:"/database/seeding"}},p={},j=[{value:"Introduction",id:"introduction",level:2},{value:"Generating Migrations",id:"generating-migrations",level:2},{value:"Migrations naming rules",id:"migrations-naming-rules",level:4},{value:"Tab completion",id:"tab-completion",level:2},{value:"Alternative installation methods",id:"alternative-installation-methods",level:3},{value:"Static installation",id:"static-installation",level:4},{value:"Dynamic installation",id:"dynamic-installation",level:4},{value:"Migration Structure",id:"migration-structure",level:2},{value:"Setting The Migration Connection",id:"setting-the-migration-connection",level:4},{value:"Running Migrations",id:"running-migrations",level:2},{value:"Forcing Migrations To Run In Production",id:"forcing-migrations-to-run-in-production",level:4},{value:"Rolling Back Migrations",id:"rolling-back-migrations",level:3},{value:"Roll Back & Migrate Using A Single Command",id:"roll-back--migrate-using-a-single-command",level:4},{value:"Drop All Tables & Migrate",id:"drop-all-tables--migrate",level:4},{value:"Tables",id:"tables",level:2},{value:"Creating Tables",id:"creating-tables",level:3},{value:"Checking For Table / Column Existence",id:"checking-for-table--column-existence",level:4},{value:"Database Connection & Table Options",id:"database-connection--table-options",level:4},{value:"Updating Tables",id:"updating-tables",level:3},{value:"Renaming / Dropping Tables",id:"renaming-and-dropping-tables",level:3},{value:"Renaming Tables With Foreign Keys",id:"renaming-tables-with-foreign-keys",level:4},{value:"Columns",id:"columns",level:2},{value:"Creating Columns",id:"creating-columns",level:3},{value:"Available Column Types",id:"available-column-types",level:3},{value:"bigIncrements()",id:"column-method-bigIncrements",level:4},{value:"bigInteger()",id:"column-method-bigInteger",level:4},{value:"binary()",id:"column-method-binary",level:4},{value:"boolean()",id:"column-method-boolean",level:4},{value:"Char()",id:"column-method-Char",level:4},{value:"date()",id:"column-method-date",level:4},{value:"datetime()",id:"column-method-datetime",level:4},{value:"datetimes()",id:"column-method-datetimes",level:4},{value:"datetimeTz()",id:"column-method-datetimeTz",level:4},{value:"decimal()",id:"column-method-decimal",level:4},{value:"Double()",id:"column-method-Double",level:4},{value:"Enum()",id:"column-method-Enum",level:4},{value:"Float()",id:"column-method-Float",level:4},{value:"foreignId()",id:"column-method-foreignId",level:4},{value:"foreignIdFor()",id:"column-method-foreignIdFor",level:4},{value:"foreignUuid()",id:"column-method-foreignUuid",level:4},{value:"geometry()",id:"column-method-geometry",level:4},{value:"geometryCollection()",id:"column-method-geometryCollection",level:4},{value:"id()",id:"column-method-id",level:4},{value:"increments()",id:"column-method-increments",level:4},{value:"integer()",id:"column-method-integer",level:4},{value:"ipAddress()",id:"column-method-ipAddress",level:4},{value:"json()",id:"column-method-json",level:4},{value:"jsonb()",id:"column-method-jsonb",level:4},{value:"lineString()",id:"column-method-lineString",level:4},{value:"longBinary()",id:"column-method-longBinary",level:4},{value:"longText()",id:"column-method-longText",level:4},{value:"macAddress()",id:"column-method-macAddress",level:4},{value:"mediumBinary()",id:"column-method-mediumBinary",level:4},{value:"mediumIncrements()",id:"column-method-mediumIncrements",level:4},{value:"mediumInteger()",id:"column-method-mediumInteger",level:4},{value:"mediumText()",id:"column-method-mediumText",level:4},{value:"multiLineString()",id:"column-method-multiLineString",level:4},{value:"multiPoint()",id:"column-method-multiPoint",level:4},{value:"multiPolygon()",id:"column-method-multiPolygon",level:4},{value:"point()",id:"column-method-point",level:4},{value:"polygon()",id:"column-method-polygon",level:4},{value:"rememberToken()",id:"column-method-rememberToken",level:4},{value:"set()",id:"column-method-set",level:4},{value:"smallIncrements()",id:"column-method-smallIncrements",level:4},{value:"smallInteger()",id:"column-method-smallInteger",level:4},{value:"softDeletes()",id:"column-method-softDeletes",level:4},{value:"softDeletesDatetime()",id:"column-method-softDeletesDatetime",level:4},{value:"softDeletesTz()",id:"column-method-softDeletesTz",level:4},{value:"string()",id:"column-method-string",level:4},{value:"text()",id:"column-method-text",level:4},{value:"time()",id:"column-method-time",level:4},{value:"timeTz()",id:"column-method-timeTz",level:4},{value:"timestamp()",id:"column-method-timestamp",level:4},{value:"timestampTz()",id:"column-method-timestampTz",level:4},{value:"timestampsTz()",id:"column-method-timestampsTz",level:4},{value:"timestamps()",id:"column-method-timestamps",level:4},{value:"tinyBinary()",id:"column-method-tinyBinary",level:4},{value:"tinyIncrements()",id:"column-method-tinyIncrements",level:4},{value:"tinyInteger()",id:"column-method-tinyInteger",level:4},{value:"tinyText()",id:"column-method-tinyText",level:4},{value:"unsignedBigInteger()",id:"column-method-unsignedBigInteger",level:4},{value:"unsignedDecimal()",id:"column-method-unsignedDecimal",level:4},{value:"unsignedInteger()",id:"column-method-unsignedInteger",level:4},{value:"unsignedMediumInteger()",id:"column-method-unsignedMediumInteger",level:4},{value:"unsignedSmallInteger()",id:"column-method-unsignedSmallInteger",level:4},{value:"unsignedTinyInteger()",id:"column-method-unsignedTinyInteger",level:4},{value:"uuid()",id:"column-method-uuid",level:4},{value:"year()",id:"column-method-year",level:4},{value:"Column Modifiers",id:"column-modifiers",level:3},{value:"Default Expressions",id:"default-expressions",level:4},{value:"Column Order",id:"column-order",level:4},{value:"Modifying Columns",id:"modifying-columns",level:3},{value:"Renaming Columns",id:"renaming-columns",level:4},{value:"Renaming Columns On Legacy Databases",id:"renaming-columns-on-legacy-databases",level:4},{value:"Dropping Columns",id:"dropping-columns",level:3},{value:"Available Command Aliases",id:"available-command-aliases",level:4},{value:"Indexes",id:"indexes",level:2},{value:"Creating Indexes",id:"creating-indexes",level:3},{value:"Available Index Types",id:"available-index-types",level:4},{value:"Index Lengths & MySQL / MariaDB",id:"index-lengths--mysql--mariadb",level:4},{value:"Renaming Indexes",id:"renaming-indexes",level:3},{value:"Dropping Indexes",id:"dropping-indexes",level:3},{value:"Foreign Key Constraints",id:"foreign-key-constraints",level:3},{value:"Dropping Foreign Keys",id:"dropping-foreign-keys",level:4},{value:"Toggling Foreign Key Constraints",id:"toggling-foreign-key-constraints",level:4}];function g(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"database-migrations",children:"Database: Migrations"})}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#generating-migrations",children:"Generating Migrations"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#tab-completion",children:"Tab completion"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#alternative-installation-methods",children:"Alternative installation methods"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#migration-structure",children:"Migration Structure"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#running-migrations",children:"Running Migrations"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#rolling-back-migrations",children:"Rolling Back Migrations"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#tables",children:"Tables"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-tables",children:"Creating Tables"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#updating-tables",children:"Updating Tables"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#renaming-and-dropping-tables",children:"Renaming / Dropping Tables"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#columns",children:"Columns"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-columns",children:"Creating Columns"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#available-column-types",children:"Available Column Types"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#column-modifiers",children:"Column Modifiers"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#modifying-columns",children:"Modifying Columns"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dropping-columns",children:"Dropping Columns"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#indexes",children:"Indexes"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-indexes",children:"Creating Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#renaming-indexes",children:"Renaming Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dropping-indexes",children:"Dropping Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#foreign-key-constraints",children:"Foreign Key Constraints"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,l.jsx)("div",{className:"api-stability alert alert--success",children:(0,l.jsxs)(n.p,{children:[(0,l.jsx)(s.A,{to:"/stability#stability-indexes",children:(0,l.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,l.jsx)(n.p,{children:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. If you have ever had to tell a teammate to manually add a column to their local database schema after pulling in your changes from source control, you've faced the problem that database migrations solve."}),"\n",(0,l.jsxs)(n.p,{children:["The TinyORM ",(0,l.jsx)(n.code,{children:"Schema"})," facade provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems. Typically, migrations will use this facade to create and modify database tables and columns."]}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom"})," migrations is a small console application that depends on the ",(0,l.jsx)(n.code,{children:"TinyORM"})," library. All migrations logic is compiled so recompilation is needed after adding a new migration class."]}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.a,{href:"/database/migrations#tables",children:(0,l.jsx)(n.code,{children:"schema builder"})})," and ",(0,l.jsx)(n.a,{href:"/database/migrations",children:(0,l.jsx)(n.code,{children:"migrations"})})," don't support ",(0,l.jsx)(n.a,{href:"/database/getting-started#multi-threading-support",children:"multi-threading"}),"."]})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsxs)(n.p,{children:["TinyORM's schema builder supports all ",(0,l.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"})," out of the box."]})}),"\n",(0,l.jsxs)(n.p,{children:["The following image shows what the ",(0,l.jsx)(n.code,{children:"tom"})," console application looks like. \u2728 As you can see it offers everything that is needed to generate and manage migrations and seeders and all of this is backed up with the tab completion."]}),"\n",(0,l.jsx)("img",{src:i(5848).A,alt:"TinyORM - Tom console application - Showcase",width:"760",title:"TinyORM - Tom console application - Showcase"}),"\n",(0,l.jsx)(n.h2,{id:"generating-migrations",children:"Generating Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["You may use the ",(0,l.jsx)(n.code,{children:"make:migration"})," ",(0,l.jsx)(n.code,{children:"tom"})," command to generate a database migration. The new migration will be placed in your ",(0,l.jsx)(n.code,{children:"database/migrations"})," directory. Each migration filename contains a timestamp that allows ",(0,l.jsx)(n.code,{children:"tom"})," to determine the order of the migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom make:migration create_posts_table\n"})}),"\n",(0,l.jsxs)(n.p,{children:["tom will use the name of the migration to attempt to guess the name of the table and whether or not the migration will be creating a new table. If ",(0,l.jsx)(n.code,{children:"tom"})," is able to determine the table name from the migration name, ",(0,l.jsx)(n.code,{children:"tom"})," will pre-fill the generated migration file with the specified table. Otherwise, you may simply specify the table in the migration file manually."]}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to specify a custom path for the generated migration, you may use the ",(0,l.jsx)(n.code,{children:"--path"})," option when executing the ",(0,l.jsx)(n.code,{children:"make:migration"})," command. The given path should be relative to your ",(0,l.jsx)("abbr",{title:"Current working directory",children:"pwd"})," or you can use the ",(0,l.jsx)(n.code,{children:"--realpath"})," option and pass the absolute path to the ",(0,l.jsx)(n.code,{children:"--path"})," option."]}),"\n",(0,l.jsx)(n.h4,{id:"migrations-naming-rules",children:"Migrations naming rules"}),"\n",(0,l.jsxs)(n.p,{children:["If the migration name starts with the ",(0,l.jsx)(n.code,{children:"create_"})," string then the stub for table creation will be used and if the migration name contains ",(0,l.jsx)(n.code,{children:"_(from|to|in)_"})," then the stub for table update will be used. You can override these rules using the ",(0,l.jsx)(n.code,{children:"--create"})," and ",(0,l.jsx)(n.code,{children:"--table"})," options and specify the table name manually."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can also pass the full migration filename with the datetime prefix and extension to the ",(0,l.jsx)(n.code,{children:"make:migration"}),". This command is able to detect almost any combination of the passed value, with or without datetime prefix or extension if it is the filename; or StudlyCase, snake_case, or kebab-case if it is the classname or any combination described above. \ud83d\udc40"]})}),"\n",(0,l.jsx)(n.h2,{id:"tab-completion",children:"Tab completion"}),"\n",(0,l.jsxs)(n.p,{children:["Tab completion is available for the ",(0,l.jsx)(n.code,{children:"pwsh"})," (on Linux too), ",(0,l.jsx)(n.code,{children:"bash"}),", and ",(0,l.jsx)(n.code,{children:"zsh"})," shells. For ",(0,l.jsx)(n.code,{children:"pwsh"})," the ",(0,l.jsx)(n.code,{children:"tom.exe"})," and ",(0,l.jsx)(n.code,{children:"TinyOrm0.dll"})," library must be on the system path to work properly. With ",(0,l.jsx)(n.code,{children:"bash"})," if the ",(0,l.jsx)(n.code,{children:"tom"})," executable and ",(0,l.jsx)(n.code,{children:"libTinyOrm.so"})," library is ",(0,l.jsx)(n.strong,{children:"not"})," on the system path then it will provide less accurate completions."]}),"\n",(0,l.jsx)(n.p,{children:"You can enable it using the following commands."}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.b,label:c.ux,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"tom integrate pwsh\n"})})}),(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom integrate bash\n"})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom integrate zsh\ntom integrate zsh --path=/usr/share/zsh/site-functions\n"})})})]}),"\n",(0,l.jsxs)(n.p,{children:["Or you can enable it manually. Following actions are the same as the ",(0,l.jsx)(n.code,{children:"tom integrate"})," command does."]}),"\n",(0,l.jsxs)(n.p,{children:["For the ",(0,l.jsx)(n.code,{children:"pwsh"})," paste the following code to the pwsh profile (works on Linux or Windows)."]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",metastring:"title='~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1'",children:"Register-ArgumentCompleter -Native -CommandName tom,tom_testdata -ScriptBlock {\n Param($wordToComplete, $commandAst, $cursorPosition)\n [Console]::InputEncoding =\n [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()\n $Local:word = $wordToComplete.Replace('\"', '\\\"')\n $Local:ast = $commandAst.ToString().Replace('\"', '\\\"')\n tom complete --word=\"$Local:word\" --commandline=\"$Local:ast\" --position=$cursorPosition\n | ForEach-Object {\n $completionText, $listText, $toolTip = $_ -split ';', 3\n $listText ??= $completionText\n $toolTip ??= $completionText\n [System.Management.Automation.CompletionResult]::new(\n $completionText, $listText, 'ParameterValue', $toolTip)\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["For ",(0,l.jsx)(n.code,{children:"bash"})," you can copy or create symlink of the ",(0,l.jsx)(n.code,{children:"/tools/completions/tom.bash"})," file to the ",(0,l.jsx)(n.code,{children:"/usr/share/bash-completion/completions"})," folder."]}),"\n",(0,l.jsx)(a.A,{className:"language-bash",children:`sudo ln -s ${(0,h.OZ)(c.xj)}/TinyORM/tools/completions/tom.bash /usr/share/bash-completion/completions/tom`}),"\n",(0,l.jsxs)(n.p,{children:["And for ",(0,l.jsx)(n.code,{children:"zsh"})," you can copy or create symlink of the ",(0,l.jsx)(n.code,{children:"/tools/completions/tom.zsh"})," file to the ",(0,l.jsx)(n.code,{children:"_tom"})," file to ",(0,l.jsx)(n.code,{children:"/usr/local/share/zsh/site-functions"})," folder."]}),"\n",(0,l.jsx)(a.A,{className:"language-bash",children:`sudo ln -s ${(0,h.OZ)(c.xj)}/TinyORM/tools/completions/tom.zsh /usr/local/share/zsh/site-functions/_tom`}),"\n",(0,l.jsxs)(n.p,{children:["It will provide completions for the ",(0,l.jsx)(n.code,{children:"tom"})," commands, long and short parameters, and also for some positional arguments like namespaces for the ",(0,l.jsx)(n.code,{children:"list"})," command or commands for the ",(0,l.jsx)(n.code,{children:"help"})," command."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom integrate zsh"})," command also accepts the ",(0,l.jsx)(n.code,{children:"--path="})," option with which you can set the location, where the zsh completion file should be created."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can also output the completion script using the ",(0,l.jsx)(n.code,{children:"--stdout"})," option eg. ",(0,l.jsx)(n.code,{children:"tom integrate bash --stdout"}),"."]})}),"\n",(0,l.jsx)(n.h3,{id:"alternative-installation-methods",children:"Alternative installation methods"}),"\n",(0,l.jsxs)(n.p,{children:["This section describes alternative installation methods for ",(0,l.jsx)(n.code,{children:"bash"})," and ",(0,l.jsx)(n.code,{children:"zsh"})," tab completions."]}),"\n",(0,l.jsx)(n.h4,{id:"static-installation",children:"Static installation"}),"\n",(0,l.jsx)(n.p,{children:"Idea is to output the tab completion to the file and then source it."}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"mkdir -p ~/.local/share/tom\ntom integrate bash --stdout > ~/.local/share/tom/tom.bash\n\n# Then source this file in the ~/.bashrc\nsource $HOME/.local/share/tom/tom.bash\n"})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"mkdir -p ~/.local/share/tom\ntom integrate zsh --stdout > ~/.local/share/tom/tom.zsh\n\n# Then source this file in the ~/.zshrc\nsource $HOME/.local/share/tom/tom.zsh\ncompdef _tom tom\n"})})})]}),"\n",(0,l.jsx)(n.h4,{id:"dynamic-installation",children:"Dynamic installation"}),"\n",(0,l.jsxs)(n.p,{children:["Idea is to ",(0,l.jsx)(n.strong,{children:"avoid"})," outputting the tab completion to the file, so you ",(0,l.jsx)(n.code,{children:"eval"})," the tab completion source code right away."]}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'# Add this eval to the ~/.bashrc\neval "$(tom integrate bash --stdout)"\n'})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'# Add this eval to the ~/.zshrc\neval "$(tom integrate zsh --stdout)"\ncompdef _tom tom\n'})})})]}),"\n",(0,l.jsx)(n.h2,{id:"migration-structure",children:"Migration Structure"}),"\n",(0,l.jsxs)(n.p,{children:["A migration class contains two methods: ",(0,l.jsx)(n.code,{children:"up"})," and ",(0,l.jsx)(n.code,{children:"down"}),". The ",(0,l.jsx)(n.code,{children:"up"})," method is used to add new tables, columns, or indexes to your database, while the ",(0,l.jsx)(n.code,{children:"down"})," method should reverse the operations performed by the ",(0,l.jsx)(n.code,{children:"up"})," method."]}),"\n",(0,l.jsxs)(n.p,{children:["Within both of these methods, you may use the TinyORM schema builder to expressively create and modify tables. To learn about all of the methods available on the ",(0,l.jsx)(n.code,{children:"Schema"})," builder, ",(0,l.jsx)(n.a,{href:"#creating-tables",children:"check out its documentation"}),". For example, the following migration creates a ",(0,l.jsx)(n.code,{children:"posts"})," table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nnamespace Migrations\n{\n\n struct CreatePostsTable : Migration\n {\n /*! Filename of the migration file. */\n T_MIGRATION\n\n /*! Run the migrations. */\n void up() const override\n {\n Schema::create("posts", [](Blueprint &table)\n {\n table.id();\n\n table.string(NAME);\n table.timestamps();\n });\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n Schema::dropIfExists("posts");\n }\n };\n\n} // namespace Migrations\n'})}),"\n",(0,l.jsxs)(n.p,{children:['Migration classes can be named in two formats, StudlyCase without the datetime prefix and "snake_case" with the datetime prefix. If the StudlyCase name is used then the ',(0,l.jsx)(n.code,{children:"T_MIGRATION"})," macro must also be used in the migration class."]}),"\n",(0,l.jsx)(n.p,{children:"Naming with the datetime prefix should look like this."}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"struct _2014_10_12_000000_create_posts_table : Migration\n{\n\n /*! Run the migrations. */\n void up() const override\n {\n //\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n //\n }\n};\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The StudlyCase naming is preferred. Also the ",(0,l.jsx)(n.code,{children:"make:migration"})," command generates migrations in this format."]})}),"\n",(0,l.jsx)(n.h4,{id:"setting-the-migration-connection",children:"Setting The Migration Connection"}),"\n",(0,l.jsxs)(n.p,{children:["If your migration will be interacting with a database connection other than your application's default database connection, you should set the ",(0,l.jsx)(n.code,{children:"connection"})," data member of your migration:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'/*! The name of the database connection to use. */\nQString connection = QStringLiteral("tinyorm_example");\n\n/*! Run the migrations. */\nvoid up() const override\n{\n //\n}\n'})}),"\n",(0,l.jsx)(n.h2,{id:"running-migrations",children:"Running Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["To run all of your outstanding migrations, execute the ",(0,l.jsx)(n.code,{children:"migrate"})," Tom command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate\n"})}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to see which migrations have run thus far, you may use the ",(0,l.jsx)(n.code,{children:"migrate:status"})," tom command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:status\n"})}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to see the SQL statements that will be executed by the migrations without actually running them, you may provide the ",(0,l.jsx)(n.code,{children:"--pretend"})," flag to the ",(0,l.jsx)(n.code,{children:"migrate"})," command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate --pretend\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["Many ",(0,l.jsx)(n.code,{children:"tom"})," commands offer variety of options, you can explore them using the ",(0,l.jsx)(n.code,{children:"tom list"})," and ",(0,l.jsx)(n.code,{children:"tom help"})," commands. In most cases, these commands and options are self-explanatory."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom"})," command is able to guess the command name and command namespace, eg. ",(0,l.jsx)(n.code,{children:"tom mig:st"})," or ",(0,l.jsx)(n.code,{children:"tom m:rol"}),", ..."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can pass the ",(0,l.jsx)(n.code,{children:"-vvv"})," command-line argument to any command to see all executed SQL queries. \ud83d\udc4c"]})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate"})," Tom command internally calls the ",(0,l.jsx)(n.code,{children:"migrate:install"})," command which installs the migration repository table. To uninstall this repository table you can call the ",(0,l.jsx)(n.code,{children:"migrate:uninstall"}),"."]})}),"\n",(0,l.jsx)(n.h4,{id:"forcing-migrations-to-run-in-production",children:"Forcing Migrations To Run In Production"}),"\n",(0,l.jsxs)(n.p,{children:["Some migration operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the ",(0,l.jsx)(n.code,{children:"--force"})," flag:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate --force\n"})}),"\n",(0,l.jsx)(n.h3,{id:"rolling-back-migrations",children:"Rolling Back Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["To roll back the latest migration operation, you may use the ",(0,l.jsx)(n.code,{children:"rollback"}),' Tom command. This command rolls back the last "batch" of migrations, which may include multiple migration files:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback\n"})}),"\n",(0,l.jsxs)(n.p,{children:["You may roll back a limited number of migrations by providing the ",(0,l.jsx)(n.code,{children:"step"})," option to the ",(0,l.jsx)(n.code,{children:"rollback"})," command. For example, the following command will roll back the last five migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback --step=5\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:reset"})," command will roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:reset\n"})}),"\n",(0,l.jsxs)(n.p,{children:['You may roll back a specific "batch" of migrations by providing the ',(0,l.jsx)(n.code,{children:"batch"})," option to the ",(0,l.jsx)(n.code,{children:"rollback"})," command, where the ",(0,l.jsx)(n.code,{children:"batch"})," option corresponds to a batch value within your application's ",(0,l.jsx)(n.code,{children:"migrations"})," database table. For example, the following command will roll back all migrations in batch three:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback --batch=3\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:reset"})," command will roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:reset\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:uninstall"})," command will uninstall the migration repository table, it optionally accepts the ",(0,l.jsx)(n.code,{children:"--reset"})," option to roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:uninstall --reset\n"})}),"\n",(0,l.jsx)(n.h4,{id:"roll-back--migrate-using-a-single-command",children:"Roll Back & Migrate Using A Single Command"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:refresh"})," command will roll back all of your migrations and then execute the ",(0,l.jsx)(n.code,{children:"migrate"})," command. This command effectively re-creates your entire database:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:refresh\n"})}),"\n",(0,l.jsxs)(n.p,{children:["You may roll back and re-migrate a limited number of migrations by providing the ",(0,l.jsx)(n.code,{children:"step"})," option to the ",(0,l.jsx)(n.code,{children:"refresh"})," command. For example, the following command will roll back and re-migrate the last five migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:refresh --step=5\n"})}),"\n",(0,l.jsx)(n.h4,{id:"drop-all-tables--migrate",children:"Drop All Tables & Migrate"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:fresh"})," command will drop all tables from the database and then execute the ",(0,l.jsx)(n.code,{children:"migrate"})," command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:fresh\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:fresh"})," command will drop all database tables regardless of their prefix. This command should be used with caution when developing on a database that is shared with other applications."]})}),"\n",(0,l.jsx)(n.h2,{id:"tables",children:"Tables"}),"\n",(0,l.jsx)(n.h3,{id:"creating-tables",children:"Creating Tables"}),"\n",(0,l.jsxs)(n.p,{children:["To create a new database table, use the ",(0,l.jsx)(n.code,{children:"create"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade. The ",(0,l.jsx)(n.code,{children:"create"})," method accepts two arguments: the first is the name of the table, while the second is a lambda expression which receives a ",(0,l.jsx)(n.code,{children:"Orm::SchemaNs::Blueprint"})," object that may be used to define the new table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Schema;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.id();\n table.string("name");\n table.string("email");\n table.timestamps();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["When creating the table, you may use any of the schema builder's ",(0,l.jsx)(n.a,{href:"#creating-columns",children:"column methods"})," to define the table's columns."]}),"\n",(0,l.jsx)(n.h4,{id:"checking-for-table--column-existence",children:"Checking For Table / Column Existence"}),"\n",(0,l.jsxs)(n.p,{children:["You may check for the existence of a table or column using the ",(0,l.jsx)(n.code,{children:"hasTable"})," and ",(0,l.jsx)(n.code,{children:"hasColumn"})," methods:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'if (Schema::hasTable("users")) {\n // The "users" table exists...\n}\n\nif (Schema::hasColumn("users", "email")) {\n // The "users" table exists and has an "email" column...\n}\n'})}),"\n",(0,l.jsx)(n.h4,{id:"database-connection--table-options",children:"Database Connection & Table Options"}),"\n",(0,l.jsxs)(n.p,{children:["If you want to perform a schema operation on a database connection that is not your application's default connection, use the ",(0,l.jsx)(n.code,{children:"connection"})," method or ",(0,l.jsx)(n.code,{children:"on"})," alias:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::connection("postgres").create("users", [](Blueprint &table)\n{\n table.id();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["In addition, a few other data members and methods may be used to define other aspects of the table's creation. The ",(0,l.jsx)(n.code,{children:"engine"})," data member may be used to specify the table's storage engine when using MySQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::InnoDB;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.engine = InnoDB;\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"charset"})," and ",(0,l.jsx)(n.code,{children:"collation"})," data members may be used to specify the character set and collation for the created table when using MySQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::UTF8MB4;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.charset = UTF8MB4;\n table.collation = "utf8mb4_unicode_ci";\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"temporary"}),' method may be used to indicate that the table should be "temporary". Temporary tables are only visible to the current connection\'s database session and are dropped automatically when the connection is closed:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::create("calculations", [](Blueprint &table)\n{\n table.temporary();\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:['If you would like to add a "comment" to a database table, you may invoke the ',(0,l.jsx)(n.code,{children:"comment"})," method on the table instance. Table comments are currently only supported by MySQL and PostgreSQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::create("calculations", [](Blueprint &table)\n{\n table.comment("Business calculations");\n\n // ...\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"updating-tables",children:"Updating Tables"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"table"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade may be used to update existing tables. Like the ",(0,l.jsx)(n.code,{children:"create"})," method, the ",(0,l.jsx)(n.code,{children:"table"})," method accepts two arguments: the name of the table and a lambda expression that receives a ",(0,l.jsx)(n.code,{children:"Blueprint"})," instance you may use to add columns or indexes to the table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.integer("votes");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"renaming-and-dropping-tables",children:"Renaming / Dropping Tables"}),"\n",(0,l.jsxs)(n.p,{children:["To rename an existing database table, use the ",(0,l.jsx)(n.code,{children:"rename"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::rename("from", "to");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["To drop an existing table, you may use the ",(0,l.jsx)(n.code,{children:"drop"})," or ",(0,l.jsx)(n.code,{children:"dropIfExists"})," methods:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::drop("users");\n\nSchema::dropIfExists("users");\n'})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-tables-with-foreign-keys",children:"Renaming Tables With Foreign Keys"}),"\n",(0,l.jsxs)(n.p,{children:["Before renaming a table, you should verify that any foreign key constraints on the table have an explicit name in your migration files instead of letting TinyORM assign a convention based name. Otherwise, the foreign key constraint ",(0,l.jsx)(n.strong,{children:"index name"})," will refer to the old table name."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["After renaming a table, you can re-create (drop and create again) the foreign key constraints to fix an ",(0,l.jsx)(n.strong,{children:"index name"}),", so it refers to a renamed table."]})}),"\n",(0,l.jsx)(n.h2,{id:"columns",children:"Columns"}),"\n",(0,l.jsx)(n.h3,{id:"creating-columns",children:"Creating Columns"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"table"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade may be used to update existing tables. Like the ",(0,l.jsx)(n.code,{children:"create"})," method, the ",(0,l.jsx)(n.code,{children:"table"})," method accepts two arguments: the name of the table and a lambda expression that receives a ",(0,l.jsx)(n.code,{children:"Blueprint"})," instance you may use to add columns to the table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.integer("votes");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"available-column-types",children:"Available Column Types"}),"\n",(0,l.jsx)(n.p,{children:"The schema builder blueprint offers a variety of methods that correspond to the different types of columns you can add to your database tables. Each of the available methods are listed in the table below:"}),"\n",(0,l.jsx)("div",{className:"tom-column-types-list",children:(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"#column-method-bigIncrements",children:"bigIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-bigInteger",children:"bigInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-binary",children:"binary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-boolean",children:"boolean"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Char",children:"Char"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-date",children:"date"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetime",children:"datetime"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetimes",children:"datetimes"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetimeTz",children:"datetimeTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-decimal",children:"decimal"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Double",children:"Double"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Enum",children:"Enum"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Float",children:"Float"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignId",children:"foreignId"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignIdFor",children:"foreignIdFor"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignUuid",children:"foreignUuid"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-geometry",children:"geometry"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-geometryCollection",children:"geometryCollection"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-id",children:"id"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-increments",children:"increments"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-integer",children:"integer"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-ipAddress",children:"ipAddress"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-json",children:"json"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-jsonb",children:"jsonb"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-lineString",children:"lineString"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-longBinary",children:"longBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-longText",children:"longText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-macAddress",children:"macAddress"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumBinary",children:"mediumBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumIncrements",children:"mediumIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumInteger",children:"mediumInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumText",children:"mediumText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiLineString",children:"multiLineString"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiPoint",children:"multiPoint"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiPolygon",children:"multiPolygon"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-point",children:"point"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-polygon",children:"polygon"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-rememberToken",children:"rememberToken"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-set",children:"set"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-smallIncrements",children:"smallIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-smallInteger",children:"smallInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletes",children:"softDeletes"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletesDatetime",children:"softDeletesDatetime"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletesTz",children:"softDeletesTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-string",children:"string"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-text",children:"text"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-time",children:"time"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timeTz",children:"timeTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestamp",children:"timestamp"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestampTz",children:"timestampTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestampsTz",children:"timestampsTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestamps",children:"timestamps"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyBinary",children:"tinyBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyIncrements",children:"tinyIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyInteger",children:"tinyInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyText",children:"tinyText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedBigInteger",children:"unsignedBigInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedDecimal",children:"unsignedDecimal"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedInteger",children:"unsignedInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedMediumInteger",children:"unsignedMediumInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedSmallInteger",children:"unsignedSmallInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedTinyInteger",children:"unsignedTinyInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-uuid",children:"uuid"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-year",children:"year"})]})}),"\n",(0,l.jsx)(n.admonition,{type:"info",children:(0,l.jsxs)(n.p,{children:["Names of ",(0,l.jsx)(n.code,{children:"Char"}),", ",(0,l.jsx)(n.code,{children:"Double"}),", ",(0,l.jsx)(n.code,{children:"Enum"}),", and ",(0,l.jsx)(n.code,{children:"Float"})," column methods are in the CamelCase format to avoid collisions with C++ keywords."]})}),"\n",(0,l.jsxs)("div",{className:"tom-column-types",children:[(0,l.jsx)(n.h4,{id:"column-method-bigIncrements",children:(0,l.jsx)(n.code,{children:"bigIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"bigIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," (primary key) equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.bigIncrements(Orm::ID);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-bigInteger",children:(0,l.jsx)(n.code,{children:"bigInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"bigInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.bigInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-binary",children:(0,l.jsx)(n.code,{children:"binary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"binary"})," method creates a ",(0,l.jsx)(n.code,{children:"BLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.binary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-boolean",children:(0,l.jsx)(n.code,{children:"boolean()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"boolean"})," method creates a ",(0,l.jsx)(n.code,{children:"BOOLEAN"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.boolean("confirmed");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Char",children:(0,l.jsx)(n.code,{children:"Char()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Char"})," method creates a ",(0,l.jsx)(n.code,{children:"CHAR"})," equivalent column with of a given length:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.Char(Orm::NAME, 100);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-date",children:(0,l.jsx)(n.code,{children:"date()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"date"})," method creates a ",(0,l.jsx)(n.code,{children:"DATE"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.date("created_at");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-datetime",children:(0,l.jsx)(n.code,{children:"datetime()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetime"})," method creates a ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.datetime("created_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-datetimes",children:(0,l.jsx)(n.code,{children:"datetimes()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetimes"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.datetimes(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-datetimeTz",children:(0,l.jsx)(n.code,{children:"datetimeTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetimeTz"})," method creates a ",(0,l.jsx)(n.code,{children:"DATETIME"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.datetimeTz(Orm::CREATED_AT, precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-decimal",children:(0,l.jsx)(n.code,{children:"decimal()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"decimal"})," method creates a ",(0,l.jsx)(n.code,{children:"DECIMAL"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.decimal("amount", precision = 8, scale = 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Double",children:(0,l.jsx)(n.code,{children:"Double()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Double"})," method creates a ",(0,l.jsx)(n.code,{children:"DOUBLE"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Double("amount", 8, 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Enum",children:(0,l.jsx)(n.code,{children:"Enum()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Enum"})," method creates a ",(0,l.jsx)(n.code,{children:"ENUM"})," equivalent column with the given valid values:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Enum("difficulty", {"easy", "hard"});\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Float",children:(0,l.jsx)(n.code,{children:"Float()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Float"})," method creates a ",(0,l.jsx)(n.code,{children:"FLOAT"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Float("amount", 8, 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignId",children:(0,l.jsx)(n.code,{children:"foreignId()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignId"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignId("user_id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignIdFor",children:(0,l.jsx)(n.code,{children:"foreignIdFor()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignIdFor"})," method adds a ",(0,l.jsx)(n.code,{children:"{column}_id UNSIGNED BIGINT"})," equivalent column for a given model class:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nModels::User user;\n\ntable.foreignIdFor(User);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignUuid",children:(0,l.jsx)(n.code,{children:"foreignUuid()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignUuid"})," method creates a ",(0,l.jsx)(n.code,{children:"UUID"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignUuid("user_id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-geometry",children:(0,l.jsx)(n.code,{children:"geometry()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"geometry"})," method creates a ",(0,l.jsx)(n.code,{children:"GEOMETRY"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.geometry("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-geometryCollection",children:(0,l.jsx)(n.code,{children:"geometryCollection()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"geometryCollection"})," method creates a ",(0,l.jsx)(n.code,{children:"GEOMETRYCOLLECTION"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.geometryCollection("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-id",children:(0,l.jsx)(n.code,{children:"id()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"id"})," method is an alias of the ",(0,l.jsx)(n.code,{children:"bigIncrements"})," method. By default, the method will create an ",(0,l.jsx)(n.code,{children:"id"})," column; however, you may pass a column name if you would like to assign a different name to the column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.id();\n"})}),(0,l.jsx)(n.h4,{id:"column-method-increments",children:(0,l.jsx)(n.code,{children:"increments()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"increments"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED INTEGER"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.increments("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-integer",children:(0,l.jsx)(n.code,{children:"integer()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"integer"})," method creates an ",(0,l.jsx)(n.code,{children:"INTEGER"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.integer("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-ipAddress",children:(0,l.jsx)(n.code,{children:"ipAddress()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"ipAddress"})," method creates a ",(0,l.jsx)(n.code,{children:"VARCHAR(45)"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.ipAddress("visitor");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-json",children:(0,l.jsx)(n.code,{children:"json()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"json"})," method creates a ",(0,l.jsx)(n.code,{children:"JSON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.json("options");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-jsonb",children:(0,l.jsx)(n.code,{children:"jsonb()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"jsonb"})," method creates a ",(0,l.jsx)(n.code,{children:"JSONB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.jsonb("options");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-lineString",children:(0,l.jsx)(n.code,{children:"lineString()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"lineString"})," method creates a ",(0,l.jsx)(n.code,{children:"LINESTRING"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.lineString("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-longBinary",children:(0,l.jsx)(n.code,{children:"longBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"longBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"LONGBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.longBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-longText",children:(0,l.jsx)(n.code,{children:"longText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"longText"})," method creates a ",(0,l.jsx)(n.code,{children:"LONGTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.longText("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-macAddress",children:(0,l.jsx)(n.code,{children:"macAddress()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"macAddress"})," method creates a column that is intended to hold a MAC address. Some database systems, such as PostgreSQL, have a dedicated column type for this type of data. Other database systems will use a string equivalent ",(0,l.jsx)(n.code,{children:"VARCHAR(17)"})," column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.macAddress("device");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumBinary",children:(0,l.jsx)(n.code,{children:"mediumBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumIncrements",children:(0,l.jsx)(n.code,{children:"mediumIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED MEDIUMINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumInteger",children:(0,l.jsx)(n.code,{children:"mediumInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumText",children:(0,l.jsx)(n.code,{children:"mediumText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumText"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumText("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiLineString",children:(0,l.jsx)(n.code,{children:"multiLineString()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiLineString"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTILINESTRING"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiLineString("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiPoint",children:(0,l.jsx)(n.code,{children:"multiPoint()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiPoint"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTIPOINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiPoint("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiPolygon",children:(0,l.jsx)(n.code,{children:"multiPolygon()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiPolygon"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTIPOLYGON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiPolygon("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-point",children:(0,l.jsx)(n.code,{children:"point()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"point"})," method creates a ",(0,l.jsx)(n.code,{children:"POINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.point("position");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-polygon",children:(0,l.jsx)(n.code,{children:"polygon()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"polygon"})," method creates a ",(0,l.jsx)(n.code,{children:"POLYGON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.polygon("position");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-rememberToken",children:(0,l.jsx)(n.code,{children:"rememberToken()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"rememberToken"})," method creates a nullable, ",(0,l.jsx)(n.code,{children:"VARCHAR(100)"}),' equivalent column that is intended to store the current "remember me" authentication token:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.rememberToken();\n"})}),(0,l.jsx)(n.h4,{id:"column-method-set",children:(0,l.jsx)(n.code,{children:"set()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"set"})," method creates a ",(0,l.jsx)(n.code,{children:"SET"})," equivalent column with the given list of valid values:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.set("flavors", {"strawberry", "vanilla"});\n'})}),(0,l.jsx)(n.h4,{id:"column-method-smallIncrements",children:(0,l.jsx)(n.code,{children:"smallIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"smallIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED SMALLINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.smallIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-smallInteger",children:(0,l.jsx)(n.code,{children:"smallInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"smallInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"SMALLINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.smallInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletes",children:(0,l.jsx)(n.code,{children:"softDeletes()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletes"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletes("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletesDatetime",children:(0,l.jsx)(n.code,{children:"softDeletesDatetime()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletesDatetime"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletesDatetime("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletesTz",children:(0,l.jsx)(n.code,{children:"softDeletesTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletesTz"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletesTz("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-string",children:(0,l.jsx)(n.code,{children:"string()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"string"})," method creates a ",(0,l.jsx)(n.code,{children:"VARCHAR"})," equivalent column of the given length:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.string(Orm::NAME, 100);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-text",children:(0,l.jsx)(n.code,{children:"text()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"text"})," method creates a ",(0,l.jsx)(n.code,{children:"TEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.text("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-time",children:(0,l.jsx)(n.code,{children:"time()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"time"})," method creates a ",(0,l.jsx)(n.code,{children:"TIME"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.time("sunrise", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timeTz",children:(0,l.jsx)(n.code,{children:"timeTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timeTz"})," method creates a ",(0,l.jsx)(n.code,{children:"TIME"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timeTz("sunrise", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestamp",children:(0,l.jsx)(n.code,{children:"timestamp()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestamp"})," method creates a ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timestamp("added_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestampTz",children:(0,l.jsx)(n.code,{children:"timestampTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestampTz"})," method creates a ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timestampTz("added_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestampsTz",children:(0,l.jsx)(n.code,{children:"timestampsTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestampsTz"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.timestampsTz(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-timestamps",children:(0,l.jsx)(n.code,{children:"timestamps()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestamps"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.timestamps(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-tinyBinary",children:(0,l.jsx)(n.code,{children:"tinyBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyIncrements",children:(0,l.jsx)(n.code,{children:"tinyIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED TINYINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyInteger",children:(0,l.jsx)(n.code,{children:"tinyInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyText",children:(0,l.jsx)(n.code,{children:"tinyText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyText"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyText("notes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedBigInteger",children:(0,l.jsx)(n.code,{children:"unsignedBigInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedBigInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedBigInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedDecimal",children:(0,l.jsx)(n.code,{children:"unsignedDecimal()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedDecimal"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED DECIMAL"})," equivalent column with an optional precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedDecimal("amount", precision = 8, scale = 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedInteger",children:(0,l.jsx)(n.code,{children:"unsignedInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED INTEGER"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedMediumInteger",children:(0,l.jsx)(n.code,{children:"unsignedMediumInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedMediumInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED MEDIUMINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedMediumInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedSmallInteger",children:(0,l.jsx)(n.code,{children:"unsignedSmallInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedSmallInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED SMALLINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedSmallInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedTinyInteger",children:(0,l.jsx)(n.code,{children:"unsignedTinyInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedTinyInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED TINYINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedTinyInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-uuid",children:(0,l.jsx)(n.code,{children:"uuid()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"uuid"})," method creates a ",(0,l.jsx)(n.code,{children:"UUID"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.uuid("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-year",children:(0,l.jsx)(n.code,{children:"year()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"year"})," method creates a ",(0,l.jsx)(n.code,{children:"YEAR"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.year("birth_year");\n'})})]}),"\n",(0,l.jsx)(n.h3,{id:"column-modifiers",children:"Column Modifiers"}),"\n",(0,l.jsxs)(n.p,{children:['In addition to the column types listed above, there are several column "modifiers" you may use when adding a column to a database table. For example, to make the column "nullable", you may use the ',(0,l.jsx)(n.code,{children:"nullable"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("email").nullable();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The following table contains all of the available column modifiers. This list does not include ",(0,l.jsx)(n.a,{href:"#creating-indexes",children:"index modifiers"}),":"]}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Modifier"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.after("column")'})}),(0,l.jsxs)(n.td,{children:['Place the column "after" another column ',(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".autoIncrement()"})}),(0,l.jsx)(n.td,{children:"Set INTEGER columns as auto-incrementing (primary key)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.charset("utf8mb4")'})}),(0,l.jsxs)(n.td,{children:["Specify a character set for the column ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'.collation("utf8mb4_unicode_ci")'})})}),(0,l.jsxs)(n.td,{children:["Specify a collation for the column ",(0,l.jsx)("small",{children:"(MySQL/PostgreSQL/SQL Server)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.comment("my comment")'})}),(0,l.jsxs)(n.td,{children:["Add a comment to a column ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),".",(0,l.jsx)("br",{}),(0,l.jsx)("small",{children:"Special characters are escaped."})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".defaultValue(value)"})}),(0,l.jsxs)(n.td,{children:['Specify a "default" value for the column.',(0,l.jsx)("br",{}),(0,l.jsx)("small",{children:"Special characters are escaped."})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".first()"})}),(0,l.jsxs)(n.td,{children:['Place the column "first" in the table ',(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".from(integer)"})}),(0,l.jsxs)(n.td,{children:["Set the starting value of an auto-incrementing field, an alias for ",(0,l.jsx)(n.code,{children:"startingValue()"})," ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".invisible()"})}),(0,l.jsxs)(n.td,{children:['Make the column "invisible" to ',(0,l.jsx)(n.code,{children:"SELECT *"})," queries ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".nullable(value = true)"})}),(0,l.jsx)(n.td,{children:"Allow NULL values to be inserted into the column."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".startingValue(integer)"})}),(0,l.jsxs)(n.td,{children:["Set the starting value of an auto-incrementing field ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".storedAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create a stored generated column ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".unsigned()"})}),(0,l.jsxs)(n.td,{children:["Set INTEGER columns as UNSIGNED ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".useCurrent()"})}),(0,l.jsx)(n.td,{children:"Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".useCurrentOnUpdate()"})}),(0,l.jsx)(n.td,{children:"Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".virtualAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create a virtual generated column ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".generatedAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create an identity column with specified sequence options ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".always()"})}),(0,l.jsxs)(n.td,{children:["Defines the precedence of sequence values over input for an identity column ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".isGeometry()"})}),(0,l.jsxs)(n.td,{children:["Set spatial column type to ",(0,l.jsx)(n.code,{children:"geometry"})," - the default type is ",(0,l.jsx)(n.code,{children:"geography"})," ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]})]})]}),"\n",(0,l.jsx)(n.h4,{id:"default-expressions",children:"Default Expressions"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"defaultValue"})," modifier accepts a value or an ",(0,l.jsx)(n.code,{children:"Orm::Query::Expression"})," instance. Using an ",(0,l.jsx)(n.code,{children:"Expression"})," instance will prevent TinyORM from wrapping the value in quotes and allow you to use database-specific functions. One situation where this is particularly useful is when you need to assign default values to JSON columns:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Query::Expression;\n\nSchema::create("flights", [](Blueprint &table)\n{\n table.id();\n table.json("detail").defaultValue(Expression("(JSON_ARRAY(\'none\'))"));\n table.timestamps();\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsx)(n.p,{children:"Support for default expressions depends on your database driver, database version, and the field type. Please refer to your database's documentation."})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can obtain an ",(0,l.jsx)(n.code,{children:"Orm::Query::Expression"})," using the ",(0,l.jsx)(n.a,{href:"/database/query-builder#raw-expressions",children:(0,l.jsx)(n.code,{children:"DB::raw"})})," method if you have access to the ",(0,l.jsx)(n.code,{children:"DB"})," facade."]})}),"\n",(0,l.jsx)(n.h4,{id:"column-order",children:"Column Order"}),"\n",(0,l.jsxs)(n.p,{children:["When using the MySQL database, the ",(0,l.jsx)(n.code,{children:"after"})," method may be used to add columns after an existing column in the schema:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.after("password", [](Blueprint &table)\n{\n table.string("address_line1");\n table.string("address_line2");\n table.string("city");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"modifying-columns",children:"Modifying Columns"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"change"})," method allows you to modify the type and attributes of existing columns. For example, you may wish to increase the size of a ",(0,l.jsx)(n.code,{children:"string"})," column. To see the ",(0,l.jsx)(n.code,{children:"change"})," method in action, let's increase the size of the ",(0,l.jsx)(n.code,{children:"name"})," column from 25 to 50. To accomplish this, we simply define the new state of the column and then call the ",(0,l.jsx)(n.code,{children:"change"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("name", 50).change();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["When modifying a column, you must explicitly include all of the modifiers you want to keep on the column definition - any missing attribute will be dropped. For example, to retain the ",(0,l.jsx)(n.code,{children:"unsigned"}),", ",(0,l.jsx)(n.code,{children:"default"}),", and ",(0,l.jsx)(n.code,{children:"comment"})," attributes, you must call each modifier explicitly when changing the column:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.integer("votes").isUnsigned().defaultValue(1).comment("my comment").change();\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"info",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"change"})," method and modifying columns is not implemented for the ",(0,l.jsx)(n.code,{children:"SQLite"})," database because it doesn't support modifying columns out of the box."]})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-columns",children:"Renaming Columns"}),"\n",(0,l.jsxs)(n.p,{children:["To rename a column, you may use the ",(0,l.jsx)(n.code,{children:"renameColumn"})," method provided by the schema builder blueprint:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.renameColumn("from", "to");\n});\n'})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-columns-on-legacy-databases",children:"Renaming Columns On Legacy Databases"}),"\n",(0,l.jsx)(n.p,{children:"Renaming columns is not supported if you are running a database installation older than one of the following releases:"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["MySQL ",(0,l.jsx)(n.code,{children:"<8.0.3"})]}),"\n",(0,l.jsxs)(n.li,{children:["MariaDB ",(0,l.jsx)(n.code,{children:"<10.5.2"})]}),"\n",(0,l.jsxs)(n.li,{children:["SQLite ",(0,l.jsx)(n.code,{children:"<3.25.0"})]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"dropping-columns",children:"Dropping Columns"}),"\n",(0,l.jsxs)(n.p,{children:["To drop a column, you may use the ",(0,l.jsx)(n.code,{children:"dropColumn"})," method on the schema builder blueprint:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.dropColumn("votes");\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["You may drop multiple columns from a table by passing a ",(0,l.jsx)(n.code,{children:"QList"})," of column names to the ",(0,l.jsx)(n.code,{children:"dropColumns"})," method, the ",(0,l.jsx)(n.code,{children:"dropColumns"})," method also provides parameter pack overload:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.dropColumns({"votes", "avatar", "location"});\n // Parameter pack overload\n table.dropColumns("votes", "avatar", "location");\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The SQLite prior to ",(0,l.jsx)(n.code,{children:"v3.35.0"})," doesn't support dropping columns using the ",(0,l.jsx)(n.code,{children:"ALTER TABLE DROP COLUMN"}),", dropping columns was added in the SQLite ",(0,l.jsx)(n.code,{children:"v3.35.0"})," as is described in the ",(0,l.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_35_0.html",children:"release notes"}),"."]})}),"\n",(0,l.jsx)(n.h4,{id:"available-command-aliases",children:"Available Command Aliases"}),"\n",(0,l.jsx)(n.p,{children:"TinyORM provides several convenient methods related to dropping common types of columns. Each of these methods is described in the table below:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropRememberToken();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"remember_token"})," column."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletes();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"deleted_at"})," column."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletesDatetime();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropSoftDeletes()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletesTz();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropSoftDeletes()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropTimestamps();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," columns."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropTimestampsTz();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropTimestamps()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropDatetimes();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropTimestamps()"})," method."]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"indexes",children:"Indexes"}),"\n",(0,l.jsx)(n.h3,{id:"creating-indexes",children:"Creating Indexes"}),"\n",(0,l.jsxs)(n.p,{children:["The TinyORM schema builder supports several types of indexes. The following example creates a new ",(0,l.jsx)(n.code,{children:"email"})," column and specifies that its values should be unique. To create the index, we can chain the ",(0,l.jsx)(n.code,{children:"unique"})," method onto the column definition:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("email").unique();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Alternatively, you may create the index after defining the column. To do so, you should call the ",(0,l.jsx)(n.code,{children:"unique"})," method on the schema builder blueprint. This method accepts the name of the column that should receive a unique index:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unique("email");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["You may even pass a ",(0,l.jsx)(n.code,{children:"QList"})," of columns to an index method to create a compound (or composite) index:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.index({"account_id", "created_at"});\n'})}),"\n",(0,l.jsx)(n.p,{children:"When creating an index, TinyORM will automatically generate an index name based on the table, column names, and the index type (eg. users_email_unique), but you may pass a second argument to the method to specify the index name yourself:"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unique("email", "unique_email");\n'})}),"\n",(0,l.jsx)(n.h4,{id:"available-index-types",children:"Available Index Types"}),"\n",(0,l.jsx)(n.p,{children:"TinyORM's schema builder blueprint class provides methods for creating each type of index supported by TinyORM. Each index method accepts an optional second argument to specify the name of the index. If omitted, the name will be derived from the names of the table and column(s) used for the index, as well as the index type (eg. users_email_fulltext). Each of the available index methods is described in the table below:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.primary("id");'})}),(0,l.jsx)(n.td,{children:"Adds a primary key."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.primary({"id", "parent_id"});'})}),(0,l.jsx)(n.td,{children:"Adds composite keys."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.unique("email");'})}),(0,l.jsx)(n.td,{children:"Adds a unique index."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.index("state");'})}),(0,l.jsx)(n.td,{children:"Adds an index."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.fullText("body");'})}),(0,l.jsx)(n.td,{children:"Adds a full text index (MySQL/PostgreSQL)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'table.fullText("body").language("english");'})})}),(0,l.jsx)(n.td,{children:"Adds a full text index of the specified language (PostgreSQL)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.spatialIndex("location");'})}),(0,l.jsx)(n.td,{children:"Adds a spatial index (except SQLite)."})]})]})]}),"\n",(0,l.jsx)(n.h4,{id:"index-lengths--mysql--mariadb",children:"Index Lengths & MySQL / MariaDB"}),"\n",(0,l.jsxs)(n.p,{children:["By default, TinyORM uses the ",(0,l.jsx)(n.code,{children:"utf8mb4"})," character set. If you are running a version of MySQL older than the 5.7.7 release or MariaDB older than the 10.2.2 release, you may need to manually configure the default string length generated by migrations in order for MySQL to create indexes for them. You may configure the default string length by calling the ",(0,l.jsx)(n.code,{children:"Schema::defaultStringLength"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\nSchema::defaultStringLength(191);\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["Alternatively, you may enable the ",(0,l.jsx)(n.code,{children:"innodb_large_prefix"})," option for your database (enabled by default in >=MySQL 5.7.7). Refer to your database's documentation for instructions on how to properly enable this option."]})}),"\n",(0,l.jsx)(n.h3,{id:"renaming-indexes",children:"Renaming Indexes"}),"\n",(0,l.jsxs)(n.p,{children:["To rename an index, you may use the ",(0,l.jsx)(n.code,{children:"renameIndex"})," method provided by the schema builder blueprint. This method accepts the current index name as its first argument and the desired name as its second argument:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.renameIndex("from", "to");\n'})}),"\n",(0,l.jsx)(n.h3,{id:"dropping-indexes",children:"Dropping Indexes"}),"\n",(0,l.jsx)(n.p,{children:"To drop an index, you must specify the index's name. By default, TinyORM automatically assigns an index name based on the table name, the name of the indexed column, and the index type (eg. users_email_unique). Here are some examples:"}),"\n",(0,l.jsx)("div",{id:"apitable-dropping-indexes",children:(0,l.jsx)(d.A,{children:(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropPrimary("users_id_primary");'})}),(0,l.jsx)(n.td,{children:'Drop a primary key from the "users" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropUnique("users_email_unique");'})}),(0,l.jsx)(n.td,{children:'Drop a unique index from the "users" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropIndex("geo_state_index");'})}),(0,l.jsx)(n.td,{children:'Drop a basic index from the "geo" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'table.dropFullText("posts_body_fulltext");'})})}),(0,l.jsx)(n.td,{children:'Drop a full text index from the "posts" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'.dropSpatialIndex("geo_location_spatialindex");'})})}),(0,l.jsx)(n.td,{children:'Drop a spatial index from the "geo" table (except SQLite).'})]})]})]})})}),"\n",(0,l.jsxs)(n.p,{children:["I may also drop indexes by a column name or column names for composite keys, if you pass a ",(0,l.jsx)(n.code,{children:"QList"})," of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns, and index type:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("geo", [](Blueprint &table)\n{\n table.dropIndex({"state"}); // Drops index \'geo_state_index\'\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"foreign-key-constraints",children:"Foreign Key Constraints"}),"\n",(0,l.jsxs)(n.p,{children:["TinyORM also provides support for creating foreign key constraints, which are used to force referential integrity at the database level. For example, let's define a ",(0,l.jsx)(n.code,{children:"user_id"})," column on the ",(0,l.jsx)(n.code,{children:"posts"})," table that references the ",(0,l.jsx)(n.code,{children:"id"})," column on a ",(0,l.jsx)(n.code,{children:"users"})," table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::ID;\n\nSchema::table("posts", [](Blueprint &table)\n{\n table.unsignedBigInteger("user_id");\n\n table.foreign("user_id").references(ID).on("users");\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Since this syntax is rather verbose, TinyORM provides additional, terser methods that use conventions to provide a better developer experience. When using the ",(0,l.jsx)(n.code,{children:"foreignId"})," method to create your column, the example above can be rewritten like so:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("posts", [](Blueprint &table)\n{\n table.foreignId("user_id").constrained();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignId"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column, while the ",(0,l.jsx)(n.code,{children:"constrained"})," method will use conventions to determine the table and column name being referenced. If your table name does not match TinyORM's conventions, you may specify the table name by passing it as an argument to the ",(0,l.jsx)(n.code,{children:"constrained"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("posts", [](Blueprint &table)\n{\n table.foreignId("user_id").constrained("users");\n});\n'})}),"\n",(0,l.jsx)(n.p,{children:'You may also specify the desired action for the "on delete" and "on update" properties of the constraint:'}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::SchemaNs::Constants::Cascade;\n\ntable.foreignId("user_id")\n .constrained()\n .onUpdate("cascade")\n .onDelete(Cascade);\n'})}),"\n",(0,l.jsx)(n.p,{children:"An alternative, expressive syntax is also provided for these actions:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Method"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.cascadeOnUpdate();"})}),(0,l.jsx)(n.td,{children:"Updates should cascade."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.restrictOnUpdate();"})}),(0,l.jsx)(n.td,{children:"Updates should be restricted."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.cascadeOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should cascade."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.restrictOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should be restricted."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.nullOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should set the foreign key value to null."})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["Any additional ",(0,l.jsx)(n.a,{href:"#column-modifiers",children:"column modifiers"})," must be called before the ",(0,l.jsx)(n.code,{children:"constrained"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignId("user_id")\n .nullable()\n .constrained();\n'})}),"\n",(0,l.jsx)(n.h4,{id:"dropping-foreign-keys",children:"Dropping Foreign Keys"}),"\n",(0,l.jsxs)(n.p,{children:["To drop a foreign key, you may use the ",(0,l.jsx)(n.code,{children:"dropForeign"}),' method, passing the name of the foreign key constraint to be deleted as an argument. Foreign key constraints use the same naming convention as indexes. In other words, the foreign key constraint name is based on the name of the table and the columns in the constraint, followed by a "_foreign" suffix:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.dropForeign("posts_user_id_foreign");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Alternatively, you may pass a ",(0,l.jsx)(n.code,{children:"QList"})," containing the column name that holds the foreign key to the ",(0,l.jsx)(n.code,{children:"dropForeign"})," method. The ",(0,l.jsx)(n.code,{children:"QList"})," will be converted to a foreign key constraint name using TinyORM's constraint naming conventions:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.dropForeign({"user_id"});\n'})}),"\n",(0,l.jsx)(n.h4,{id:"toggling-foreign-key-constraints",children:"Toggling Foreign Key Constraints"}),"\n",(0,l.jsx)(n.p,{children:"You may enable or disable foreign key constraints within your migrations by using the following methods:"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"Schema::enableForeignKeyConstraints();\n\nSchema::disableForeignKeyConstraints();\n\nSchema::withoutForeignKeyConstraints([]\n{\n // Constraints disabled within this lambda expression...\n});\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The SQLite disables foreign key constraints by default. When using SQLite, make sure to ",(0,l.jsx)(n.a,{href:"/database/getting-started#sqlite-configuration",children:"enable foreign key support"})," in your database configuration before attempting to create them in your migrations. In addition, SQLite only supports creating foreign keys when creating tables and ",(0,l.jsx)(n.a,{href:"https://www.sqlite.org/omitted.html",children:"not when tables are altered"}),"."]})})]})}function b(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(g,{...e})}):g(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>d});i(6540);var l=i(4164);const t={tabItem:"tabItem_Ymn6"};var s=i(4848);function d(e){let{children:n,hidden:i,className:d}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,l.A)(t.tabItem,d),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>T});var l=i(6540),t=i(4164),s=i(3104),d=i(6347),a=i(205),o=i(7485),r=i(1682),c=i(679);function h(e){return l.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,l.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function m(e){const{values:n,children:i}=e;return(0,l.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:l,default:t}}=e;return{value:n,label:i,attributes:l,default:t}}))}(i);return function(e){const n=(0,r.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function u(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function x(e){let{queryString:n=!1,groupId:i}=e;const t=(0,d.W6)(),s=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,o.aZ)(s),(0,l.useCallback)((e=>{if(!s)return;const n=new URLSearchParams(t.location.search);n.set(s,e),t.replace({...t.location,search:n.toString()})}),[s,t])]}function p(e){const{defaultValue:n,queryString:i=!1,groupId:t}=e,s=m(e),[d,o]=(0,l.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!u({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const l=i.find((e=>e.default))??i[0];if(!l)throw new Error("Unexpected error: 0 tabValues");return l.value}({defaultValue:n,tabValues:s}))),[r,h]=x({queryString:i,groupId:t}),[p,j]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[t,s]=(0,c.Dv)(i);return[t,(0,l.useCallback)((e=>{i&&s.set(e)}),[i,s])]}({groupId:t}),g=(()=>{const e=r??p;return u({value:e,tabValues:s})?e:null})();(0,a.A)((()=>{g&&o(g)}),[g]);return{selectedValue:d,selectValue:(0,l.useCallback)((e=>{if(!u({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);o(e),h(e),j(e)}),[h,j,s]),tabValues:s}}var j=i(2303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=i(4848);function f(e){let{className:n,block:i,selectedValue:l,selectValue:d,tabValues:a}=e;const o=[],{blockElementScrollPositionUntilNextRender:r}=(0,s.a_)(),c=e=>{const n=e.currentTarget,i=o.indexOf(n),t=a[i].value;t!==l&&(r(n),d(t))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const i=o.indexOf(e.currentTarget)+1;n=o[i]??o[0];break}case"ArrowLeft":{const i=o.indexOf(e.currentTarget)-1;n=o[i]??o[o.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":i},n),children:a.map((e=>{let{value:n,label:i,attributes:s}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:l===n?0:-1,"aria-selected":l===n,ref:e=>o.push(e),onKeyDown:h,onClick:c,...s,className:(0,t.A)("tabs__item",g.tabItem,s?.className,{"tabs__item--active":l===n}),children:i??n},n)}))})}function y(e){let{lazy:n,children:i,selectedValue:s}=e;const d=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=d.find((e=>e.props.value===s));return e?(0,l.cloneElement)(e,{className:(0,t.A)("margin-top--md",e.props.className)}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:d.map(((e,n)=>(0,l.cloneElement)(e,{key:n,hidden:e.props.value!==s})))})}function v(e){const n=p(e);return(0,b.jsxs)("div",{className:(0,t.A)("tabs-container",g.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(y,{...n,...e})]})}function T(e){const n=(0,j.A)();return(0,b.jsx)(v,{...e,children:h(e.children)},String(n))}},6684:(e,n,i)=>{i.d(n,{A:()=>c});var l=i(6540),t=i(3427),s=i(6347);const d={apiTable:"apiTable_flxF"};var a=i(4848);function o(e,n){let{name:i,children:d}=e;const o=function(e){let n=e;for(;(0,l.isValidElement)(n);)[n]=l.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(d),r=i?`${i}-${o}`:o,c=`#${r}`,h=(0,s.W6)();return(0,t.A)().collectAnchor(r),(0,a.jsx)("tr",{id:r,tabIndex:0,ref:h.location.hash===c?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||h.push(c)},onKeyDown:e=>{"Enter"===e.key&&h.push(c)},children:d.props.children})}const r=l.forwardRef(o);function c(e){let{children:n,name:i}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[t,s]=l.Children.toArray(n.props.children),o=(0,l.useRef)(null);(0,l.useEffect)((()=>{o.current?.focus()}),[o]);const c=l.Children.map(s.props.children,(e=>(0,a.jsx)(r,{name:i,ref:o,children:e})));return(0,a.jsxs)("table",{className:d.apiTable,children:[t,(0,a.jsx)("tbody",{children:c})]})}},7324:(e,n,i)=>{i.d(n,{$E:()=>j,A3:()=>b,CW:()=>g,Dx:()=>c,F4:()=>m,Fi:()=>r,J_:()=>T,LQ:()=>f,Lf:()=>I,OO:()=>t,Q7:()=>y,b:()=>a,cy:()=>o,gg:()=>x,kl:()=>u,os:()=>h,pW:()=>s,ux:()=>p,vf:()=>l,xj:()=>d,xt:()=>v});const l="shell",t="database",s="application",d="bash",a="pwsh",o="zsh",r="maria",c="mysql",h="postgres",m="sqlite",u="application",x="bash",p="pwsh",j="zsh",g="MariaDB",b="MySQL",f="PostgreSQL",y="SQLite",v="tinyorm.org",T="$HOME/Code/c/",I="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>s});var l=i(6540),t=i(1838);function s(){const e=(0,l.useContext)(t.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>o,Sn:()=>d,T3:()=>c,bw:()=>r,nC:()=>h,np:()=>a});var l=i(6362),t=i(2303),s=i(7324);const d=function(e,n){return void 0===n&&(n=!0),m((0,l.A)().rootFolder[e]??r(e),e,n)},a=()=>(0,l.A)().rootFolder[s.pW]??r(s.pW),o=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==s.b?"/":"\\";return m(d(e)+i+a(),e,n)};function r(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,t.A)())return"";switch(e){case s.b:return s.Lf;case s.xj:return s.J_;case s.pW:return s.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===s.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case s.b:return x(n).replace(/\$env:(.+?)(\/.*)/,i);case s.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function m(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==s.b)return u(e);const l=u(e);return i?x(l):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(l)}function u(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function x(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},5848:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/tom_cli-402f7dd4dfe7dbd0b20dfe5fb61838a2.png"}}]); \ No newline at end of file diff --git a/assets/js/21dc2778.d15c2f87.js b/assets/js/21dc2778.d15c2f87.js deleted file mode 100644 index 4629af597..000000000 --- a/assets/js/21dc2778.d15c2f87.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[295],{8478:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>u,default:()=>b,frontMatter:()=>m,metadata:()=>x,toc:()=>j});var l=i(4848),t=i(8453),s=i(8774),d=i(6684),a=i(2364),o=i(9365),r=i(1470),c=i(7324),h=i(6694);const m={sidebar_position:2,sidebar_label:"Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",keywords:["c++ orm","database","migrations","tinyorm"]},u="Database: Migrations",x={id:"database/migrations",title:"Database: Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",source:"@site/docs/database/migrations.mdx",sourceDirName:"database",slug:"/database/migrations",permalink:"/database/migrations",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Migrations",description:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. Migrations use the Schema facade that provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems.",keywords:["c++ orm","database","migrations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Query Builder",permalink:"/database/query-builder"},next:{title:"Seeding",permalink:"/database/seeding"}},p={},j=[{value:"Introduction",id:"introduction",level:2},{value:"Generating Migrations",id:"generating-migrations",level:2},{value:"Migrations naming rules",id:"migrations-naming-rules",level:4},{value:"Tab completion",id:"tab-completion",level:2},{value:"Alternative installation methods",id:"alternative-installation-methods",level:3},{value:"Static installation",id:"static-installation",level:4},{value:"Dynamic installation",id:"dynamic-installation",level:4},{value:"Migration Structure",id:"migration-structure",level:2},{value:"Setting The Migration Connection",id:"setting-the-migration-connection",level:4},{value:"Running Migrations",id:"running-migrations",level:2},{value:"Forcing Migrations To Run In Production",id:"forcing-migrations-to-run-in-production",level:4},{value:"Rolling Back Migrations",id:"rolling-back-migrations",level:3},{value:"Roll Back & Migrate Using A Single Command",id:"roll-back--migrate-using-a-single-command",level:4},{value:"Drop All Tables & Migrate",id:"drop-all-tables--migrate",level:4},{value:"Tables",id:"tables",level:2},{value:"Creating Tables",id:"creating-tables",level:3},{value:"Checking For Table / Column Existence",id:"checking-for-table--column-existence",level:4},{value:"Database Connection & Table Options",id:"database-connection--table-options",level:4},{value:"Updating Tables",id:"updating-tables",level:3},{value:"Renaming / Dropping Tables",id:"renaming-and-dropping-tables",level:3},{value:"Renaming Tables With Foreign Keys",id:"renaming-tables-with-foreign-keys",level:4},{value:"Columns",id:"columns",level:2},{value:"Creating Columns",id:"creating-columns",level:3},{value:"Available Column Types",id:"available-column-types",level:3},{value:"bigIncrements()",id:"column-method-bigIncrements",level:4},{value:"bigInteger()",id:"column-method-bigInteger",level:4},{value:"binary()",id:"column-method-binary",level:4},{value:"boolean()",id:"column-method-boolean",level:4},{value:"Char()",id:"column-method-Char",level:4},{value:"date()",id:"column-method-date",level:4},{value:"datetime()",id:"column-method-datetime",level:4},{value:"datetimes()",id:"column-method-datetimes",level:4},{value:"datetimeTz()",id:"column-method-datetimeTz",level:4},{value:"decimal()",id:"column-method-decimal",level:4},{value:"Double()",id:"column-method-Double",level:4},{value:"Enum()",id:"column-method-Enum",level:4},{value:"Float()",id:"column-method-Float",level:4},{value:"foreignId()",id:"column-method-foreignId",level:4},{value:"foreignIdFor()",id:"column-method-foreignIdFor",level:4},{value:"foreignUuid()",id:"column-method-foreignUuid",level:4},{value:"geometry()",id:"column-method-geometry",level:4},{value:"geometryCollection()",id:"column-method-geometryCollection",level:4},{value:"id()",id:"column-method-id",level:4},{value:"increments()",id:"column-method-increments",level:4},{value:"integer()",id:"column-method-integer",level:4},{value:"ipAddress()",id:"column-method-ipAddress",level:4},{value:"json()",id:"column-method-json",level:4},{value:"jsonb()",id:"column-method-jsonb",level:4},{value:"lineString()",id:"column-method-lineString",level:4},{value:"longBinary()",id:"column-method-longBinary",level:4},{value:"longText()",id:"column-method-longText",level:4},{value:"macAddress()",id:"column-method-macAddress",level:4},{value:"mediumBinary()",id:"column-method-mediumBinary",level:4},{value:"mediumIncrements()",id:"column-method-mediumIncrements",level:4},{value:"mediumInteger()",id:"column-method-mediumInteger",level:4},{value:"mediumText()",id:"column-method-mediumText",level:4},{value:"multiLineString()",id:"column-method-multiLineString",level:4},{value:"multiPoint()",id:"column-method-multiPoint",level:4},{value:"multiPolygon()",id:"column-method-multiPolygon",level:4},{value:"point()",id:"column-method-point",level:4},{value:"polygon()",id:"column-method-polygon",level:4},{value:"rememberToken()",id:"column-method-rememberToken",level:4},{value:"set()",id:"column-method-set",level:4},{value:"smallIncrements()",id:"column-method-smallIncrements",level:4},{value:"smallInteger()",id:"column-method-smallInteger",level:4},{value:"softDeletes()",id:"column-method-softDeletes",level:4},{value:"softDeletesDatetime()",id:"column-method-softDeletesDatetime",level:4},{value:"softDeletesTz()",id:"column-method-softDeletesTz",level:4},{value:"string()",id:"column-method-string",level:4},{value:"text()",id:"column-method-text",level:4},{value:"time()",id:"column-method-time",level:4},{value:"timeTz()",id:"column-method-timeTz",level:4},{value:"timestamp()",id:"column-method-timestamp",level:4},{value:"timestampTz()",id:"column-method-timestampTz",level:4},{value:"timestampsTz()",id:"column-method-timestampsTz",level:4},{value:"timestamps()",id:"column-method-timestamps",level:4},{value:"tinyBinary()",id:"column-method-tinyBinary",level:4},{value:"tinyIncrements()",id:"column-method-tinyIncrements",level:4},{value:"tinyInteger()",id:"column-method-tinyInteger",level:4},{value:"tinyText()",id:"column-method-tinyText",level:4},{value:"unsignedBigInteger()",id:"column-method-unsignedBigInteger",level:4},{value:"unsignedDecimal()",id:"column-method-unsignedDecimal",level:4},{value:"unsignedInteger()",id:"column-method-unsignedInteger",level:4},{value:"unsignedMediumInteger()",id:"column-method-unsignedMediumInteger",level:4},{value:"unsignedSmallInteger()",id:"column-method-unsignedSmallInteger",level:4},{value:"unsignedTinyInteger()",id:"column-method-unsignedTinyInteger",level:4},{value:"uuid()",id:"column-method-uuid",level:4},{value:"year()",id:"column-method-year",level:4},{value:"Column Modifiers",id:"column-modifiers",level:3},{value:"Default Expressions",id:"default-expressions",level:4},{value:"Column Order",id:"column-order",level:4},{value:"Modifying Columns",id:"modifying-columns",level:3},{value:"Renaming Columns",id:"renaming-columns",level:4},{value:"Renaming Columns On Legacy Databases",id:"renaming-columns-on-legacy-databases",level:4},{value:"Dropping Columns",id:"dropping-columns",level:3},{value:"Available Command Aliases",id:"available-command-aliases",level:4},{value:"Indexes",id:"indexes",level:2},{value:"Creating Indexes",id:"creating-indexes",level:3},{value:"Available Index Types",id:"available-index-types",level:4},{value:"Index Lengths & MySQL / MariaDB",id:"index-lengths--mysql--mariadb",level:4},{value:"Renaming Indexes",id:"renaming-indexes",level:3},{value:"Dropping Indexes",id:"dropping-indexes",level:3},{value:"Foreign Key Constraints",id:"foreign-key-constraints",level:3},{value:"Dropping Foreign Keys",id:"dropping-foreign-keys",level:4},{value:"Toggling Foreign Key Constraints",id:"toggling-foreign-key-constraints",level:4}];function g(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.h1,{id:"database-migrations",children:"Database: Migrations"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#generating-migrations",children:"Generating Migrations"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#tab-completion",children:"Tab completion"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#alternative-installation-methods",children:"Alternative installation methods"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#migration-structure",children:"Migration Structure"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#running-migrations",children:"Running Migrations"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#rolling-back-migrations",children:"Rolling Back Migrations"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#tables",children:"Tables"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-tables",children:"Creating Tables"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#updating-tables",children:"Updating Tables"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#renaming-and-dropping-tables",children:"Renaming / Dropping Tables"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#columns",children:"Columns"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-columns",children:"Creating Columns"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#available-column-types",children:"Available Column Types"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#column-modifiers",children:"Column Modifiers"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#modifying-columns",children:"Modifying Columns"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dropping-columns",children:"Dropping Columns"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#indexes",children:"Indexes"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#creating-indexes",children:"Creating Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#renaming-indexes",children:"Renaming Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dropping-indexes",children:"Dropping Indexes"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#foreign-key-constraints",children:"Foreign Key Constraints"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,l.jsx)("div",{class:"api-stability alert alert--success",children:(0,l.jsxs)(n.p,{children:[(0,l.jsx)(s.A,{to:"/stability#stability-indexes",children:(0,l.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,l.jsx)(n.p,{children:"Migrations are like version control for your database, allowing your team to define and share the application's database schema definition. If you have ever had to tell a teammate to manually add a column to their local database schema after pulling in your changes from source control, you've faced the problem that database migrations solve."}),"\n",(0,l.jsxs)(n.p,{children:["The TinyORM ",(0,l.jsx)(n.code,{children:"Schema"})," facade provides database agnostic support for creating and manipulating tables across all of TinyORM's supported database systems. Typically, migrations will use this facade to create and modify database tables and columns."]}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom"})," migrations is a small console application that depends on the ",(0,l.jsx)(n.code,{children:"TinyORM"})," library. All migrations logic is compiled so recompilation is needed after adding a new migration class."]}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.a,{href:"/database/migrations#tables",children:(0,l.jsx)(n.code,{children:"schema builder"})})," and ",(0,l.jsx)(n.a,{href:"/database/migrations",children:(0,l.jsx)(n.code,{children:"migrations"})})," don't support ",(0,l.jsx)(n.a,{href:"/database/getting-started#multi-threading-support",children:"multi-threading"}),"."]})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsxs)(n.p,{children:["TinyORM's schema builder supports all ",(0,l.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"})," out of the box."]})}),"\n",(0,l.jsxs)(n.p,{children:["The following image shows what the ",(0,l.jsx)(n.code,{children:"tom"})," console application looks like. \u2728 As you can see it offers everything that is needed to generate and manage migrations and seeders and all of this is backed up with the tab completion."]}),"\n",(0,l.jsx)("img",{src:i(5848).A,alt:"TinyORM - Tom console application - Showcase",width:"760",title:"TinyORM - Tom console application - Showcase"}),"\n",(0,l.jsx)(n.h2,{id:"generating-migrations",children:"Generating Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["You may use the ",(0,l.jsx)(n.code,{children:"make:migration"})," ",(0,l.jsx)(n.code,{children:"tom"})," command to generate a database migration. The new migration will be placed in your ",(0,l.jsx)(n.code,{children:"database/migrations"})," directory. Each migration filename contains a timestamp that allows ",(0,l.jsx)(n.code,{children:"tom"})," to determine the order of the migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom make:migration create_posts_table\n"})}),"\n",(0,l.jsxs)(n.p,{children:["tom will use the name of the migration to attempt to guess the name of the table and whether or not the migration will be creating a new table. If ",(0,l.jsx)(n.code,{children:"tom"})," is able to determine the table name from the migration name, ",(0,l.jsx)(n.code,{children:"tom"})," will pre-fill the generated migration file with the specified table. Otherwise, you may simply specify the table in the migration file manually."]}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to specify a custom path for the generated migration, you may use the ",(0,l.jsx)(n.code,{children:"--path"})," option when executing the ",(0,l.jsx)(n.code,{children:"make:migration"})," command. The given path should be relative to your ",(0,l.jsx)("abbr",{title:"Current working directory",children:"pwd"})," or you can use the ",(0,l.jsx)(n.code,{children:"--realpath"})," option and pass the absolute path to the ",(0,l.jsx)(n.code,{children:"--path"})," option."]}),"\n",(0,l.jsx)(n.h4,{id:"migrations-naming-rules",children:"Migrations naming rules"}),"\n",(0,l.jsxs)(n.p,{children:["If the migration name starts with the ",(0,l.jsx)(n.code,{children:"create_"})," string then the stub for table creation will be used and if the migration name contains ",(0,l.jsx)(n.code,{children:"_(from|to|in)_"})," then the stub for table update will be used. You can override these rules using the ",(0,l.jsx)(n.code,{children:"--create"})," and ",(0,l.jsx)(n.code,{children:"--table"})," options and specify the table name manually."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can also pass the full migration filename with the datetime prefix and extension to the ",(0,l.jsx)(n.code,{children:"make:migration"}),". This command is able to detect almost any combination of the passed value, with or without datetime prefix or extension if it is the filename; or StudlyCase, snake_case, or kebab-case if it is the classname or any combination described above. \ud83d\udc40"]})}),"\n",(0,l.jsx)(n.h2,{id:"tab-completion",children:"Tab completion"}),"\n",(0,l.jsxs)(n.p,{children:["Tab completion is available for the ",(0,l.jsx)(n.code,{children:"pwsh"})," (on Linux too), ",(0,l.jsx)(n.code,{children:"bash"}),", and ",(0,l.jsx)(n.code,{children:"zsh"})," shells. For ",(0,l.jsx)(n.code,{children:"pwsh"})," the ",(0,l.jsx)(n.code,{children:"tom.exe"})," and ",(0,l.jsx)(n.code,{children:"TinyOrm0.dll"})," library must be on the system path to work properly. With ",(0,l.jsx)(n.code,{children:"bash"})," if the ",(0,l.jsx)(n.code,{children:"tom"})," executable and ",(0,l.jsx)(n.code,{children:"libTinyOrm.so"})," library is ",(0,l.jsx)(n.strong,{children:"not"})," on the system path then it will provide less accurate completions."]}),"\n",(0,l.jsx)(n.p,{children:"You can enable it using the following commands."}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.b,label:c.ux,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"tom integrate pwsh\n"})})}),(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom integrate bash\n"})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom integrate zsh\ntom integrate zsh --path=/usr/share/zsh/site-functions\n"})})})]}),"\n",(0,l.jsxs)(n.p,{children:["Or you can enable it manually. Following actions are the same as the ",(0,l.jsx)(n.code,{children:"tom integrate"})," command does."]}),"\n",(0,l.jsxs)(n.p,{children:["For the ",(0,l.jsx)(n.code,{children:"pwsh"})," paste the following code to the pwsh profile (works on Linux or Windows)."]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",metastring:"title='~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1'",children:"Register-ArgumentCompleter -Native -CommandName tom,tom_testdata -ScriptBlock {\n Param($wordToComplete, $commandAst, $cursorPosition)\n [Console]::InputEncoding =\n [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()\n $Local:word = $wordToComplete.Replace('\"', '\\\"')\n $Local:ast = $commandAst.ToString().Replace('\"', '\\\"')\n tom complete --word=\"$Local:word\" --commandline=\"$Local:ast\" --position=$cursorPosition\n | ForEach-Object {\n $completionText, $listText, $toolTip = $_ -split ';', 3\n $listText ??= $completionText\n $toolTip ??= $completionText\n [System.Management.Automation.CompletionResult]::new(\n $completionText, $listText, 'ParameterValue', $toolTip)\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["For ",(0,l.jsx)(n.code,{children:"bash"})," you can copy or create symlink of the ",(0,l.jsx)(n.code,{children:"/tools/completions/tom.bash"})," file to the ",(0,l.jsx)(n.code,{children:"/usr/share/bash-completion/completions"})," folder."]}),"\n",(0,l.jsx)(a.A,{className:"language-bash",children:`sudo ln -s ${(0,h.OZ)(c.xj)}/TinyORM/tools/completions/tom.bash /usr/share/bash-completion/completions/tom`}),"\n",(0,l.jsxs)(n.p,{children:["And for ",(0,l.jsx)(n.code,{children:"zsh"})," you can copy or create symlink of the ",(0,l.jsx)(n.code,{children:"/tools/completions/tom.zsh"})," file to the ",(0,l.jsx)(n.code,{children:"_tom"})," file to ",(0,l.jsx)(n.code,{children:"/usr/local/share/zsh/site-functions"})," folder."]}),"\n",(0,l.jsx)(a.A,{className:"language-bash",children:`sudo ln -s ${(0,h.OZ)(c.xj)}/TinyORM/tools/completions/tom.zsh /usr/local/share/zsh/site-functions/_tom`}),"\n",(0,l.jsxs)(n.p,{children:["It will provide completions for the ",(0,l.jsx)(n.code,{children:"tom"})," commands, long and short parameters, and also for some positional arguments like namespaces for the ",(0,l.jsx)(n.code,{children:"list"})," command or commands for the ",(0,l.jsx)(n.code,{children:"help"})," command."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom integrate zsh"})," command also accepts the ",(0,l.jsx)(n.code,{children:"--path="})," option with which you can set the location, where the zsh completion file should be created."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can also output the completion script using the ",(0,l.jsx)(n.code,{children:"--stdout"})," option eg. ",(0,l.jsx)(n.code,{children:"tom integrate bash --stdout"}),"."]})}),"\n",(0,l.jsx)(n.h3,{id:"alternative-installation-methods",children:"Alternative installation methods"}),"\n",(0,l.jsxs)(n.p,{children:["This section describes alternative installation methods for ",(0,l.jsx)(n.code,{children:"bash"})," and ",(0,l.jsx)(n.code,{children:"zsh"})," tab completions."]}),"\n",(0,l.jsx)(n.h4,{id:"static-installation",children:"Static installation"}),"\n",(0,l.jsx)(n.p,{children:"Idea is to output the tab completion to the file and then source it."}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"mkdir -p ~/.local/share/tom\ntom integrate bash --stdout > ~/.local/share/tom/tom.bash\n\n# Then source this file in the ~/.bashrc\nsource $HOME/.local/share/tom/tom.bash\n"})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"mkdir -p ~/.local/share/tom\ntom integrate zsh --stdout > ~/.local/share/tom/tom.zsh\n\n# Then source this file in the ~/.zshrc\nsource $HOME/.local/share/tom/tom.zsh\ncompdef _tom tom\n"})})})]}),"\n",(0,l.jsx)(n.h4,{id:"dynamic-installation",children:"Dynamic installation"}),"\n",(0,l.jsxs)(n.p,{children:["Idea is to ",(0,l.jsx)(n.strong,{children:"avoid"})," outputting the tab completion to the file, so you ",(0,l.jsx)(n.code,{children:"eval"})," the tab completion source code right away."]}),"\n",(0,l.jsxs)(r.A,{groupId:c.vf,children:[(0,l.jsx)(o.A,{value:c.xj,label:c.gg,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'# Add this eval to the ~/.bashrc\neval "$(tom integrate bash --stdout)"\n'})})}),(0,l.jsx)(o.A,{value:c.cy,label:c.$E,children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'# Add this eval to the ~/.zshrc\neval "$(tom integrate zsh --stdout)"\ncompdef _tom tom\n'})})})]}),"\n",(0,l.jsx)(n.h2,{id:"migration-structure",children:"Migration Structure"}),"\n",(0,l.jsxs)(n.p,{children:["A migration class contains two methods: ",(0,l.jsx)(n.code,{children:"up"})," and ",(0,l.jsx)(n.code,{children:"down"}),". The ",(0,l.jsx)(n.code,{children:"up"})," method is used to add new tables, columns, or indexes to your database, while the ",(0,l.jsx)(n.code,{children:"down"})," method should reverse the operations performed by the ",(0,l.jsx)(n.code,{children:"up"})," method."]}),"\n",(0,l.jsxs)(n.p,{children:["Within both of these methods, you may use the TinyORM schema builder to expressively create and modify tables. To learn about all of the methods available on the ",(0,l.jsx)(n.code,{children:"Schema"})," builder, ",(0,l.jsx)(n.a,{href:"#creating-tables",children:"check out its documentation"}),". For example, the following migration creates a ",(0,l.jsx)(n.code,{children:"posts"})," table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nnamespace Migrations\n{\n\n struct CreatePostsTable : Migration\n {\n /*! Filename of the migration file. */\n T_MIGRATION\n\n /*! Run the migrations. */\n void up() const override\n {\n Schema::create("posts", [](Blueprint &table)\n {\n table.id();\n\n table.string(NAME);\n table.timestamps();\n });\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n Schema::dropIfExists("posts");\n }\n };\n\n} // namespace Migrations\n'})}),"\n",(0,l.jsxs)(n.p,{children:['Migration classes can be named in two formats, StudlyCase without the datetime prefix and "snake_case" with the datetime prefix. If the StudlyCase name is used then the ',(0,l.jsx)(n.code,{children:"T_MIGRATION"})," macro must also be used in the migration class."]}),"\n",(0,l.jsx)(n.p,{children:"Naming with the datetime prefix should look like this."}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"struct _2014_10_12_000000_create_posts_table : Migration\n{\n\n /*! Run the migrations. */\n void up() const override\n {\n //\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n //\n }\n};\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The StudlyCase naming is preferred. Also the ",(0,l.jsx)(n.code,{children:"make:migration"})," command generates migrations in this format."]})}),"\n",(0,l.jsx)(n.h4,{id:"setting-the-migration-connection",children:"Setting The Migration Connection"}),"\n",(0,l.jsxs)(n.p,{children:["If your migration will be interacting with a database connection other than your application's default database connection, you should set the ",(0,l.jsx)(n.code,{children:"connection"})," data member of your migration:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'/*! The name of the database connection to use. */\nQString connection = QStringLiteral("tinyorm_example");\n\n/*! Run the migrations. */\nvoid up() const override\n{\n //\n}\n'})}),"\n",(0,l.jsx)(n.h2,{id:"running-migrations",children:"Running Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["To run all of your outstanding migrations, execute the ",(0,l.jsx)(n.code,{children:"migrate"})," Tom command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate\n"})}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to see which migrations have run thus far, you may use the ",(0,l.jsx)(n.code,{children:"migrate:status"})," tom command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:status\n"})}),"\n",(0,l.jsxs)(n.p,{children:["If you would like to see the SQL statements that will be executed by the migrations without actually running them, you may provide the ",(0,l.jsx)(n.code,{children:"--pretend"})," flag to the ",(0,l.jsx)(n.code,{children:"migrate"})," command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate --pretend\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["Many ",(0,l.jsx)(n.code,{children:"tom"})," commands offer variety of options, you can explore them using the ",(0,l.jsx)(n.code,{children:"tom list"})," and ",(0,l.jsx)(n.code,{children:"tom help"})," commands. In most cases, these commands and options are self-explanatory."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tom"})," command is able to guess the command name and command namespace, eg. ",(0,l.jsx)(n.code,{children:"tom mig:st"})," or ",(0,l.jsx)(n.code,{children:"tom m:rol"}),", ..."]})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can pass the ",(0,l.jsx)(n.code,{children:"-vvv"})," command-line argument to any command to see all executed SQL queries. \ud83d\udc4c"]})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate"})," Tom command internally calls the ",(0,l.jsx)(n.code,{children:"migrate:install"})," command which installs the migration repository table. To uninstall this repository table you can call the ",(0,l.jsx)(n.code,{children:"migrate:uninstall"}),"."]})}),"\n",(0,l.jsx)(n.h4,{id:"forcing-migrations-to-run-in-production",children:"Forcing Migrations To Run In Production"}),"\n",(0,l.jsxs)(n.p,{children:["Some migration operations are destructive, which means they may cause you to lose data. In order to protect you from running these commands against your production database, you will be prompted for confirmation before the commands are executed. To force the commands to run without a prompt, use the ",(0,l.jsx)(n.code,{children:"--force"})," flag:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate --force\n"})}),"\n",(0,l.jsx)(n.h3,{id:"rolling-back-migrations",children:"Rolling Back Migrations"}),"\n",(0,l.jsxs)(n.p,{children:["To roll back the latest migration operation, you may use the ",(0,l.jsx)(n.code,{children:"rollback"}),' Tom command. This command rolls back the last "batch" of migrations, which may include multiple migration files:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback\n"})}),"\n",(0,l.jsxs)(n.p,{children:["You may roll back a limited number of migrations by providing the ",(0,l.jsx)(n.code,{children:"step"})," option to the ",(0,l.jsx)(n.code,{children:"rollback"})," command. For example, the following command will roll back the last five migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback --step=5\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:reset"})," command will roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:reset\n"})}),"\n",(0,l.jsxs)(n.p,{children:['You may roll back a specific "batch" of migrations by providing the ',(0,l.jsx)(n.code,{children:"batch"})," option to the ",(0,l.jsx)(n.code,{children:"rollback"})," command, where the ",(0,l.jsx)(n.code,{children:"batch"})," option corresponds to a batch value within your application's ",(0,l.jsx)(n.code,{children:"migrations"})," database table. For example, the following command will roll back all migrations in batch three:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:rollback --batch=3\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:reset"})," command will roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:reset\n"})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:uninstall"})," command will uninstall the migration repository table, it optionally accepts the ",(0,l.jsx)(n.code,{children:"--reset"})," option to roll back all of your application's migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:uninstall --reset\n"})}),"\n",(0,l.jsx)(n.h4,{id:"roll-back--migrate-using-a-single-command",children:"Roll Back & Migrate Using A Single Command"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:refresh"})," command will roll back all of your migrations and then execute the ",(0,l.jsx)(n.code,{children:"migrate"})," command. This command effectively re-creates your entire database:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:refresh\n"})}),"\n",(0,l.jsxs)(n.p,{children:["You may roll back and re-migrate a limited number of migrations by providing the ",(0,l.jsx)(n.code,{children:"step"})," option to the ",(0,l.jsx)(n.code,{children:"refresh"})," command. For example, the following command will roll back and re-migrate the last five migrations:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:refresh --step=5\n"})}),"\n",(0,l.jsx)(n.h4,{id:"drop-all-tables--migrate",children:"Drop All Tables & Migrate"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:fresh"})," command will drop all tables from the database and then execute the ",(0,l.jsx)(n.code,{children:"migrate"})," command:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tom migrate:fresh\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"migrate:fresh"})," command will drop all database tables regardless of their prefix. This command should be used with caution when developing on a database that is shared with other applications."]})}),"\n",(0,l.jsx)(n.h2,{id:"tables",children:"Tables"}),"\n",(0,l.jsx)(n.h3,{id:"creating-tables",children:"Creating Tables"}),"\n",(0,l.jsxs)(n.p,{children:["To create a new database table, use the ",(0,l.jsx)(n.code,{children:"create"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade. The ",(0,l.jsx)(n.code,{children:"create"})," method accepts two arguments: the first is the name of the table, while the second is a lambda expression which receives a ",(0,l.jsx)(n.code,{children:"Orm::SchemaNs::Blueprint"})," object that may be used to define the new table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Schema;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.id();\n table.string("name");\n table.string("email");\n table.timestamps();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["When creating the table, you may use any of the schema builder's ",(0,l.jsx)(n.a,{href:"#creating-columns",children:"column methods"})," to define the table's columns."]}),"\n",(0,l.jsx)(n.h4,{id:"checking-for-table--column-existence",children:"Checking For Table / Column Existence"}),"\n",(0,l.jsxs)(n.p,{children:["You may check for the existence of a table or column using the ",(0,l.jsx)(n.code,{children:"hasTable"})," and ",(0,l.jsx)(n.code,{children:"hasColumn"})," methods:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'if (Schema::hasTable("users")) {\n // The "users" table exists...\n}\n\nif (Schema::hasColumn("users", "email")) {\n // The "users" table exists and has an "email" column...\n}\n'})}),"\n",(0,l.jsx)(n.h4,{id:"database-connection--table-options",children:"Database Connection & Table Options"}),"\n",(0,l.jsxs)(n.p,{children:["If you want to perform a schema operation on a database connection that is not your application's default connection, use the ",(0,l.jsx)(n.code,{children:"connection"})," method or ",(0,l.jsx)(n.code,{children:"on"})," alias:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::connection("postgres").create("users", [](Blueprint &table)\n{\n table.id();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["In addition, a few other data members and methods may be used to define other aspects of the table's creation. The ",(0,l.jsx)(n.code,{children:"engine"})," data member may be used to specify the table's storage engine when using MySQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::InnoDB;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.engine = InnoDB;\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"charset"})," and ",(0,l.jsx)(n.code,{children:"collation"})," data members may be used to specify the character set and collation for the created table when using MySQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::UTF8MB4;\n\nSchema::create("users", [](Blueprint &table)\n{\n table.charset = UTF8MB4;\n table.collation = "utf8mb4_unicode_ci";\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"temporary"}),' method may be used to indicate that the table should be "temporary". Temporary tables are only visible to the current connection\'s database session and are dropped automatically when the connection is closed:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::create("calculations", [](Blueprint &table)\n{\n table.temporary();\n\n // ...\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:['If you would like to add a "comment" to a database table, you may invoke the ',(0,l.jsx)(n.code,{children:"comment"})," method on the table instance. Table comments are currently only supported by MySQL and PostgreSQL:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::create("calculations", [](Blueprint &table)\n{\n table.comment("Business calculations");\n\n // ...\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"updating-tables",children:"Updating Tables"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"table"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade may be used to update existing tables. Like the ",(0,l.jsx)(n.code,{children:"create"})," method, the ",(0,l.jsx)(n.code,{children:"table"})," method accepts two arguments: the name of the table and a lambda expression that receives a ",(0,l.jsx)(n.code,{children:"Blueprint"})," instance you may use to add columns or indexes to the table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.integer("votes");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"renaming-and-dropping-tables",children:"Renaming / Dropping Tables"}),"\n",(0,l.jsxs)(n.p,{children:["To rename an existing database table, use the ",(0,l.jsx)(n.code,{children:"rename"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::rename("from", "to");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["To drop an existing table, you may use the ",(0,l.jsx)(n.code,{children:"drop"})," or ",(0,l.jsx)(n.code,{children:"dropIfExists"})," methods:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::drop("users");\n\nSchema::dropIfExists("users");\n'})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-tables-with-foreign-keys",children:"Renaming Tables With Foreign Keys"}),"\n",(0,l.jsxs)(n.p,{children:["Before renaming a table, you should verify that any foreign key constraints on the table have an explicit name in your migration files instead of letting TinyORM assign a convention based name. Otherwise, the foreign key constraint ",(0,l.jsx)(n.strong,{children:"index name"})," will refer to the old table name."]}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["After renaming a table, you can re-create (drop and create again) the foreign key constraints to fix an ",(0,l.jsx)(n.strong,{children:"index name"}),", so it refers to a renamed table."]})}),"\n",(0,l.jsx)(n.h2,{id:"columns",children:"Columns"}),"\n",(0,l.jsx)(n.h3,{id:"creating-columns",children:"Creating Columns"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"table"})," method on the ",(0,l.jsx)(n.code,{children:"Schema"})," facade may be used to update existing tables. Like the ",(0,l.jsx)(n.code,{children:"create"})," method, the ",(0,l.jsx)(n.code,{children:"table"})," method accepts two arguments: the name of the table and a lambda expression that receives a ",(0,l.jsx)(n.code,{children:"Blueprint"})," instance you may use to add columns to the table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.integer("votes");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"available-column-types",children:"Available Column Types"}),"\n",(0,l.jsx)(n.p,{children:"The schema builder blueprint offers a variety of methods that correspond to the different types of columns you can add to your database tables. Each of the available methods are listed in the table below:"}),"\n",(0,l.jsx)("div",{className:"tom-column-types-list",children:(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"#column-method-bigIncrements",children:"bigIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-bigInteger",children:"bigInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-binary",children:"binary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-boolean",children:"boolean"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Char",children:"Char"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-date",children:"date"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetime",children:"datetime"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetimes",children:"datetimes"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-datetimeTz",children:"datetimeTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-decimal",children:"decimal"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Double",children:"Double"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Enum",children:"Enum"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-Float",children:"Float"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignId",children:"foreignId"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignIdFor",children:"foreignIdFor"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-foreignUuid",children:"foreignUuid"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-geometry",children:"geometry"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-geometryCollection",children:"geometryCollection"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-id",children:"id"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-increments",children:"increments"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-integer",children:"integer"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-ipAddress",children:"ipAddress"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-json",children:"json"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-jsonb",children:"jsonb"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-lineString",children:"lineString"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-longBinary",children:"longBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-longText",children:"longText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-macAddress",children:"macAddress"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumBinary",children:"mediumBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumIncrements",children:"mediumIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumInteger",children:"mediumInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-mediumText",children:"mediumText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiLineString",children:"multiLineString"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiPoint",children:"multiPoint"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-multiPolygon",children:"multiPolygon"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-point",children:"point"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-polygon",children:"polygon"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-rememberToken",children:"rememberToken"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-set",children:"set"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-smallIncrements",children:"smallIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-smallInteger",children:"smallInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletes",children:"softDeletes"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletesDatetime",children:"softDeletesDatetime"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-softDeletesTz",children:"softDeletesTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-string",children:"string"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-text",children:"text"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-time",children:"time"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timeTz",children:"timeTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestamp",children:"timestamp"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestampTz",children:"timestampTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestampsTz",children:"timestampsTz"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-timestamps",children:"timestamps"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyBinary",children:"tinyBinary"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyIncrements",children:"tinyIncrements"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyInteger",children:"tinyInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-tinyText",children:"tinyText"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedBigInteger",children:"unsignedBigInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedDecimal",children:"unsignedDecimal"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedInteger",children:"unsignedInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedMediumInteger",children:"unsignedMediumInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedSmallInteger",children:"unsignedSmallInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-unsignedTinyInteger",children:"unsignedTinyInteger"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-uuid",children:"uuid"}),"\n",(0,l.jsx)(n.a,{href:"#column-method-year",children:"year"})]})}),"\n",(0,l.jsx)(n.admonition,{type:"info",children:(0,l.jsxs)(n.p,{children:["Names of ",(0,l.jsx)(n.code,{children:"Char"}),", ",(0,l.jsx)(n.code,{children:"Double"}),", ",(0,l.jsx)(n.code,{children:"Enum"}),", and ",(0,l.jsx)(n.code,{children:"Float"})," column methods are in the CamelCase format to avoid collisions with C++ keywords."]})}),"\n",(0,l.jsxs)("div",{className:"tom-column-types",children:[(0,l.jsx)(n.h4,{id:"column-method-bigIncrements",children:(0,l.jsx)(n.code,{children:"bigIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"bigIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," (primary key) equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.bigIncrements(Orm::ID);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-bigInteger",children:(0,l.jsx)(n.code,{children:"bigInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"bigInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.bigInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-binary",children:(0,l.jsx)(n.code,{children:"binary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"binary"})," method creates a ",(0,l.jsx)(n.code,{children:"BLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.binary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-boolean",children:(0,l.jsx)(n.code,{children:"boolean()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"boolean"})," method creates a ",(0,l.jsx)(n.code,{children:"BOOLEAN"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.boolean("confirmed");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Char",children:(0,l.jsx)(n.code,{children:"Char()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Char"})," method creates a ",(0,l.jsx)(n.code,{children:"CHAR"})," equivalent column with of a given length:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.Char(Orm::NAME, 100);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-date",children:(0,l.jsx)(n.code,{children:"date()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"date"})," method creates a ",(0,l.jsx)(n.code,{children:"DATE"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.date("created_at");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-datetime",children:(0,l.jsx)(n.code,{children:"datetime()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetime"})," method creates a ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.datetime("created_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-datetimes",children:(0,l.jsx)(n.code,{children:"datetimes()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetimes"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.datetimes(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-datetimeTz",children:(0,l.jsx)(n.code,{children:"datetimeTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"datetimeTz"})," method creates a ",(0,l.jsx)(n.code,{children:"DATETIME"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.datetimeTz(Orm::CREATED_AT, precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-decimal",children:(0,l.jsx)(n.code,{children:"decimal()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"decimal"})," method creates a ",(0,l.jsx)(n.code,{children:"DECIMAL"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.decimal("amount", precision = 8, scale = 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Double",children:(0,l.jsx)(n.code,{children:"Double()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Double"})," method creates a ",(0,l.jsx)(n.code,{children:"DOUBLE"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Double("amount", 8, 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Enum",children:(0,l.jsx)(n.code,{children:"Enum()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Enum"})," method creates a ",(0,l.jsx)(n.code,{children:"ENUM"})," equivalent column with the given valid values:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Enum("difficulty", {"easy", "hard"});\n'})}),(0,l.jsx)(n.h4,{id:"column-method-Float",children:(0,l.jsx)(n.code,{children:"Float()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"Float"})," method creates a ",(0,l.jsx)(n.code,{children:"FLOAT"})," equivalent column with the given precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.Float("amount", 8, 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignId",children:(0,l.jsx)(n.code,{children:"foreignId()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignId"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignId("user_id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignIdFor",children:(0,l.jsx)(n.code,{children:"foreignIdFor()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignIdFor"})," method adds a ",(0,l.jsx)(n.code,{children:"{column}_id UNSIGNED BIGINT"})," equivalent column for a given model class:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nModels::User user;\n\ntable.foreignIdFor(User);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-foreignUuid",children:(0,l.jsx)(n.code,{children:"foreignUuid()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignUuid"})," method creates a ",(0,l.jsx)(n.code,{children:"UUID"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignUuid("user_id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-geometry",children:(0,l.jsx)(n.code,{children:"geometry()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"geometry"})," method creates a ",(0,l.jsx)(n.code,{children:"GEOMETRY"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.geometry("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-geometryCollection",children:(0,l.jsx)(n.code,{children:"geometryCollection()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"geometryCollection"})," method creates a ",(0,l.jsx)(n.code,{children:"GEOMETRYCOLLECTION"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.geometryCollection("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-id",children:(0,l.jsx)(n.code,{children:"id()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"id"})," method is an alias of the ",(0,l.jsx)(n.code,{children:"bigIncrements"})," method. By default, the method will create an ",(0,l.jsx)(n.code,{children:"id"})," column; however, you may pass a column name if you would like to assign a different name to the column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.id();\n"})}),(0,l.jsx)(n.h4,{id:"column-method-increments",children:(0,l.jsx)(n.code,{children:"increments()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"increments"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED INTEGER"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.increments("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-integer",children:(0,l.jsx)(n.code,{children:"integer()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"integer"})," method creates an ",(0,l.jsx)(n.code,{children:"INTEGER"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.integer("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-ipAddress",children:(0,l.jsx)(n.code,{children:"ipAddress()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"ipAddress"})," method creates a ",(0,l.jsx)(n.code,{children:"VARCHAR(45)"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.ipAddress("visitor");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-json",children:(0,l.jsx)(n.code,{children:"json()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"json"})," method creates a ",(0,l.jsx)(n.code,{children:"JSON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.json("options");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-jsonb",children:(0,l.jsx)(n.code,{children:"jsonb()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"jsonb"})," method creates a ",(0,l.jsx)(n.code,{children:"JSONB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.jsonb("options");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-lineString",children:(0,l.jsx)(n.code,{children:"lineString()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"lineString"})," method creates a ",(0,l.jsx)(n.code,{children:"LINESTRING"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.lineString("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-longBinary",children:(0,l.jsx)(n.code,{children:"longBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"longBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"LONGBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.longBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-longText",children:(0,l.jsx)(n.code,{children:"longText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"longText"})," method creates a ",(0,l.jsx)(n.code,{children:"LONGTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.longText("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-macAddress",children:(0,l.jsx)(n.code,{children:"macAddress()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"macAddress"})," method creates a column that is intended to hold a MAC address. Some database systems, such as PostgreSQL, have a dedicated column type for this type of data. Other database systems will use a string equivalent ",(0,l.jsx)(n.code,{children:"VARCHAR(17)"})," column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.macAddress("device");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumBinary",children:(0,l.jsx)(n.code,{children:"mediumBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumIncrements",children:(0,l.jsx)(n.code,{children:"mediumIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED MEDIUMINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumInteger",children:(0,l.jsx)(n.code,{children:"mediumInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-mediumText",children:(0,l.jsx)(n.code,{children:"mediumText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"mediumText"})," method creates a ",(0,l.jsx)(n.code,{children:"MEDIUMTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.mediumText("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiLineString",children:(0,l.jsx)(n.code,{children:"multiLineString()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiLineString"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTILINESTRING"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiLineString("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiPoint",children:(0,l.jsx)(n.code,{children:"multiPoint()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiPoint"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTIPOINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiPoint("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-multiPolygon",children:(0,l.jsx)(n.code,{children:"multiPolygon()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"multiPolygon"})," method creates a ",(0,l.jsx)(n.code,{children:"MULTIPOLYGON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.multiPolygon("positions");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-point",children:(0,l.jsx)(n.code,{children:"point()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"point"})," method creates a ",(0,l.jsx)(n.code,{children:"POINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.point("position");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-polygon",children:(0,l.jsx)(n.code,{children:"polygon()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"polygon"})," method creates a ",(0,l.jsx)(n.code,{children:"POLYGON"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.polygon("position");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-rememberToken",children:(0,l.jsx)(n.code,{children:"rememberToken()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"rememberToken"})," method creates a nullable, ",(0,l.jsx)(n.code,{children:"VARCHAR(100)"}),' equivalent column that is intended to store the current "remember me" authentication token:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.rememberToken();\n"})}),(0,l.jsx)(n.h4,{id:"column-method-set",children:(0,l.jsx)(n.code,{children:"set()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"set"})," method creates a ",(0,l.jsx)(n.code,{children:"SET"})," equivalent column with the given list of valid values:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.set("flavors", {"strawberry", "vanilla"});\n'})}),(0,l.jsx)(n.h4,{id:"column-method-smallIncrements",children:(0,l.jsx)(n.code,{children:"smallIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"smallIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED SMALLINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.smallIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-smallInteger",children:(0,l.jsx)(n.code,{children:"smallInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"smallInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"SMALLINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.smallInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletes",children:(0,l.jsx)(n.code,{children:"softDeletes()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletes"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletes("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletesDatetime",children:(0,l.jsx)(n.code,{children:"softDeletesDatetime()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletesDatetime"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"DATETIME"})," equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletesDatetime("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-softDeletesTz",children:(0,l.jsx)(n.code,{children:"softDeletesTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"softDeletesTz"})," method adds a nullable ",(0,l.jsx)(n.code,{children:"deleted_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent column with an optional precision (total digits). This column is intended to store the ",(0,l.jsx)(n.code,{children:"deleted_at"}),' timestamp needed for TinyORM\'s "soft delete" functionality:']}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.softDeletesTz("deleted_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-string",children:(0,l.jsx)(n.code,{children:"string()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"string"})," method creates a ",(0,l.jsx)(n.code,{children:"VARCHAR"})," equivalent column of the given length:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\ntable.string(Orm::NAME, 100);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-text",children:(0,l.jsx)(n.code,{children:"text()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"text"})," method creates a ",(0,l.jsx)(n.code,{children:"TEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.text("description");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-time",children:(0,l.jsx)(n.code,{children:"time()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"time"})," method creates a ",(0,l.jsx)(n.code,{children:"TIME"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.time("sunrise", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timeTz",children:(0,l.jsx)(n.code,{children:"timeTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timeTz"})," method creates a ",(0,l.jsx)(n.code,{children:"TIME"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timeTz("sunrise", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestamp",children:(0,l.jsx)(n.code,{children:"timestamp()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestamp"})," method creates a ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timestamp("added_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestampTz",children:(0,l.jsx)(n.code,{children:"timestampTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestampTz"})," method creates a ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent column with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.timestampTz("added_at", precision = 0);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-timestampsTz",children:(0,l.jsx)(n.code,{children:"timestampsTz()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestampsTz"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," (with timezone) equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.timestampsTz(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-timestamps",children:(0,l.jsx)(n.code,{children:"timestamps()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"timestamps"})," method creates ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," ",(0,l.jsx)(n.code,{children:"TIMESTAMP"})," equivalent columns with an optional precision (total digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"table.timestamps(precision = 0);\n"})}),(0,l.jsx)(n.h4,{id:"column-method-tinyBinary",children:(0,l.jsx)(n.code,{children:"tinyBinary()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyBinary"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYBLOB"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyBinary("photo");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyIncrements",children:(0,l.jsx)(n.code,{children:"tinyIncrements()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyIncrements"})," method creates an auto-incrementing ",(0,l.jsx)(n.code,{children:"UNSIGNED TINYINT"})," equivalent column as a primary key:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyIncrements("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyInteger",children:(0,l.jsx)(n.code,{children:"tinyInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyInteger"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-tinyText",children:(0,l.jsx)(n.code,{children:"tinyText()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"tinyText"})," method creates a ",(0,l.jsx)(n.code,{children:"TINYTEXT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.tinyText("notes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedBigInteger",children:(0,l.jsx)(n.code,{children:"unsignedBigInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedBigInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedBigInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedDecimal",children:(0,l.jsx)(n.code,{children:"unsignedDecimal()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedDecimal"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED DECIMAL"})," equivalent column with an optional precision (total digits) and scale (decimal digits):"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedDecimal("amount", precision = 8, scale = 2);\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedInteger",children:(0,l.jsx)(n.code,{children:"unsignedInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED INTEGER"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedMediumInteger",children:(0,l.jsx)(n.code,{children:"unsignedMediumInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedMediumInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED MEDIUMINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedMediumInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedSmallInteger",children:(0,l.jsx)(n.code,{children:"unsignedSmallInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedSmallInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED SMALLINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedSmallInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-unsignedTinyInteger",children:(0,l.jsx)(n.code,{children:"unsignedTinyInteger()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"unsignedTinyInteger"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED TINYINT"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unsignedTinyInteger("votes");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-uuid",children:(0,l.jsx)(n.code,{children:"uuid()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"uuid"})," method creates a ",(0,l.jsx)(n.code,{children:"UUID"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.uuid("id");\n'})}),(0,l.jsx)(n.h4,{id:"column-method-year",children:(0,l.jsx)(n.code,{children:"year()"})}),(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"year"})," method creates a ",(0,l.jsx)(n.code,{children:"YEAR"})," equivalent column:"]}),(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.year("birth_year");\n'})})]}),"\n",(0,l.jsx)(n.h3,{id:"column-modifiers",children:"Column Modifiers"}),"\n",(0,l.jsxs)(n.p,{children:['In addition to the column types listed above, there are several column "modifiers" you may use when adding a column to a database table. For example, to make the column "nullable", you may use the ',(0,l.jsx)(n.code,{children:"nullable"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("email").nullable();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The following table contains all of the available column modifiers. This list does not include ",(0,l.jsx)(n.a,{href:"#creating-indexes",children:"index modifiers"}),":"]}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Modifier"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.after("column")'})}),(0,l.jsxs)(n.td,{children:['Place the column "after" another column ',(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".autoIncrement()"})}),(0,l.jsx)(n.td,{children:"Set INTEGER columns as auto-incrementing (primary key)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.charset("utf8mb4")'})}),(0,l.jsxs)(n.td,{children:["Specify a character set for the column ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'.collation("utf8mb4_unicode_ci")'})})}),(0,l.jsxs)(n.td,{children:["Specify a collation for the column ",(0,l.jsx)("small",{children:"(MySQL/PostgreSQL/SQL Server)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'.comment("my comment")'})}),(0,l.jsxs)(n.td,{children:["Add a comment to a column ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),".",(0,l.jsx)("br",{}),(0,l.jsx)("small",{children:"Special characters are escaped."})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".defaultValue(value)"})}),(0,l.jsxs)(n.td,{children:['Specify a "default" value for the column.',(0,l.jsx)("br",{}),(0,l.jsx)("small",{children:"Special characters are escaped."})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".first()"})}),(0,l.jsxs)(n.td,{children:['Place the column "first" in the table ',(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".from(integer)"})}),(0,l.jsxs)(n.td,{children:["Set the starting value of an auto-incrementing field, an alias for ",(0,l.jsx)(n.code,{children:"startingValue()"})," ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".invisible()"})}),(0,l.jsxs)(n.td,{children:['Make the column "invisible" to ',(0,l.jsx)(n.code,{children:"SELECT *"})," queries ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".nullable(value = true)"})}),(0,l.jsx)(n.td,{children:"Allow NULL values to be inserted into the column."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".startingValue(integer)"})}),(0,l.jsxs)(n.td,{children:["Set the starting value of an auto-incrementing field ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".storedAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create a stored generated column ",(0,l.jsx)("small",{children:"(MySQL / PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".unsigned()"})}),(0,l.jsxs)(n.td,{children:["Set INTEGER columns as UNSIGNED ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".useCurrent()"})}),(0,l.jsx)(n.td,{children:"Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".useCurrentOnUpdate()"})}),(0,l.jsx)(n.td,{children:"Set TIMESTAMP columns to use CURRENT_TIMESTAMP when a record is updated."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".virtualAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create a virtual generated column ",(0,l.jsx)("small",{children:"(MySQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".generatedAs(expression)"})}),(0,l.jsxs)(n.td,{children:["Create an identity column with specified sequence options ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".always()"})}),(0,l.jsxs)(n.td,{children:["Defines the precedence of sequence values over input for an identity column ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:".isGeometry()"})}),(0,l.jsxs)(n.td,{children:["Set spatial column type to ",(0,l.jsx)(n.code,{children:"geometry"})," - the default type is ",(0,l.jsx)(n.code,{children:"geography"})," ",(0,l.jsx)("small",{children:"(PostgreSQL)"}),"."]})]})]})]}),"\n",(0,l.jsx)(n.h4,{id:"default-expressions",children:"Default Expressions"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"defaultValue"})," modifier accepts a value or an ",(0,l.jsx)(n.code,{children:"Orm::Query::Expression"})," instance. Using an ",(0,l.jsx)(n.code,{children:"Expression"})," instance will prevent TinyORM from wrapping the value in quotes and allow you to use database-specific functions. One situation where this is particularly useful is when you need to assign default values to JSON columns:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Query::Expression;\n\nSchema::create("flights", [](Blueprint &table)\n{\n table.id();\n table.json("detail").defaultValue(Expression("(JSON_ARRAY(\'none\'))"));\n table.timestamps();\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"note",children:(0,l.jsx)(n.p,{children:"Support for default expressions depends on your database driver, database version, and the field type. Please refer to your database's documentation."})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["You can obtain an ",(0,l.jsx)(n.code,{children:"Orm::Query::Expression"})," using the ",(0,l.jsx)(n.a,{href:"/database/query-builder#raw-expressions",children:(0,l.jsx)(n.code,{children:"DB::raw"})})," method if you have access to the ",(0,l.jsx)(n.code,{children:"DB"})," facade."]})}),"\n",(0,l.jsx)(n.h4,{id:"column-order",children:"Column Order"}),"\n",(0,l.jsxs)(n.p,{children:["When using the MySQL database, the ",(0,l.jsx)(n.code,{children:"after"})," method may be used to add columns after an existing column in the schema:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.after("password", [](Blueprint &table)\n{\n table.string("address_line1");\n table.string("address_line2");\n table.string("city");\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"modifying-columns",children:"Modifying Columns"}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"change"})," method allows you to modify the type and attributes of existing columns. For example, you may wish to increase the size of a ",(0,l.jsx)(n.code,{children:"string"})," column. To see the ",(0,l.jsx)(n.code,{children:"change"})," method in action, let's increase the size of the ",(0,l.jsx)(n.code,{children:"name"})," column from 25 to 50. To accomplish this, we simply define the new state of the column and then call the ",(0,l.jsx)(n.code,{children:"change"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("name", 50).change();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["When modifying a column, you must explicitly include all of the modifiers you want to keep on the column definition - any missing attribute will be dropped. For example, to retain the ",(0,l.jsx)(n.code,{children:"unsigned"}),", ",(0,l.jsx)(n.code,{children:"default"}),", and ",(0,l.jsx)(n.code,{children:"comment"})," attributes, you must call each modifier explicitly when changing the column:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.integer("votes").isUnsigned().defaultValue(1).comment("my comment").change();\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"info",children:(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"change"})," method and modifying columns is not implemented for the ",(0,l.jsx)(n.code,{children:"SQLite"})," database because it doesn't support modifying columns out of the box."]})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-columns",children:"Renaming Columns"}),"\n",(0,l.jsxs)(n.p,{children:["To rename a column, you may use the ",(0,l.jsx)(n.code,{children:"renameColumn"})," method provided by the schema builder blueprint:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.renameColumn("from", "to");\n});\n'})}),"\n",(0,l.jsx)(n.h4,{id:"renaming-columns-on-legacy-databases",children:"Renaming Columns On Legacy Databases"}),"\n",(0,l.jsx)(n.p,{children:"Renaming columns is not supported if you are running a database installation older than one of the following releases:"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["MySQL ",(0,l.jsx)(n.code,{children:"<8.0.3"})]}),"\n",(0,l.jsxs)(n.li,{children:["MariaDB ",(0,l.jsx)(n.code,{children:"<10.5.2"})]}),"\n",(0,l.jsxs)(n.li,{children:["SQLite ",(0,l.jsx)(n.code,{children:"<3.25.0"})]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"dropping-columns",children:"Dropping Columns"}),"\n",(0,l.jsxs)(n.p,{children:["To drop a column, you may use the ",(0,l.jsx)(n.code,{children:"dropColumn"})," method on the schema builder blueprint:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.dropColumn("votes");\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["You may drop multiple columns from a table by passing a ",(0,l.jsx)(n.code,{children:"QList"})," of column names to the ",(0,l.jsx)(n.code,{children:"dropColumns"})," method, the ",(0,l.jsx)(n.code,{children:"dropColumns"})," method also provides parameter pack overload:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("users", [](Blueprint &table)\n{\n table.dropColumns({"votes", "avatar", "location"});\n // Parameter pack overload\n table.dropColumns("votes", "avatar", "location");\n});\n'})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The SQLite prior to ",(0,l.jsx)(n.code,{children:"v3.35.0"})," doesn't support dropping columns using the ",(0,l.jsx)(n.code,{children:"ALTER TABLE DROP COLUMN"}),", dropping columns was added in the SQLite ",(0,l.jsx)(n.code,{children:"v3.35.0"})," as is described in the ",(0,l.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_35_0.html",children:"release notes"}),"."]})}),"\n",(0,l.jsx)(n.h4,{id:"available-command-aliases",children:"Available Command Aliases"}),"\n",(0,l.jsx)(n.p,{children:"TinyORM provides several convenient methods related to dropping common types of columns. Each of these methods is described in the table below:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropRememberToken();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"remember_token"})," column."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletes();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"deleted_at"})," column."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletesDatetime();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropSoftDeletes()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropSoftDeletesTz();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropSoftDeletes()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropTimestamps();"})}),(0,l.jsxs)(n.td,{children:["Drop the ",(0,l.jsx)(n.code,{children:"created_at"})," and ",(0,l.jsx)(n.code,{children:"updated_at"})," columns."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropTimestampsTz();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropTimestamps()"})," method."]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.dropDatetimes();"})}),(0,l.jsxs)(n.td,{children:["Alias of ",(0,l.jsx)(n.code,{children:"dropTimestamps()"})," method."]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"indexes",children:"Indexes"}),"\n",(0,l.jsx)(n.h3,{id:"creating-indexes",children:"Creating Indexes"}),"\n",(0,l.jsxs)(n.p,{children:["The TinyORM schema builder supports several types of indexes. The following example creates a new ",(0,l.jsx)(n.code,{children:"email"})," column and specifies that its values should be unique. To create the index, we can chain the ",(0,l.jsx)(n.code,{children:"unique"})," method onto the column definition:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nSchema::table("users", [](Blueprint &table)\n{\n table.string("email").unique();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Alternatively, you may create the index after defining the column. To do so, you should call the ",(0,l.jsx)(n.code,{children:"unique"})," method on the schema builder blueprint. This method accepts the name of the column that should receive a unique index:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unique("email");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["You may even pass a ",(0,l.jsx)(n.code,{children:"QList"})," of columns to an index method to create a compound (or composite) index:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.index({"account_id", "created_at"});\n'})}),"\n",(0,l.jsx)(n.p,{children:"When creating an index, TinyORM will automatically generate an index name based on the table, column names, and the index type (eg. users_email_unique), but you may pass a second argument to the method to specify the index name yourself:"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.unique("email", "unique_email");\n'})}),"\n",(0,l.jsx)(n.h4,{id:"available-index-types",children:"Available Index Types"}),"\n",(0,l.jsx)(n.p,{children:"TinyORM's schema builder blueprint class provides methods for creating each type of index supported by TinyORM. Each index method accepts an optional second argument to specify the name of the index. If omitted, the name will be derived from the names of the table and column(s) used for the index, as well as the index type (eg. users_email_fulltext). Each of the available index methods is described in the table below:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.primary("id");'})}),(0,l.jsx)(n.td,{children:"Adds a primary key."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.primary({"id", "parent_id"});'})}),(0,l.jsx)(n.td,{children:"Adds composite keys."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.unique("email");'})}),(0,l.jsx)(n.td,{children:"Adds a unique index."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.index("state");'})}),(0,l.jsx)(n.td,{children:"Adds an index."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.fullText("body");'})}),(0,l.jsx)(n.td,{children:"Adds a full text index (MySQL/PostgreSQL)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'table.fullText("body").language("english");'})})}),(0,l.jsx)(n.td,{children:"Adds a full text index of the specified language (PostgreSQL)."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.spatialIndex("location");'})}),(0,l.jsx)(n.td,{children:"Adds a spatial index (except SQLite)."})]})]})]}),"\n",(0,l.jsx)(n.h4,{id:"index-lengths--mysql--mariadb",children:"Index Lengths & MySQL / MariaDB"}),"\n",(0,l.jsxs)(n.p,{children:["By default, TinyORM uses the ",(0,l.jsx)(n.code,{children:"utf8mb4"})," character set. If you are running a version of MySQL older than the 5.7.7 release or MariaDB older than the 10.2.2 release, you may need to manually configure the default string length generated by migrations in order for MySQL to create indexes for them. You may configure the default string length by calling the ",(0,l.jsx)(n.code,{children:"Schema::defaultStringLength"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"#include \n\nSchema::defaultStringLength(191);\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"tip",children:(0,l.jsxs)(n.p,{children:["Alternatively, you may enable the ",(0,l.jsx)(n.code,{children:"innodb_large_prefix"})," option for your database (enabled by default in >=MySQL 5.7.7). Refer to your database's documentation for instructions on how to properly enable this option."]})}),"\n",(0,l.jsx)(n.h3,{id:"renaming-indexes",children:"Renaming Indexes"}),"\n",(0,l.jsxs)(n.p,{children:["To rename an index, you may use the ",(0,l.jsx)(n.code,{children:"renameIndex"})," method provided by the schema builder blueprint. This method accepts the current index name as its first argument and the desired name as its second argument:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.renameIndex("from", "to");\n'})}),"\n",(0,l.jsx)(n.h3,{id:"dropping-indexes",children:"Dropping Indexes"}),"\n",(0,l.jsx)(n.p,{children:"To drop an index, you must specify the index's name. By default, TinyORM automatically assigns an index name based on the table name, the name of the indexed column, and the index type (eg. users_email_unique). Here are some examples:"}),"\n",(0,l.jsx)("div",{id:"apitable-dropping-indexes",children:(0,l.jsx)(d.A,{children:(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Command"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropPrimary("users_id_primary");'})}),(0,l.jsx)(n.td,{children:'Drop a primary key from the "users" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropUnique("users_email_unique");'})}),(0,l.jsx)(n.td,{children:'Drop a unique index from the "users" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:'table.dropIndex("geo_state_index");'})}),(0,l.jsx)(n.td,{children:'Drop a basic index from the "geo" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'table.dropFullText("posts_body_fulltext");'})})}),(0,l.jsx)(n.td,{children:'Drop a full text index from the "posts" table.'})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)("small",{children:(0,l.jsx)(n.code,{children:'.dropSpatialIndex("geo_location_spatialindex");'})})}),(0,l.jsx)(n.td,{children:'Drop a spatial index from the "geo" table (except SQLite).'})]})]})]})})}),"\n",(0,l.jsxs)(n.p,{children:["I may also drop indexes by a column name or column names for composite keys, if you pass a ",(0,l.jsx)(n.code,{children:"QList"})," of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns, and index type:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("geo", [](Blueprint &table)\n{\n table.dropIndex({"state"}); // Drops index \'geo_state_index\'\n});\n'})}),"\n",(0,l.jsx)(n.h3,{id:"foreign-key-constraints",children:"Foreign Key Constraints"}),"\n",(0,l.jsxs)(n.p,{children:["TinyORM also provides support for creating foreign key constraints, which are used to force referential integrity at the database level. For example, let's define a ",(0,l.jsx)(n.code,{children:"user_id"})," column on the ",(0,l.jsx)(n.code,{children:"posts"})," table that references the ",(0,l.jsx)(n.code,{children:"id"})," column on a ",(0,l.jsx)(n.code,{children:"users"})," table:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Constants::ID;\n\nSchema::table("posts", [](Blueprint &table)\n{\n table.unsignedBigInteger("user_id");\n\n table.foreign("user_id").references(ID).on("users");\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Since this syntax is rather verbose, TinyORM provides additional, terser methods that use conventions to provide a better developer experience. When using the ",(0,l.jsx)(n.code,{children:"foreignId"})," method to create your column, the example above can be rewritten like so:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("posts", [](Blueprint &table)\n{\n table.foreignId("user_id").constrained();\n});\n'})}),"\n",(0,l.jsxs)(n.p,{children:["The ",(0,l.jsx)(n.code,{children:"foreignId"})," method creates an ",(0,l.jsx)(n.code,{children:"UNSIGNED BIGINT"})," equivalent column, while the ",(0,l.jsx)(n.code,{children:"constrained"})," method will use conventions to determine the table and column name being referenced. If your table name does not match TinyORM's conventions, you may specify the table name by passing it as an argument to the ",(0,l.jsx)(n.code,{children:"constrained"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'Schema::table("posts", [](Blueprint &table)\n{\n table.foreignId("user_id").constrained("users");\n});\n'})}),"\n",(0,l.jsx)(n.p,{children:'You may also specify the desired action for the "on delete" and "on update" properties of the constraint:'}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::SchemaNs::Constants::Cascade;\n\ntable.foreignId("user_id")\n .constrained()\n .onUpdate("cascade")\n .onDelete(Cascade);\n'})}),"\n",(0,l.jsx)(n.p,{children:"An alternative, expressive syntax is also provided for these actions:"}),"\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Method"}),(0,l.jsx)(n.th,{children:"Description"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.cascadeOnUpdate();"})}),(0,l.jsx)(n.td,{children:"Updates should cascade."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.restrictOnUpdate();"})}),(0,l.jsx)(n.td,{children:"Updates should be restricted."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.cascadeOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should cascade."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.restrictOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should be restricted."})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"table.nullOnDelete();"})}),(0,l.jsx)(n.td,{children:"Deletes should set the foreign key value to null."})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["Any additional ",(0,l.jsx)(n.a,{href:"#column-modifiers",children:"column modifiers"})," must be called before the ",(0,l.jsx)(n.code,{children:"constrained"})," method:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.foreignId("user_id")\n .nullable()\n .constrained();\n'})}),"\n",(0,l.jsx)(n.h4,{id:"dropping-foreign-keys",children:"Dropping Foreign Keys"}),"\n",(0,l.jsxs)(n.p,{children:["To drop a foreign key, you may use the ",(0,l.jsx)(n.code,{children:"dropForeign"}),' method, passing the name of the foreign key constraint to be deleted as an argument. Foreign key constraints use the same naming convention as indexes. In other words, the foreign key constraint name is based on the name of the table and the columns in the constraint, followed by a "_foreign" suffix:']}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.dropForeign("posts_user_id_foreign");\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Alternatively, you may pass a ",(0,l.jsx)(n.code,{children:"QList"})," containing the column name that holds the foreign key to the ",(0,l.jsx)(n.code,{children:"dropForeign"})," method. The ",(0,l.jsx)(n.code,{children:"QList"})," will be converted to a foreign key constraint name using TinyORM's constraint naming conventions:"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:'table.dropForeign({"user_id"});\n'})}),"\n",(0,l.jsx)(n.h4,{id:"toggling-foreign-key-constraints",children:"Toggling Foreign Key Constraints"}),"\n",(0,l.jsx)(n.p,{children:"You may enable or disable foreign key constraints within your migrations by using the following methods:"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cpp",children:"Schema::enableForeignKeyConstraints();\n\nSchema::disableForeignKeyConstraints();\n\nSchema::withoutForeignKeyConstraints([]\n{\n // Constraints disabled within this lambda expression...\n});\n"})}),"\n",(0,l.jsx)(n.admonition,{type:"warning",children:(0,l.jsxs)(n.p,{children:["The SQLite disables foreign key constraints by default. When using SQLite, make sure to ",(0,l.jsx)(n.a,{href:"/database/getting-started#sqlite-configuration",children:"enable foreign key support"})," in your database configuration before attempting to create them in your migrations. In addition, SQLite only supports creating foreign keys when creating tables and ",(0,l.jsx)(n.a,{href:"https://www.sqlite.org/omitted.html",children:"not when tables are altered"}),"."]})})]})}function b(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(g,{...e})}):g(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>d});i(6540);var l=i(4164);const t={tabItem:"tabItem_Ymn6"};var s=i(4848);function d(e){let{children:n,hidden:i,className:d}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,l.A)(t.tabItem,d),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>T});var l=i(6540),t=i(4164),s=i(3104),d=i(6347),a=i(205),o=i(7485),r=i(1682),c=i(679);function h(e){return l.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,l.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function m(e){const{values:n,children:i}=e;return(0,l.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:l,default:t}}=e;return{value:n,label:i,attributes:l,default:t}}))}(i);return function(e){const n=(0,r.X)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function u(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function x(e){let{queryString:n=!1,groupId:i}=e;const t=(0,d.W6)(),s=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,o.aZ)(s),(0,l.useCallback)((e=>{if(!s)return;const n=new URLSearchParams(t.location.search);n.set(s,e),t.replace({...t.location,search:n.toString()})}),[s,t])]}function p(e){const{defaultValue:n,queryString:i=!1,groupId:t}=e,s=m(e),[d,o]=(0,l.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!u({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const l=i.find((e=>e.default))??i[0];if(!l)throw new Error("Unexpected error: 0 tabValues");return l.value}({defaultValue:n,tabValues:s}))),[r,h]=x({queryString:i,groupId:t}),[p,j]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[t,s]=(0,c.Dv)(i);return[t,(0,l.useCallback)((e=>{i&&s.set(e)}),[i,s])]}({groupId:t}),g=(()=>{const e=r??p;return u({value:e,tabValues:s})?e:null})();(0,a.A)((()=>{g&&o(g)}),[g]);return{selectedValue:d,selectValue:(0,l.useCallback)((e=>{if(!u({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);o(e),h(e),j(e)}),[h,j,s]),tabValues:s}}var j=i(2303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=i(4848);function f(e){let{className:n,block:i,selectedValue:l,selectValue:d,tabValues:a}=e;const o=[],{blockElementScrollPositionUntilNextRender:r}=(0,s.a_)(),c=e=>{const n=e.currentTarget,i=o.indexOf(n),t=a[i].value;t!==l&&(r(n),d(t))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const i=o.indexOf(e.currentTarget)+1;n=o[i]??o[0];break}case"ArrowLeft":{const i=o.indexOf(e.currentTarget)-1;n=o[i]??o[o.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":i},n),children:a.map((e=>{let{value:n,label:i,attributes:s}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:l===n?0:-1,"aria-selected":l===n,ref:e=>o.push(e),onKeyDown:h,onClick:c,...s,className:(0,t.A)("tabs__item",g.tabItem,s?.className,{"tabs__item--active":l===n}),children:i??n},n)}))})}function y(e){let{lazy:n,children:i,selectedValue:t}=e;const s=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=s.find((e=>e.props.value===t));return e?(0,l.cloneElement)(e,{className:"margin-top--md"}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:s.map(((e,n)=>(0,l.cloneElement)(e,{key:n,hidden:e.props.value!==t})))})}function v(e){const n=p(e);return(0,b.jsxs)("div",{className:(0,t.A)("tabs-container",g.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(y,{...n,...e})]})}function T(e){const n=(0,j.A)();return(0,b.jsx)(v,{...e,children:h(e.children)},String(n))}},6684:(e,n,i)=>{i.d(n,{A:()=>c});var l=i(6540),t=i(3427),s=i(6347);const d={apiTable:"apiTable_flxF"};var a=i(4848);function o(e,n){let{name:i,children:d}=e;const o=function(e){let n=e;for(;(0,l.isValidElement)(n);)[n]=l.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(d),r=i?`${i}-${o}`:o,c=`#${r}`,h=(0,s.W6)();return(0,t.A)().collectAnchor(r),(0,a.jsx)("tr",{id:r,tabIndex:0,ref:h.location.hash===c?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||h.push(c)},onKeyDown:e=>{"Enter"===e.key&&h.push(c)},children:d.props.children})}const r=l.forwardRef(o);function c(e){let{children:n,name:i}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[t,s]=l.Children.toArray(n.props.children),o=(0,l.useRef)(null);(0,l.useEffect)((()=>{o.current?.focus()}),[o]);const c=l.Children.map(s.props.children,(e=>(0,a.jsx)(r,{name:i,ref:o,children:e})));return(0,a.jsxs)("table",{className:d.apiTable,children:[t,(0,a.jsx)("tbody",{children:c})]})}},7324:(e,n,i)=>{i.d(n,{$E:()=>j,A3:()=>b,CW:()=>g,Dx:()=>c,F4:()=>m,Fi:()=>r,J_:()=>T,LQ:()=>f,Lf:()=>I,OO:()=>t,Q7:()=>y,b:()=>a,cy:()=>o,gg:()=>x,kl:()=>u,os:()=>h,pW:()=>s,ux:()=>p,vf:()=>l,xj:()=>d,xt:()=>v});const l="shell",t="database",s="application",d="bash",a="pwsh",o="zsh",r="maria",c="mysql",h="postgres",m="sqlite",u="application",x="bash",p="pwsh",j="zsh",g="MariaDB",b="MySQL",f="PostgreSQL",y="SQLite",v="tinyorm.org",T="$HOME/Code/c/",I="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>s});var l=i(6540),t=i(1838);function s(){const e=(0,l.useContext)(t.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>o,Sn:()=>d,T3:()=>c,bw:()=>r,nC:()=>h,np:()=>a});var l=i(6362),t=i(2303),s=i(7324);const d=function(e,n){return void 0===n&&(n=!0),m((0,l.A)().rootFolder[e]??r(e),e,n)},a=()=>(0,l.A)().rootFolder[s.pW]??r(s.pW),o=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==s.b?"/":"\\";return m(d(e)+i+a(),e,n)};function r(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,t.A)())return"";switch(e){case s.b:return s.Lf;case s.xj:return s.J_;case s.pW:return s.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===s.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case s.b:return x(n).replace(/\$env:(.+?)(\/.*)/,i);case s.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function m(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==s.b)return u(e);const l=u(e);return i?x(l):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(l)}function u(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function x(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},5848:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/tom_cli-402f7dd4dfe7dbd0b20dfe5fb61838a2.png"}}]); \ No newline at end of file diff --git a/assets/js/237.d109f2ba.js b/assets/js/237.da9a0891.js similarity index 95% rename from assets/js/237.d109f2ba.js rename to assets/js/237.da9a0891.js index 28eec7750..1f0c64ed3 100644 --- a/assets/js/237.d109f2ba.js +++ b/assets/js/237.da9a0891.js @@ -1 +1 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[237],{3363:(e,t,n)=>{n.d(t,{A:()=>a});n(6540);var i=n(4164),o=n(1312),r=n(1107),s=n(4848);function a(e){let{className:t}=e;return(0,s.jsx)("main",{className:(0,i.A)("container margin-vert--xl",t),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(r.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},2237:(e,t,n)=>{n.r(t),n.d(t,{default:()=>l});n(6540);var i=n(1312),o=n(9024),r=n(9201),s=n(3363),a=n(4848);function l(){const e=(0,i.T)({id:"theme.NotFound.title",message:"Page Not Found"});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.be,{title:e}),(0,a.jsx)(r.A,{children:(0,a.jsx)(s.A,{})})]})}}}]); \ No newline at end of file +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[237],{3363:(e,t,n)=>{n.d(t,{A:()=>a});n(6540);var i=n(4164),o=n(1312),r=n(1107),s=n(4848);function a(e){let{className:t}=e;return(0,s.jsx)("main",{className:(0,i.A)("container margin-vert--xl",t),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(r.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},2237:(e,t,n)=>{n.r(t),n.d(t,{default:()=>l});n(6540);var i=n(1312),o=n(9024),r=n(1957),s=n(3363),a=n(4848);function l(){const e=(0,i.T)({id:"theme.NotFound.title",message:"Page Not Found"});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.be,{title:e}),(0,a.jsx)(r.A,{children:(0,a.jsx)(s.A,{})})]})}}}]); \ No newline at end of file diff --git a/assets/js/3dd307b5.b96ad197.js b/assets/js/3dd307b5.b96ad197.js new file mode 100644 index 000000000..3c8c3f680 --- /dev/null +++ b/assets/js/3dd307b5.b96ad197.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[117],{4251:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>l,metadata:()=>d,toc:()=>a});var s=t(4848),o=t(8453),r=t(8774);const l={sidebar_position:2,sidebar_label:"Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",keywords:["c++ orm","orm","collections","collection","model","tinyorm"]},i="TinyORM: Collections",d={id:"tinyorm/collections",title:"TinyORM: Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",source:"@site/docs/tinyorm/collections.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/collections",permalink:"/tinyorm/collections",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",keywords:["c++ orm","orm","collections","collection","model","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Relationships",permalink:"/tinyorm/relationships"},next:{title:"Casts",permalink:"/tinyorm/casts"}},c={},a=[{value:"Introduction",id:"introduction",level:2},{value:"Collection Conversion",id:"collection-conversion",level:4},{value:"Creating Collections",id:"creating-collections",level:3},{value:"Available Methods",id:"available-methods",level:2},{value:"all()",id:"method-all",level:4},{value:"contains()",id:"method-contains",level:4},{value:"doesntContain()",id:"method-doesntcontain",level:4},{value:"each()",id:"method-each",level:4},{value:"except()",id:"method-except",level:4},{value:"filter()",id:"method-filter",level:4},{value:"find()",id:"method-find",level:4},{value:"first()",id:"method-first",level:4},{value:"firstWhere()",id:"method-first-where",level:4},{value:"fresh()",id:"method-fresh",level:4},{value:"implode()",id:"method-implode",level:4},{value:"isEmpty()",id:"method-isempty",level:4},{value:"isNotEmpty()",id:"method-isnotempty",level:4},{value:"last()",id:"method-last",level:4},{value:"load()",id:"method-load",level:4},{value:"map()",id:"method-map",level:4},{value:"mapWithKeys()",id:"method-mapwithkeys",level:4},{value:"mapWithModelKeys()",id:"method-mapwithmodelkeys",level:4},{value:"modelKeys()",id:"method-modelkeys",level:4},{value:"only()",id:"method-only",level:4},{value:"pluck()",id:"method-pluck",level:4},{value:"reject()",id:"method-reject",level:4},{value:"sort()",id:"method-sort",level:4},{value:"sortBy()",id:"method-sortby",level:4},{value:"sortByDesc()",id:"method-sortbydesc",level:4},{value:"sortDesc()",id:"method-sortdesc",level:4},{value:"stableSort()",id:"method-stablesort",level:4},{value:"stableSortBy()",id:"method-stablesortby",level:4},{value:"stableSortByDesc()",id:"method-stablesortbydesc",level:4},{value:"stableSortDesc()",id:"method-stablesortdesc",level:4},{value:"tap()",id:"method-tap",level:4},{value:"toBase()",id:"method-tobase",level:4},{value:"toJson()",id:"method-tojson",level:4},{value:"toJsonArray()",id:"method-tojsonarray",level:4},{value:"toJsonDocument()",id:"method-tojsondocument",level:4},{value:"toMap()",id:"method-tomap",level:4},{value:"toMapVariantList()",id:"method-tomapvariantlist",level:4},{value:"toQuery()",id:"method-toquery",level:4},{value:"toList()",id:"method-tolist",level:4},{value:"toListVariantList()",id:"method-tolistvariantlist",level:4},{value:"unique()",id:"method-unique",level:4},{value:"uniqueBy()",id:"method-uniqueby",level:4},{value:"uniqueRelaxed()",id:"method-uniquerelaxed",level:4},{value:"uniqueRelaxedBy()",id:"method-uniquerelaxedby",level:4},{value:"value()",id:"method-value",level:4},{value:"where()",id:"method-where",level:4},{value:"whereBetween()",id:"method-wherebetween",level:4},{value:"whereIn()",id:"method-wherein",level:4},{value:"whereNotBetween()",id:"method-wherenotbetween",level:4},{value:"whereNotIn()",id:"method-wherenotin",level:4},{value:"whereNotNull()",id:"method-wherenotnull",level:4},{value:"whereNull()",id:"method-wherenull",level:4}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"tinyorm-collections",children:"TinyORM: Collections"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#creating-collections",children:"Creating Collections"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#available-methods",children:"Available Methods"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(r.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Types::ModelsCollection"})," is specialized container which provides a fluent, convenient wrapper for working with vector of models. All TinyORM methods that return more than one model result, will return instances of the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class, including results retrieved via the ",(0,s.jsx)(n.code,{children:"get"})," method or methods that return relationships like the ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class extends ",(0,s.jsx)(n.code,{children:"QList"}),", so it naturally inherits dozens of methods used to work with the underlying vector of TinyORM models. Be sure to review the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html",children:(0,s.jsx)(n.code,{children:"QList"})})," documentation to learn all about these helpful methods!"]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," template parameter can be declared only with the model type or a model type pointer, it also can't be ",(0,s.jsx)(n.code,{children:"const"})," and can't be a reference. It's constrained using the ",(0,s.jsx)(n.code,{children:"DerivedCollectionModel"})," concept."]})}),"\n",(0,s.jsxs)(n.p,{children:["You can iterate over the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," the same way as over the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nModelsCollection users = User::whereEq("active", true)->get();\n\nfor (const auto &user : users)\n qDebug() << user.getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"However, as previously mentioned, collections are much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. For example, we may remove all active users and then gather the first name of each remaining user:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto names = User::all().reject([](User *const user)\n{\n return user->getAttribute("active");\n})\n .pluck("name");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As you can see, the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class allows you to chain its methods to perform fluent mapping and reducing of the underlying vector. In general, collections are immutable, meaning every ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," method returns an entirely new ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instance."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is returning from the Models' methods like ",(0,s.jsx)(n.code,{children:"get"}),", ",(0,s.jsx)(n.code,{children:"all"}),", ",(0,s.jsx)(n.code,{children:"findMany"}),", ",(0,s.jsx)(n.code,{children:"chunk"}),"; the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is returning from the relationship-related methods as ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"collection-conversion",children:"Collection Conversion"}),"\n",(0,s.jsxs)(n.p,{children:["While most TinyORM collection methods return a new instance of ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),", the ",(0,s.jsx)(n.code,{children:"modelKeys"}),", ",(0,s.jsx)(n.code,{children:"mapWithKeys"}),", and ",(0,s.jsx)(n.code,{children:"pluck"})," methods return a base QList or std unordered/map instances. Likewise, one of the ",(0,s.jsx)(n.code,{children:"map"})," methods overload returns the ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"creating-collections",children:"Creating Collections"}),"\n",(0,s.jsxs)(n.p,{children:["Creating a ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is as simple as:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You can also create a collection of pointers, eg. ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection userPointers {\n &users[0], &users[1],\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is implicitly convertible and assignable from the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'QList usersVector {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n};\n\nModelsCollection users(usersVector);\nusers = usersVector;\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Alternatively, you can use the ",(0,s.jsx)(n.code,{children:"Orm::collect"})," helper function to create a ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," from the given attributes:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = Orm::collect({\n {{"name", "Kate"}, {"added_on", QDateTime::currentDateTimeUtc()}},\n {{"name", "John"}, {"added_on", QDateTime({2023, 6, 1}, {13, 46, 15}, QTimeZone::UTC)}},\n});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Orm::collect"})," function is ",(0,s.jsx)(n.strong,{children:"mandatory"})," if your attributes contain the ",(0,s.jsx)(n.code,{children:"QDateTime"})," instance, you can read more about this problem ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#qdatetime-and-connection-name-problem",children:"here"}),"."]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The results of ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"})," queries are always returned as ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instances."]})}),"\n",(0,s.jsx)(n.h2,{id:"available-methods",children:"Available Methods"}),"\n",(0,s.jsxs)(n.p,{children:["For the majority of the remaining collection documentation, we'll discuss each method available on the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class. Remember, all of these methods may be chained to fluently manipulate the underlying vector."]}),"\n",(0,s.jsxs)(n.p,{children:["Furthermore, almost every method returns a new ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instance, allowing you to preserve the original copy of the collection when necessary:"]}),"\n",(0,s.jsx)("div",{className:"collection-methods-list",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"#method-all",children:"all"}),"\n",(0,s.jsx)(n.a,{href:"#method-contains",children:"contains"}),"\n",(0,s.jsx)(n.a,{href:"#method-doesntcontain",children:"doesntContain"}),"\n",(0,s.jsx)(n.a,{href:"#method-each",children:"each"}),"\n",(0,s.jsx)(n.a,{href:"#method-except",children:"except"}),"\n",(0,s.jsx)(n.a,{href:"#method-filter",children:"filter"}),"\n",(0,s.jsx)(n.a,{href:"#method-find",children:"find"}),"\n",(0,s.jsx)(n.a,{href:"#method-first",children:"first"}),"\n",(0,s.jsx)(n.a,{href:"#method-first-where",children:"firstWhere"}),"\n",(0,s.jsx)(n.a,{href:"#method-fresh",children:"fresh"}),"\n",(0,s.jsx)(n.a,{href:"#method-implode",children:"implode"}),"\n",(0,s.jsx)(n.a,{href:"#method-isempty",children:"isEmpty"}),"\n",(0,s.jsx)(n.a,{href:"#method-isnotempty",children:"isNotEmpty"}),"\n",(0,s.jsx)(n.a,{href:"#method-last",children:"last"}),"\n",(0,s.jsx)(n.a,{href:"#method-load",children:"load"}),"\n",(0,s.jsx)(n.a,{href:"#method-map",children:"map"}),"\n",(0,s.jsx)(n.a,{href:"#method-mapwithkeys",children:"mapWithKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-mapwithmodelkeys",children:"mapWithModelKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-modelkeys",children:"modelKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-only",children:"only"}),"\n",(0,s.jsx)(n.a,{href:"#method-pluck",children:"pluck"}),"\n",(0,s.jsx)(n.a,{href:"#method-reject",children:"reject"}),"\n",(0,s.jsx)(n.a,{href:"#method-sort",children:"sort"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortby",children:"sortBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortbydesc",children:"sortByDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortdesc",children:"sortDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesort",children:"stableSort"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortby",children:"stableSortBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortbydesc",children:"stableSortByDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortdesc",children:"stableSortDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-tap",children:"tap"}),"\n",(0,s.jsx)(n.a,{href:"#method-tobase",children:"toBase"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojson",children:"toJson"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojsonarray",children:"toJsonArray"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojsondocument",children:"toJsonDocument"}),"\n",(0,s.jsx)(n.a,{href:"#method-tomap",children:"toMap"}),"\n",(0,s.jsx)(n.a,{href:"#method-tomapvariantlist",children:"toMapVariantList"}),"\n",(0,s.jsx)(n.a,{href:"#method-toquery",children:"toQuery"}),"\n",(0,s.jsx)(n.a,{href:"#method-tolist",children:"toList"}),"\n",(0,s.jsx)(n.a,{href:"#method-tolistvariantlist",children:"toListVariantList"}),"\n",(0,s.jsx)(n.a,{href:"#method-unique",children:"unique"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniqueby",children:"uniqueBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniquerelaxed",children:"uniqueRelaxed"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniquerelaxedby",children:"uniqueRelaxedBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-value",children:"value"}),"\n",(0,s.jsx)(n.a,{href:"#method-where",children:"where"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherebetween",children:"whereBetween"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherein",children:"whereIn"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotbetween",children:"whereNotBetween"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotin",children:"whereNotIn"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotnull",children:"whereNotNull"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenull",children:"whereNull"})]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["For a better understanding of the following examples, many of the variable declarations below use actual types instead of the ",(0,s.jsx)(n.code,{children:"auto"})," keyword."]})}),"\n",(0,s.jsxs)("div",{className:"collection-methods",children:[(0,s.jsx)(n.h4,{id:"method-all",children:(0,s.jsx)(n.code,{children:"all()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"all"})," method returns a copy of the underlying vector represented by the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"QList = users.all();\n"})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#method-tobase",children:(0,s.jsx)(n.code,{children:"toBase"})})," is an alias to the ",(0,s.jsx)(n.code,{children:"all"})," method."]})}),(0,s.jsx)(n.h4,{id:"method-contains",children:(0,s.jsx)(n.code,{children:"contains()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"contains"})," method may be used to determine if a given model instance is contained by the collection. This method accepts a primary key or a model instance:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.contains(1);\n\nusers.contains(User::find(1));\n"})}),(0,s.jsxs)(n.p,{children:["Alternatively, you may pass a lambda expression to the ",(0,s.jsx)(n.code,{children:"contains"})," method to determine if a model exists in the collection matching a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.contains([](const User *const user)\n{\n return user->getKeyCasted() == 2;\n});\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"contains"}),", see the ",(0,s.jsx)(n.a,{href:"#method-doesntcontain",children:"doesntContain"})," method."]}),(0,s.jsx)(n.h4,{id:"method-doesntcontain",children:(0,s.jsx)(n.code,{children:"doesntContain()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"doesntContain"})," method determines whether the collection does not contain a given item. This method accepts a primary key or a model instance:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.doesntContain(1);\n\nusers.doesntContain(User::find(1));\n"})}),(0,s.jsxs)(n.p,{children:["Alternatively, you may pass a lambda expression to the ",(0,s.jsx)(n.code,{children:"doesntContain"})," method to determine if a model does not exist in the collection matching a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.doesntContain([](const User *const user)\n{\n return user->getKeyCasted() == 2;\n});\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"doesntContain"}),", see the ",(0,s.jsx)(n.a,{href:"#method-contains",children:"contains"})," method."]}),(0,s.jsx)(n.h4,{id:"method-each",children:(0,s.jsx)(n.code,{children:"each()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"each"})," method iterates over the models in the collection and passes each model to the lambda expression:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = Post::whereEq("user_id", 1)->get();\n\nusers.each([](User *const user)\n{\n // ...\n});\n'})}),(0,s.jsxs)(n.p,{children:["If you would like to stop iterating through the models, you may return ",(0,s.jsx)(n.code,{children:"false"})," from your lambda expression:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.each([](User *const user)\n{\n if (/* condition */)\n return false;\n\n // Some logic\n\n return true;\n});\n"})}),(0,s.jsx)(n.p,{children:"You may also pass the lambda expression with two parameters, whereas the second one is an index:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.each([](User *const user, const std::size_t index)\n{\n // ...\n});\n"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"each"})," method returns an lvalue ",(0,s.jsx)(n.strong,{children:"reference"})," to the currently processed collection."]}),(0,s.jsxs)(n.p,{children:["It can be also called on ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," rvalues, it returns an rvalue reference in this case."]}),(0,s.jsx)(n.h4,{id:"method-except",children:(0,s.jsx)(n.code,{children:"except()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"except"})," method returns all of the models that do not have the given primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersResult = users.except({1, 2, 3});\n"})}),(0,s.jsxs)(n.p,{children:["All of the models are returned if the ",(0,s.jsx)(n.code,{children:"ids"})," argument is empty ",(0,s.jsx)(n.code,{children:"except({})"}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"except"}),", see the ",(0,s.jsx)(n.a,{href:"#method-only",children:"only"})," method."]}),(0,s.jsx)(n.h4,{id:"method-filter",children:(0,s.jsx)(n.code,{children:"filter()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"filter"})," method filters the collection using the lambda expression, keeping only those models that pass a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersBanned = users.filter([](const User *const user)\n{\n return user->getAttribute("is_banned");\n});\n'})}),(0,s.jsx)(n.p,{children:"You may also pass the lambda expression with two parameters, whereas the second one is an index:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersBanned = users.filter([](const User *const user,\n const std::size_t index)\n{\n return index < 10 && user->getAttribute("is_banned");\n});\n'})}),(0,s.jsxs)(n.p,{children:["If no lambda expression is supplied, all models of the collection that are equivalent to the ",(0,s.jsx)(n.code,{children:"nullptr"})," will be removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersRaw = User::findMany({1, 2});\nModelsCollection users {&usersRaw[0], nullptr, &usersRaw[1]};\n\nModelsCollection filtered = users.filter();\n\n// {1, 2}\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"filter"}),", see the ",(0,s.jsx)(n.a,{href:"#method-reject",children:"reject"})," method."]}),(0,s.jsx)(n.h4,{id:"method-find",children:(0,s.jsx)(n.code,{children:"find()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"find"})," method returns the model that has a primary key matching the given key:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"User *const user = users.find(1);\n"})}),(0,s.jsxs)(n.p,{children:["If you pass a model instance, ",(0,s.jsx)(n.code,{children:"find"})," will attempt to return a model matching the primary key:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"User *user = users.find(anotherUser);\n"})}),(0,s.jsxs)(n.p,{children:["The two overloads above also accept the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," model argument, which will be returned if a model was not found in the collection, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsxs)(n.p,{children:["Alternatively, may pass more IDs and ",(0,s.jsx)(n.code,{children:"find"})," will return all models which have a primary key within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersMany = users.find({1, 2});\n"})}),(0,s.jsxs)(n.p,{children:["This overload internally calls the ",(0,s.jsx)(n.a,{href:"#method-only",children:(0,s.jsx)(n.code,{children:"only"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-first",children:(0,s.jsx)(n.code,{children:"first()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"first"})," method returns the first model in the collection that passes a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nUser *user = users.first([](User *const user)\n{\n return user->getAttribute("votes") > 150;\n});\n\n// {{"name", "John"}, {"votes", 200}}\n'})}),(0,s.jsxs)(n.p,{children:["If no model passes a given truth test then the value of the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," argument will be returned, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nUser defaultUser {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}};\n\nUser *user = users.first([](User *const user)\n{\n return user->getAttribute("votes") > 500;\n},\n &defaultUser);\n\n/*\n {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}}\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"first"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#first",children:(0,s.jsx)(n.code,{children:"QList::first"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-first-where",children:(0,s.jsx)(n.code,{children:"firstWhere()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"firstWhere"})," method returns the first model in the collection with the given column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "Leon"}, {"age", NullVariant::UShort()}},\n {{"name", "Jill"}, {"age", 14}},\n {{"name", "Jack"}, {"age", 23}},\n {{"name", "Jill"}, {"age", 84}},\n};\n\nauto user = users.firstWhereEq("name", "Linda");\n\n// {{"name", "Jill"}, {"age", 14}}\n'})}),(0,s.jsxs)(n.p,{children:["You may also call the ",(0,s.jsx)(n.code,{children:"firstWhere"})," method with a comparison operator:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'users.firstWhere("age", ">=", 18);\n\n// {{"name", "Jack"}, {"age", 23}}\n'})}),(0,s.jsx)(n.h4,{id:"method-fresh",children:(0,s.jsx)(n.code,{children:"fresh()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"fresh"})," method retrieves a fresh instance of each model in the collection from the database. In addition, any specified relationships will be eager loaded:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersFresh = users.fresh();\n\nauto usersFresh = users.fresh("comments");\n\nauto usersFresh = users.fresh("posts:id,name");\n\nauto usersFresh = users.fresh({"comments", "posts:id,name"});\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"relations"})," argument format is the same as for TinyBuilder's ",(0,s.jsx)(n.a,{href:"/tinyorm/relationships#lazy-eager-loading",children:(0,s.jsx)(n.code,{children:"load"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-implode",children:(0,s.jsx)(n.code,{children:"implode()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"implode"}),' method joins attributes by the given column and the "glue" string you wish to place between the values:']}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n};\n\nproducts.implode("product", ", ");\n\n// {Desk, Chair}\n'})}),(0,s.jsx)(n.p,{children:'The default "glue" value is an empty string "".'}),(0,s.jsx)(n.h4,{id:"method-isempty",children:(0,s.jsx)(n.code,{children:"isEmpty()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"isEmpty"})," method returns ",(0,s.jsx)(n.code,{children:"true"})," if the collection is empty; otherwise, ",(0,s.jsx)(n.code,{children:"false"})," is returned:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection().isEmpty();\n\n// true\n"})}),(0,s.jsx)(n.h4,{id:"method-isnotempty",children:(0,s.jsx)(n.code,{children:"isNotEmpty()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"isNotEmpty"})," method returns ",(0,s.jsx)(n.code,{children:"true"})," if the collection is not empty; otherwise, ",(0,s.jsx)(n.code,{children:"false"})," is returned:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection().isNotEmpty();\n\n// false\n"})}),(0,s.jsx)(n.h4,{id:"method-last",children:(0,s.jsx)(n.code,{children:"last()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"last"})," method returns the last model in the collection that passes a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n {{"name", "Rose"}, {"votes", 350}},\n};\n\nUser *user = users.last([](User *const user)\n{\n return user->getAttribute("votes") < 300;\n});\n\n// {{"name", "John"}, {"votes", 200}}\n'})}),(0,s.jsxs)(n.p,{children:["If no model passes a given truth test then the value of the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," argument will be returned, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nUser defaultUser {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}};\n\nUser *user = users.last([](User *const user)\n{\n return user->getAttribute("votes") < 100;\n},\n &defaultUser);\n\n/*\n {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}}\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"last"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#last",children:(0,s.jsx)(n.code,{children:"QList::last"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-load",children:(0,s.jsx)(n.code,{children:"load()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"load"})," method eager loads the given relationships for all models in the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'users.load({"comments", "posts"});\n\nusers.load("comments.author");\n\nusers.load({{"comments"}, {"posts", [](auto &query)\n{\n query.whereEq("active", true);\n}}});\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"relations"})," argument format is the same as for TinyBuilder's ",(0,s.jsx)(n.a,{href:"/tinyorm/relationships#lazy-eager-loading",children:(0,s.jsx)(n.code,{children:"load"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-map",children:(0,s.jsx)(n.code,{children:"map()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"map"})," method iterates through the collection and passes a ",(0,s.jsx)(n.strong,{children:"copy"})," of each model to the given lambda expression. The lambda expression is free to modify the model and return it, thus forming a new collection of modified models:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nauto usersAdded = users.map([](User &&userCopy)\n{\n if (userCopy.getAttribute("name") == "John")\n userCopy["votes"] = userCopy.getAttribute("votes") + 1;\n\n return std::move(userCopy);\n});\n\n/*\n {\n {{"name", "John"}, {"price", 201}},\n {{"name", "Jack"}, {"price", 400}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["The second ",(0,s.jsx)(n.code,{children:"map"})," overload allows to return the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'QList usersAdded = users.map([](User &&userCopy)\n{\n const auto votesRef = userCopy["votes"];\n\n if (userCopy.getAttribute("name") == "John")\n votesRef = userCopy.getAttribute("votes") + 1;\n\n return votesRef->value();\n});\n\n// {201, 400}\n'})}),(0,s.jsxs)(n.p,{children:["Both overloads allow to pass the lambda expression with two arguments, whereas the second argument can be an index of the ",(0,s.jsx)(n.code,{children:"std::size_t"})," type."]}),(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsxs)(n.p,{children:["Like most other collection methods, ",(0,s.jsx)(n.code,{children:"map"})," returns a new collection instance; it does not modify the collection it is called on. If you want to modify the original collection in place, use the ",(0,s.jsx)(n.a,{href:"#method-each",children:(0,s.jsx)(n.code,{children:"each"})})," method."]})}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The model copy is passed to the lambda expression even if the ",(0,s.jsx)(n.code,{children:"map"})," iterates over a collection of model pointers ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),". The models are dereferenced behind the scene."]})}),(0,s.jsx)(n.h4,{id:"method-mapwithkeys",children:(0,s.jsx)(n.code,{children:"mapWithKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"mapWithKeys"})," method iterates through the collection and passes each model to the given lambda expression. It returns the ",(0,s.jsx)(n.code,{children:"std::unordered_map"})," and the lambda expression should return the ",(0,s.jsx)(n.code,{children:"std::pair"})," containing a single column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 1}, {"name", "John"}, {"email", "john@example.com"}},\n {{"id", 2}, {"name", "Jill"}, {"email", "jill@example.com"}},\n};\n\nauto usersMap = users.mapWithKeys(\n [](User *const user) -> std::pair\n{\n return {user->getKeyCasted(), user->getAttribute("name")};\n});\n\n// {{1, \'John\'}, {2, \'Jill\'}}\n'})}),(0,s.jsx)(n.p,{children:"You can also map IDs to the model pointers:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"auto usersMap = users.mapWithKeys(\n [](User *const user) -> std::pair\n{\n return {user->getKeyCasted(), user};\n});\n"})}),(0,s.jsx)(n.h4,{id:"method-mapwithmodelkeys",children:(0,s.jsx)(n.code,{children:"mapWithModelKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"mapWithModelKeys"})," maps the primary keys to the ",(0,s.jsx)(n.code,{children:"Model *"}),", it returns the ",(0,s.jsx)(n.code,{children:"std::unordered_map"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"auto usersMap = users.mapWithModelKeys();\n"})}),(0,s.jsx)(n.h4,{id:"method-modelkeys",children:(0,s.jsx)(n.code,{children:"modelKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"modelKeys"})," method returns the primary keys for all models in the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 1}, {"name", "John"}},\n {{"id", 2}, {"name", "Jill"}},\n {{"id", 3}, {"name", "Kate"}},\n {{"id", 5}, {"name", "Rose"}},\n};\n\nusers.modelKeys(); // Returns QList\nusers.modelKeys();\n\n// {1, 2, 3, 5}\n'})}),(0,s.jsx)(n.h4,{id:"method-only",children:(0,s.jsx)(n.code,{children:"only()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"only"})," method returns all of the models that have the given primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersResult = users.only({1, 2, 3});\n"})}),(0,s.jsxs)(n.p,{children:["An empty collection is returned if the ",(0,s.jsx)(n.code,{children:"ids"})," argument is empty ",(0,s.jsx)(n.code,{children:"only({})"}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"only"}),", see the ",(0,s.jsx)(n.a,{href:"#method-except",children:"except"})," method."]}),(0,s.jsx)(n.h4,{id:"method-pluck",children:(0,s.jsx)(n.code,{children:"pluck()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"pluck"})," method retrieves all of the values for a given column, the following overload returns the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"id", 1}, {"name", "Desk"}},\n {{"id", 2}, {"name", "Chair"}},\n};\n\nauto plucked = products.pluck("name");\n\n// {Desk, Chair}\n'})}),(0,s.jsxs)(n.p,{children:["The second overload allows returning the custom type ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto plucked = products.pluck("name");\n'})}),(0,s.jsxs)(n.p,{children:["You may also specify how you wish the resulting collection to be keyed, this overload returns the ",(0,s.jsx)(n.code,{children:"std::map"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto plucked = products.pluck("name", "id");\n\n// {{1, "Desk"}, {2, "Chair"}}\n'})}),(0,s.jsx)(n.p,{children:"If duplicate keys exist, the last matching attribute will be inserted into the plucked collection:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection collection {\n {{"brand", "Tesla"}, {"color", "red"}},\n {{"brand", "Pagani"}, {"color", "white"}},\n {{"brand", "Tesla"}, {"color", "black"}},\n {{"brand", "Pagani"}, {"color", "orange"}},\n};\n\nauto plucked = collection.pluck("color", "brand");\n\n// {{\'Tesla\', \'black\'}, {\'Pagani\', \'orange"}}\n'})}),(0,s.jsx)(n.h4,{id:"method-reject",children:(0,s.jsx)(n.code,{children:"reject()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"reject"})," method filters the collection using the given lambda expression. The lambda should return ",(0,s.jsx)(n.code,{children:"true"})," if the model should be removed from the resulting collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersWithNote = users.reject([](const User *const user)\n{\n return user->getAttribute("note").isNull();\n});\n'})}),(0,s.jsxs)(n.p,{children:["You may also pass the lambda expression with two arguments, whereas the second argument can be an index of the ",(0,s.jsx)(n.code,{children:"std::size_t"})," type."]}),(0,s.jsxs)(n.p,{children:["For the inverse of the ",(0,s.jsx)(n.code,{children:"reject"})," method, see the ",(0,s.jsx)(n.a,{href:"#method-filter",children:(0,s.jsx)(n.code,{children:"filter"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-sort",children:(0,s.jsx)(n.code,{children:"sort()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"sort"})," method sorts the models collection by primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto sorted = users.sort();\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You may pass a predicate and projection callbacks to the ",(0,s.jsx)(n.code,{children:"sort"})," method with your own algorithms. Refer to the CPP reference documentation on ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/sort",children:(0,s.jsx)(n.code,{children:"ranges::sort"})}),", which is what the ",(0,s.jsx)(n.code,{children:"sort"})," method calls internally."]}),(0,s.jsxs)(n.p,{children:["You can eg. sort by multiple columns, for an alternative method of multi-column sorting look at ",(0,s.jsx)(n.a,{href:"#method-sortby",children:"sortBy"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 200}},\n};\n\nauto sorted = users.sort([](const User *const left,\n const User *const right)\n{\n const auto leftValue = left->getAttribute("name");\n const auto rightValue = right->getAttribute("name");\n\n if (leftValue == rightValue)\n return left->getAttribute("votes") <\n right->getAttribute("votes");\n\n return leftValue < rightValue;\n});\n\n/*\n {\n {{"name", "John"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 350}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsx)(n.a,{href:"#method-stablesort",children:"stable"})," sort method variants to preserve the order of equal models."]})}),(0,s.jsx)(n.h4,{id:"method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"sortBy"})," method sorts the collection by the given column, this overload needs the template argument so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nauto sorted = users.sortBy("name");\n\n/*\n {\n {{"name", "Jack"}, {"votes", 400}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 150}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"You may pass the projection callback to determine how to sort the collection's models:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto sorted = users.sortBy([](User *const user)\n{\n return user->getAttribute("votes");\n});\n\n/*\n {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["If you would like to sort your collection by multiple columns, you may pass a vector of comparison lambda expressions that define each sort operation to the ",(0,s.jsx)(n.code,{children:"sortBy"})," method, in the following example is the ",(0,s.jsx)(n.code,{children:"name"})," column sorted in ascending order and the second ",(0,s.jsx)(n.code,{children:"votes"})," column is sorted in descending order:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using AttributeUtils = Orm::Tiny::Utils::Attribute;\n\nModelsCollection users {\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 200}},\n};\n\nauto sorted = users.sortBy({\n [](const User *const left, const User *const right)\n {\n return AttributeUtils::compareForSortBy(\n left->getAttribute("name"),\n right->getAttribute("name"));\n },\n [](const User *const left, const User *const right)\n {\n return AttributeUtils::compareForSortByDesc(\n left->getAttribute("votes"),\n right->getAttribute("votes"));\n },\n});\n\n/*\n {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "Kate"}, {"votes", 200}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"AttributeUtils::compareForSortBy"})," and ",(0,s.jsx)(n.code,{children:"compareForSortByDesc"})," methods are helper methods, they are needed because the Qt framework doesn't define ",(0,s.jsx)(n.code,{children:"<=>"})," spaceship operator on its types, it doesn't support the three-way comparison."]}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-sortbydesc",children:(0,s.jsx)(n.code,{children:"sortByDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy"})})," method but will sort the collection in the opposite order."]}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-sortdesc",children:(0,s.jsx)(n.code,{children:"sortDesc()"})}),(0,s.jsxs)(n.p,{children:["This method will sort the collection in the opposite order as the ",(0,s.jsx)(n.a,{href:"#method-sort",children:(0,s.jsx)(n.code,{children:"sort"})})," method:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto sorted = users.sortDesc();\n\n/*\n {\n {{"id", 3}, {"name", "John"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-stablesort",children:(0,s.jsx)(n.code,{children:"stableSort()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sort",children:(0,s.jsx)(n.code,{children:"sort"})})," method but will preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortby",children:(0,s.jsx)(n.code,{children:"stableSortBy()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy"})})," method but will preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortbydesc",children:(0,s.jsx)(n.code,{children:"stableSortByDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortbydesc",children:(0,s.jsx)(n.code,{children:"sortByDesc"})})," method but will sort the collection in the opposite order and preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortdesc",children:(0,s.jsx)(n.code,{children:"stableSortDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortdesc",children:(0,s.jsx)(n.code,{children:"sortDesc"})})," method but will sort the collection in the opposite order and preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-tap",children:(0,s.jsx)(n.code,{children:"tap()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tap"}),' method passes a collection to the given lambda expression, allowing you to "tap" into the collection at a specific point and do something with the models while not affecting the collection itself:']}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nusers.sort()\n .tap([](/*const */ModelsCollection &usersRef)\n{\n qDebug() << "IDs after sorting:"\n << usersRef.template modelKeys();\n})\n .value("id");\n\n// 1\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tap"})," method returns an lvalue ",(0,s.jsx)(n.strong,{children:"reference"})," to the currently processed collection."]}),(0,s.jsxs)(n.p,{children:["It can be also called on ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," rvalues, it returns an rvalue reference in this case."]}),(0,s.jsx)(n.h4,{id:"method-tobase",children:(0,s.jsx)(n.code,{children:"toBase()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toBase"})," method returns a copy of the underlying vector represented by the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"QList = users.toBase();\n"})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#method-tobase",children:(0,s.jsx)(n.code,{children:"toBase"})})," is an alias to the ",(0,s.jsx)(n.code,{children:"all"})," method."]})}),(0,s.jsx)(n.h4,{id:"method-tojson",children:(0,s.jsx)(n.code,{children:"toJson()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJson"})," method converts the collection of models with all nested relations into a JSON serialized ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qbytearray.html",children:(0,s.jsx)(n.code,{children:"QByteArray"})}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty array for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and ",(0,s.jsx)(n.code,{children:"null"})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJson"})," method accepts the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html#JsonFormat-enum",children:(0,s.jsx)(n.code,{children:"QJsonDocument::JsonFormat"})}),", possible values are ",(0,s.jsx)(n.code,{children:"QJsonDocument::Indented"})," or ",(0,s.jsx)(n.code,{children:"QJsonDocument::Compact"}),"."]})}),(0,s.jsx)(n.h4,{id:"method-tojsonarray",children:(0,s.jsx)(n.code,{children:"toJsonArray()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJsonArray"})," method converts the collection of models with all nested relations into a ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonarray.html",children:(0,s.jsx)(n.code,{children:"QJsonArray"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-tojsondocument",children:(0,s.jsx)(n.code,{children:"toJsonDocument()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJsonDocument"})," method converts the collection of models with all nested relations into a ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,s.jsx)(n.code,{children:"QJsonDocument"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-tomap",children:(0,s.jsx)(n.code,{children:"toMap()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMap"})," method converts the collection of models with all nested relations into an attributes map ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.h4,{id:"method-tomapvariantlist",children:(0,s.jsx)(n.code,{children:"toMapVariantList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMapVariantList"})," method converts the collection of models with all nested relations into an attributes map, but it returns the ",(0,s.jsx)("abbr",{title:"QList",children:(0,s.jsx)(n.code,{children:"QVariantList"})})," instead of the ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMapVariantList"})," method is internally needed by the ",(0,s.jsx)(n.code,{children:"toJson"})," related methods."]})}),(0,s.jsx)(n.h4,{id:"method-toquery",children:(0,s.jsx)(n.code,{children:"toQuery()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toQuery"})," method returns the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," instance containing a ",(0,s.jsx)(n.code,{children:"whereIn"})," constraint with the collection of models' primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nModelsCollection users = User::whereEq("status", "VIP")->get();\n\nusers.toQuery()->update({\n {"status", "Administrator"},\n});\n'})}),(0,s.jsx)(n.h4,{id:"method-tolist",children:(0,s.jsx)(n.code,{children:"toList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toList"})," method converts the collection of models with all nested relations into an attributes vector ",(0,s.jsx)(n.code,{children:"QList>"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.h4,{id:"method-tolistvariantlist",children:(0,s.jsx)(n.code,{children:"toListVariantList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toListVariantList"})," method converts the collection of models with all nested relations into an attributes vector, but it returns the ",(0,s.jsx)("abbr",{title:"QList",children:(0,s.jsx)(n.code,{children:"QVariantList"})})," instead of the ",(0,s.jsx)(n.code,{children:"QList>"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toListVariantList"})," method is internally needed by the ",(0,s.jsx)(n.code,{children:"toJson"})," related methods."]})}),(0,s.jsx)(n.h4,{id:"method-unique",children:(0,s.jsx)(n.code,{children:"unique()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"unique"})," method returns all of the unique models in the ",(0,s.jsx)(n.strong,{children:"sorted"})," collection. Any models with the same primary key as another model in the collection are removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto unique = users.unique();\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["It sorts the collection internally because the ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/unique",children:(0,s.jsx)(n.code,{children:"ranges::unique"})})," can correctly operate only on the sorted container. You can disable it by passing ",(0,s.jsx)(n.code,{children:"false"})," using the first ",(0,s.jsx)(n.code,{children:"sort"})," parameter:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto unique = users.sort().unique(false);\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniqueby",children:(0,s.jsx)(n.code,{children:"uniqueBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueBy"})," method returns all of the unique models in the ",(0,s.jsx)(n.strong,{children:"sorted"})," collection by the given column. Any models with the same column value as another model in the collection are removed. It needs the template argument, so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Jack"}},\n};\n\nauto unique = users.uniqueBy("name");\n\n/*\n {\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Kate"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["It sorts the collection internally because the ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/unique",children:(0,s.jsx)(n.code,{children:"ranges::unique"})})," can correctly operate only on the sorted container. You can disable it by passing ",(0,s.jsx)(n.code,{children:"false"})," using the second ",(0,s.jsx)(n.code,{children:"sort"})," parameter:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto unique = users.sortBy("name")\n .uniqueBy("name", false);\n\n/*\n {\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Kate"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniquerelaxed",children:(0,s.jsx)(n.code,{children:"uniqueRelaxed()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueRelaxed"})," method returns all of the unique models in the collection, it doesn't need a sorted collection. Any models with the same primary key as another model in the collection are removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto unique = users.uniqueRelaxed();\n\n/*\n {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniquerelaxedby",children:(0,s.jsx)(n.code,{children:"uniqueRelaxedBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueRelaxedBy"})," method returns all of the unique models in the collection by the given column, it doesn't need a sorted collection, but it needs the template argument, so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Jack"}},\n};\n\nauto unique = users.uniqueRelaxedBy("name");\n\n/*\n {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-value",children:(0,s.jsx)(n.code,{children:"value()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"value"})," method retrieves a given value from the first model of the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nQVariant votes = users.value("votes");\n\n// 200\n'})}),(0,s.jsxs)(n.p,{children:["Alternatively, you can cast an obtained ",(0,s.jsx)(n.code,{children:"QVariant"})," value to the given type by the second ",(0,s.jsx)(n.code,{children:"value"})," overload:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'quint64 votes = users.value("votes");\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"value"})," method also accepts the second ",(0,s.jsx)(n.code,{children:"defaultValue"})," argument, which will be returned if a collection is empty, the first model is ",(0,s.jsx)(n.code,{children:"nullptr"}),", or a model doesn't contain the given column:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto votes = ModelsCollection().value("votes", 0);\n\n// 0\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"value"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#value",children:(0,s.jsx)(n.code,{children:"QList::value"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-where",children:(0,s.jsx)(n.code,{children:"where()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"where"})," method filters the collection by a given column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.where("price", "=", 100);\n\n/*\n {\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Door"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["For convenience, if you want to verify that a column is ",(0,s.jsx)(n.code,{children:"="})," to a given value, you may call ",(0,s.jsx)(n.code,{children:"whereEq"})," method. Similar ",(0,s.jsx)(n.code,{children:"XxxEq"})," methods are also defined for other commands:"]}),(0,s.jsx)(n.p,{children:'auto filtered = products.whereEq("price", 100);'}),(0,s.jsxs)(n.p,{children:["Optionally, you may pass a comparison operator as the second argument.",(0,s.jsx)("br",{}),"Supported operators are ",(0,s.jsx)(n.code,{children:"="}),", ",(0,s.jsx)(n.code,{children:"!="}),", ",(0,s.jsx)(n.code,{children:"<"}),", ",(0,s.jsx)(n.code,{children:">"}),", ",(0,s.jsx)(n.code,{children:"<="}),", and ",(0,s.jsx)(n.code,{children:">="}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.where("price", ">", 150);\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Door"}, {"price", 250}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherebetween",children:(0,s.jsx)(n.code,{children:"whereBetween()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereBetween"})," method filters the collection by determining if a specified models' attribute value is within a given range:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Pencil"}, {"price", 30}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.whereBetween("price", {100, 200});\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherein",children:(0,s.jsx)(n.code,{children:"whereIn()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereIn"})," method filters models from the collection that have a specified attribute value that is contained within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.whereIn("price", {100, 200});\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["An empty collection is returned if the ",(0,s.jsx)(n.code,{children:"values"})," argument is empty ",(0,s.jsx)(n.code,{children:'whereIn("price", {})'}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsx)(n.h4,{id:"method-wherenotbetween",children:(0,s.jsx)(n.code,{children:"whereNotBetween()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotBetween"})," method filters the collection by determining if a specified models' attribute value is outside of a given range:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Pencil"}, {"price", 30}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.whereNotBetween("price", {100, 200});\n\n/*\n {\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Pencil"}, {"price", 30}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherenotin",children:(0,s.jsx)(n.code,{children:"whereNotIn()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotIn"})," method removes models from the collection that have a specified attribute value that is contained within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.whereNotIn("price", {100, 200});\n\n/*\n {\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["All of the models are returned if the ",(0,s.jsx)(n.code,{children:"values"})," argument is empty ",(0,s.jsx)(n.code,{children:'whereNotIn("price", {})'}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsx)(n.h4,{id:"method-wherenotnull",children:(0,s.jsx)(n.code,{children:"whereNotNull()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotNull"})," method returns models from the collection where the given column is not ",(0,s.jsx)(n.code,{children:"null"})," QVariant:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "John"}},\n {{"name", NullVariant::QString()}},\n {{"name", "Jack"}},\n};\n\nauto filtered = users.whereNotNull("name");\n\n/*\n {\n {{"name", "John"}},\n {{"name", "Jack"}},\n }\n*/\n'})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"NullVariant"})," class returns the correct ",(0,s.jsx)(n.code,{children:"null"})," QVariant for both Qt 5 ",(0,s.jsx)(n.code,{children:"QVariant(QVariant::String)"})," and also Qt 6 ",(0,s.jsx)(n.code,{children:"QVariant(QMetaType(QMetaType::QString))"}),". The reason why this class still exists even after Qt v5.15 support was removed is the performance boost."]})}),(0,s.jsx)(n.h4,{id:"method-wherenull",children:(0,s.jsx)(n.code,{children:"whereNull()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNull"})," method returns models from the collection where the given column is ",(0,s.jsx)(n.code,{children:"null"})," QVariant:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "John"}},\n {{"name", NullVariant::QString()}},\n {{"name", "Jack"}},\n};\n\nauto filtered = users.whereNotNull("name");\n\n// {{"name", NullVariant::QString()}}\n'})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"NullVariant"})," class returns the correct ",(0,s.jsx)(n.code,{children:"null"})," QVariant for both Qt 5 ",(0,s.jsx)(n.code,{children:"QVariant(QVariant::String)"})," and also Qt 6 ",(0,s.jsx)(n.code,{children:"QVariant(QMetaType(QMetaType::QString))"}),". The reason why this class still exists even after Qt v5.15 support was removed is the performance boost."]})})]})]})}function u(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>i});var s=t(6540);const o={},r=s.createContext(o);function l(e){const n=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:l(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/3dd307b5.dc00c88e.js b/assets/js/3dd307b5.dc00c88e.js deleted file mode 100644 index 97ccf800c..000000000 --- a/assets/js/3dd307b5.dc00c88e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[117],{4251:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>l,metadata:()=>d,toc:()=>a});var s=t(4848),o=t(8453),r=t(8774);const l={sidebar_position:2,sidebar_label:"Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",keywords:["c++ orm","orm","collections","collection","model","tinyorm"]},i="TinyORM: Collections",d={id:"tinyorm/collections",title:"TinyORM: Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",source:"@site/docs/tinyorm/collections.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/collections",permalink:"/tinyorm/collections",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Collections",description:"The ModelsCollection is specialized container which provides a fluent, convenient wrapper for working with vector of models. Is much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. All TinyORM methods that return more than one model result will return instances of the ModelsCollection class.",keywords:["c++ orm","orm","collections","collection","model","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Relationships",permalink:"/tinyorm/relationships"},next:{title:"Casts",permalink:"/tinyorm/casts"}},c={},a=[{value:"Introduction",id:"introduction",level:2},{value:"Collection Conversion",id:"collection-conversion",level:4},{value:"Creating Collections",id:"creating-collections",level:3},{value:"Available Methods",id:"available-methods",level:2},{value:"all()",id:"method-all",level:4},{value:"contains()",id:"method-contains",level:4},{value:"doesntContain()",id:"method-doesntcontain",level:4},{value:"each()",id:"method-each",level:4},{value:"except()",id:"method-except",level:4},{value:"filter()",id:"method-filter",level:4},{value:"find()",id:"method-find",level:4},{value:"first()",id:"method-first",level:4},{value:"firstWhere()",id:"method-first-where",level:4},{value:"fresh()",id:"method-fresh",level:4},{value:"implode()",id:"method-implode",level:4},{value:"isEmpty()",id:"method-isempty",level:4},{value:"isNotEmpty()",id:"method-isnotempty",level:4},{value:"last()",id:"method-last",level:4},{value:"load()",id:"method-load",level:4},{value:"map()",id:"method-map",level:4},{value:"mapWithKeys()",id:"method-mapwithkeys",level:4},{value:"mapWithModelKeys()",id:"method-mapwithmodelkeys",level:4},{value:"modelKeys()",id:"method-modelkeys",level:4},{value:"only()",id:"method-only",level:4},{value:"pluck()",id:"method-pluck",level:4},{value:"reject()",id:"method-reject",level:4},{value:"sort()",id:"method-sort",level:4},{value:"sortBy()",id:"method-sortby",level:4},{value:"sortByDesc()",id:"method-sortbydesc",level:4},{value:"sortDesc()",id:"method-sortdesc",level:4},{value:"stableSort()",id:"method-stablesort",level:4},{value:"stableSortBy()",id:"method-stablesortby",level:4},{value:"stableSortByDesc()",id:"method-stablesortbydesc",level:4},{value:"stableSortDesc()",id:"method-stablesortdesc",level:4},{value:"tap()",id:"method-tap",level:4},{value:"toBase()",id:"method-tobase",level:4},{value:"toJson()",id:"method-tojson",level:4},{value:"toJsonArray()",id:"method-tojsonarray",level:4},{value:"toJsonDocument()",id:"method-tojsondocument",level:4},{value:"toMap()",id:"method-tomap",level:4},{value:"toMapVariantList()",id:"method-tomapvariantlist",level:4},{value:"toQuery()",id:"method-toquery",level:4},{value:"toList()",id:"method-tolist",level:4},{value:"toListVariantList()",id:"method-tolistvariantlist",level:4},{value:"unique()",id:"method-unique",level:4},{value:"uniqueBy()",id:"method-uniqueby",level:4},{value:"uniqueRelaxed()",id:"method-uniquerelaxed",level:4},{value:"uniqueRelaxedBy()",id:"method-uniquerelaxedby",level:4},{value:"value()",id:"method-value",level:4},{value:"where()",id:"method-where",level:4},{value:"whereBetween()",id:"method-wherebetween",level:4},{value:"whereIn()",id:"method-wherein",level:4},{value:"whereNotBetween()",id:"method-wherenotbetween",level:4},{value:"whereNotIn()",id:"method-wherenotin",level:4},{value:"whereNotNull()",id:"method-wherenotnull",level:4},{value:"whereNull()",id:"method-wherenull",level:4}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"tinyorm-collections",children:"TinyORM: Collections"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#creating-collections",children:"Creating Collections"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#available-methods",children:"Available Methods"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(r.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Types::ModelsCollection"})," is specialized container which provides a fluent, convenient wrapper for working with vector of models. All TinyORM methods that return more than one model result, will return instances of the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class, including results retrieved via the ",(0,s.jsx)(n.code,{children:"get"})," method or methods that return relationships like the ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class extends ",(0,s.jsx)(n.code,{children:"QList"}),", so it naturally inherits dozens of methods used to work with the underlying vector of TinyORM models. Be sure to review the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html",children:(0,s.jsx)(n.code,{children:"QList"})})," documentation to learn all about these helpful methods!"]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," template parameter can be declared only with the model type or a model type pointer, it also can't be ",(0,s.jsx)(n.code,{children:"const"})," and can't be a reference. It's constrained using the ",(0,s.jsx)(n.code,{children:"DerivedCollectionModel"})," concept."]})}),"\n",(0,s.jsxs)(n.p,{children:["You can iterate over the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," the same way as over the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nModelsCollection users = User::whereEq("active", true)->get();\n\nfor (const auto &user : users)\n qDebug() << user.getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"However, as previously mentioned, collections are much more powerful than vectors and expose a variety of map / reduce operations that may be chained using an intuitive interface. For example, we may remove all active users and then gather the first name of each remaining user:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto names = User::all().reject([](User *const user)\n{\n return user->getAttribute("active");\n})\n .pluck("name");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As you can see, the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class allows you to chain its methods to perform fluent mapping and reducing of the underlying vector. In general, collections are immutable, meaning every ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," method returns an entirely new ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instance."]}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is returning from the Models' methods like ",(0,s.jsx)(n.code,{children:"get"}),", ",(0,s.jsx)(n.code,{children:"all"}),", ",(0,s.jsx)(n.code,{children:"findMany"}),", ",(0,s.jsx)(n.code,{children:"chunk"}),"; the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is returning from the relationship-related methods as ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]})}),"\n",(0,s.jsx)(n.h4,{id:"collection-conversion",children:"Collection Conversion"}),"\n",(0,s.jsxs)(n.p,{children:["While most TinyORM collection methods return a new instance of ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),", the ",(0,s.jsx)(n.code,{children:"modelKeys"}),", ",(0,s.jsx)(n.code,{children:"mapWithKeys"}),", and ",(0,s.jsx)(n.code,{children:"pluck"})," methods return a base QList or std unordered/map instances. Likewise, one of the ",(0,s.jsx)(n.code,{children:"map"})," methods overload returns the ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"creating-collections",children:"Creating Collections"}),"\n",(0,s.jsxs)(n.p,{children:["Creating a ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is as simple as:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You can also create a collection of pointers, eg. ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection userPointers {\n &users[0], &users[1],\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," is implicitly convertible and assignable from the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'QList usersVector {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n};\n\nModelsCollection users(usersVector);\nusers = usersVector;\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Alternatively, you can use the ",(0,s.jsx)(n.code,{children:"Orm::collect"})," helper function to create a ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," from the given attributes:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = Orm::collect({\n {{"name", "Kate"}, {"added_on", QDateTime::currentDateTimeUtc()}},\n {{"name", "John"}, {"added_on", QDateTime({2023, 6, 1}, {13, 46, 15}, QTimeZone::UTC)}},\n});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Orm::collect"})," function is ",(0,s.jsx)(n.strong,{children:"mandatory"})," if your attributes contain the ",(0,s.jsx)(n.code,{children:"QDateTime"})," instance, you can read more about this problem ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#qdatetime-and-connection-name-problem",children:"here"}),"."]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The results of ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"})," queries are always returned as ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instances."]})}),"\n",(0,s.jsx)(n.h2,{id:"available-methods",children:"Available Methods"}),"\n",(0,s.jsxs)(n.p,{children:["For the majority of the remaining collection documentation, we'll discuss each method available on the ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," class. Remember, all of these methods may be chained to fluently manipulate the underlying vector."]}),"\n",(0,s.jsxs)(n.p,{children:["Furthermore, almost every method returns a new ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," instance, allowing you to preserve the original copy of the collection when necessary:"]}),"\n",(0,s.jsx)("div",{className:"collection-methods-list",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"#method-all",children:"all"}),"\n",(0,s.jsx)(n.a,{href:"#method-contains",children:"contains"}),"\n",(0,s.jsx)(n.a,{href:"#method-doesntcontain",children:"doesntContain"}),"\n",(0,s.jsx)(n.a,{href:"#method-each",children:"each"}),"\n",(0,s.jsx)(n.a,{href:"#method-except",children:"except"}),"\n",(0,s.jsx)(n.a,{href:"#method-filter",children:"filter"}),"\n",(0,s.jsx)(n.a,{href:"#method-find",children:"find"}),"\n",(0,s.jsx)(n.a,{href:"#method-first",children:"first"}),"\n",(0,s.jsx)(n.a,{href:"#method-first-where",children:"firstWhere"}),"\n",(0,s.jsx)(n.a,{href:"#method-fresh",children:"fresh"}),"\n",(0,s.jsx)(n.a,{href:"#method-implode",children:"implode"}),"\n",(0,s.jsx)(n.a,{href:"#method-isempty",children:"isEmpty"}),"\n",(0,s.jsx)(n.a,{href:"#method-isnotempty",children:"isNotEmpty"}),"\n",(0,s.jsx)(n.a,{href:"#method-last",children:"last"}),"\n",(0,s.jsx)(n.a,{href:"#method-load",children:"load"}),"\n",(0,s.jsx)(n.a,{href:"#method-map",children:"map"}),"\n",(0,s.jsx)(n.a,{href:"#method-mapwithkeys",children:"mapWithKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-mapwithmodelkeys",children:"mapWithModelKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-modelkeys",children:"modelKeys"}),"\n",(0,s.jsx)(n.a,{href:"#method-only",children:"only"}),"\n",(0,s.jsx)(n.a,{href:"#method-pluck",children:"pluck"}),"\n",(0,s.jsx)(n.a,{href:"#method-reject",children:"reject"}),"\n",(0,s.jsx)(n.a,{href:"#method-sort",children:"sort"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortby",children:"sortBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortbydesc",children:"sortByDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-sortdesc",children:"sortDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesort",children:"stableSort"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortby",children:"stableSortBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortbydesc",children:"stableSortByDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-stablesortdesc",children:"stableSortDesc"}),"\n",(0,s.jsx)(n.a,{href:"#method-tap",children:"tap"}),"\n",(0,s.jsx)(n.a,{href:"#method-tobase",children:"toBase"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojson",children:"toJson"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojsonarray",children:"toJsonArray"}),"\n",(0,s.jsx)(n.a,{href:"#method-tojsondocument",children:"toJsonDocument"}),"\n",(0,s.jsx)(n.a,{href:"#method-tomap",children:"toMap"}),"\n",(0,s.jsx)(n.a,{href:"#method-tomapvariantlist",children:"toMapVariantList"}),"\n",(0,s.jsx)(n.a,{href:"#method-toquery",children:"toQuery"}),"\n",(0,s.jsx)(n.a,{href:"#method-tolist",children:"toList"}),"\n",(0,s.jsx)(n.a,{href:"#method-tolistvariantlist",children:"toListVariantList"}),"\n",(0,s.jsx)(n.a,{href:"#method-unique",children:"unique"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniqueby",children:"uniqueBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniquerelaxed",children:"uniqueRelaxed"}),"\n",(0,s.jsx)(n.a,{href:"#method-uniquerelaxedby",children:"uniqueRelaxedBy"}),"\n",(0,s.jsx)(n.a,{href:"#method-value",children:"value"}),"\n",(0,s.jsx)(n.a,{href:"#method-where",children:"where"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherebetween",children:"whereBetween"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherein",children:"whereIn"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotbetween",children:"whereNotBetween"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotin",children:"whereNotIn"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenotnull",children:"whereNotNull"}),"\n",(0,s.jsx)(n.a,{href:"#method-wherenull",children:"whereNull"})]})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["For a better understanding of the following examples, many of the variable declarations below use actual types instead of the ",(0,s.jsx)(n.code,{children:"auto"})," keyword."]})}),"\n",(0,s.jsxs)("div",{className:"collection-methods",children:[(0,s.jsx)(n.h4,{id:"method-all",children:(0,s.jsx)(n.code,{children:"all()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"all"})," method returns a copy of the underlying vector represented by the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"QList = users.all();\n"})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#method-tobase",children:(0,s.jsx)(n.code,{children:"toBase"})})," is an alias to the ",(0,s.jsx)(n.code,{children:"all"})," method."]})}),(0,s.jsx)(n.h4,{id:"method-contains",children:(0,s.jsx)(n.code,{children:"contains()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"contains"})," method may be used to determine if a given model instance is contained by the collection. This method accepts a primary key or a model instance:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.contains(1);\n\nusers.contains(User::find(1));\n"})}),(0,s.jsxs)(n.p,{children:["Alternatively, you may pass a lambda expression to the ",(0,s.jsx)(n.code,{children:"contains"})," method to determine if a model exists in the collection matching a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.contains([](const User *const user)\n{\n return user->getKeyCasted() == 2;\n});\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"contains"}),", see the ",(0,s.jsx)(n.a,{href:"#method-doesntcontain",children:"doesntContain"})," method."]}),(0,s.jsx)(n.h4,{id:"method-doesntcontain",children:(0,s.jsx)(n.code,{children:"doesntContain()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"doesntContain"})," method determines whether the collection does not contain a given item. This method accepts a primary key or a model instance:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.doesntContain(1);\n\nusers.doesntContain(User::find(1));\n"})}),(0,s.jsxs)(n.p,{children:["Alternatively, you may pass a lambda expression to the ",(0,s.jsx)(n.code,{children:"doesntContain"})," method to determine if a model does not exist in the collection matching a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.doesntContain([](const User *const user)\n{\n return user->getKeyCasted() == 2;\n});\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"doesntContain"}),", see the ",(0,s.jsx)(n.a,{href:"#method-contains",children:"contains"})," method."]}),(0,s.jsx)(n.h4,{id:"method-each",children:(0,s.jsx)(n.code,{children:"each()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"each"})," method iterates over the models in the collection and passes each model to the lambda expression:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users = Post::whereEq("user_id", 1)->get();\n\nusers.each([](User *const user)\n{\n // ...\n});\n'})}),(0,s.jsxs)(n.p,{children:["If you would like to stop iterating through the models, you may return ",(0,s.jsx)(n.code,{children:"false"})," from your lambda expression:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.each([](User *const user)\n{\n if (/* condition */)\n return false;\n\n // Some logic\n\n return true;\n});\n"})}),(0,s.jsx)(n.p,{children:"You may also pass the lambda expression with two parameters, whereas the second one is an index:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"users.each([](User *const user, const std::size_t index)\n{\n // ...\n});\n"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"each"})," method returns an lvalue ",(0,s.jsx)(n.strong,{children:"reference"})," to the currently processed collection."]}),(0,s.jsxs)(n.p,{children:["It can be also called on ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," rvalues, it returns an rvalue reference in this case."]}),(0,s.jsx)(n.h4,{id:"method-except",children:(0,s.jsx)(n.code,{children:"except()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"except"})," method returns all of the models that do not have the given primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersResult = users.except({1, 2, 3});\n"})}),(0,s.jsxs)(n.p,{children:["All of the models are returned if the ",(0,s.jsx)(n.code,{children:"ids"})," argument is empty ",(0,s.jsx)(n.code,{children:"except({})"}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"except"}),", see the ",(0,s.jsx)(n.a,{href:"#method-only",children:"only"})," method."]}),(0,s.jsx)(n.h4,{id:"method-filter",children:(0,s.jsx)(n.code,{children:"filter()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"filter"})," method filters the collection using the lambda expression, keeping only those models that pass a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersBanned = users.filter([](const User *const user)\n{\n return user->getAttribute("is_banned");\n});\n'})}),(0,s.jsx)(n.p,{children:"You may also pass the lambda expression with two parameters, whereas the second one is an index:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersBanned = users.filter([](const User *const user,\n const std::size_t index)\n{\n return index < 10 && user->getAttribute("is_banned");\n});\n'})}),(0,s.jsxs)(n.p,{children:["If no lambda expression is supplied, all models of the collection that are equivalent to the ",(0,s.jsx)(n.code,{children:"nullptr"})," will be removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersRaw = User::findMany({1, 2});\nModelsCollection users {&usersRaw[0], nullptr, &usersRaw[1]};\n\nModelsCollection filtered = users.filter();\n\n// {1, 2}\n"})}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"filter"}),", see the ",(0,s.jsx)(n.a,{href:"#method-reject",children:"reject"})," method."]}),(0,s.jsx)(n.h4,{id:"method-find",children:(0,s.jsx)(n.code,{children:"find()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"find"})," method returns the model that has a primary key matching the given key:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"User *const user = users.find(1);\n"})}),(0,s.jsxs)(n.p,{children:["If you pass a model instance, ",(0,s.jsx)(n.code,{children:"find"})," will attempt to return a model matching the primary key:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"User *user = users.find(anotherUser);\n"})}),(0,s.jsxs)(n.p,{children:["The two overloads above also accept the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," model argument, which will be returned if a model was not found in the collection, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsxs)(n.p,{children:["Alternatively, may pass more IDs and ",(0,s.jsx)(n.code,{children:"find"})," will return all models which have a primary key within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersMany = users.find({1, 2});\n"})}),(0,s.jsxs)(n.p,{children:["This overload internally calls the ",(0,s.jsx)(n.a,{href:"#method-only",children:(0,s.jsx)(n.code,{children:"only"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-first",children:(0,s.jsx)(n.code,{children:"first()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"first"})," method returns the first model in the collection that passes a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nUser *user = users.first([](User *const user)\n{\n return user->getAttribute("votes") > 150;\n});\n\n// {{"name", "John"}, {"votes", 200}}\n'})}),(0,s.jsxs)(n.p,{children:["If no model passes a given truth test then the value of the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," argument will be returned, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nUser defaultUser {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}};\n\nUser *user = users.first([](User *const user)\n{\n return user->getAttribute("votes") > 500;\n},\n &defaultUser);\n\n/*\n {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}}\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"first"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#first",children:(0,s.jsx)(n.code,{children:"QList::first"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-first-where",children:(0,s.jsx)(n.code,{children:"firstWhere()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"firstWhere"})," method returns the first model in the collection with the given column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "Leon"}, {"age", NullVariant::UShort()}},\n {{"name", "Jill"}, {"age", 14}},\n {{"name", "Jack"}, {"age", 23}},\n {{"name", "Jill"}, {"age", 84}},\n};\n\nauto user = users.firstWhereEq("name", "Linda");\n\n// {{"name", "Jill"}, {"age", 14}}\n'})}),(0,s.jsxs)(n.p,{children:["You may also call the ",(0,s.jsx)(n.code,{children:"firstWhere"})," method with a comparison operator:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'users.firstWhere("age", ">=", 18);\n\n// {{"name", "Jack"}, {"age", 23}}\n'})}),(0,s.jsx)(n.h4,{id:"method-fresh",children:(0,s.jsx)(n.code,{children:"fresh()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"fresh"})," method retrieves a fresh instance of each model in the collection from the database. In addition, any specified relationships will be eager loaded:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersFresh = users.fresh();\n\nauto usersFresh = users.fresh("comments");\n\nauto usersFresh = users.fresh("posts:id,name");\n\nauto usersFresh = users.fresh({"comments", "posts:id,name"});\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"relations"})," argument format is the same as for TinyBuilder's ",(0,s.jsx)(n.a,{href:"/tinyorm/relationships#lazy-eager-loading",children:(0,s.jsx)(n.code,{children:"load"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-implode",children:(0,s.jsx)(n.code,{children:"implode()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"implode"}),' method joins attributes by the given column and the "glue" string you wish to place between the values:']}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n};\n\nproducts.implode("product", ", ");\n\n// {Desk, Chair}\n'})}),(0,s.jsx)(n.p,{children:'The default "glue" value is an empty string "".'}),(0,s.jsx)(n.h4,{id:"method-isempty",children:(0,s.jsx)(n.code,{children:"isEmpty()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"isEmpty"})," method returns ",(0,s.jsx)(n.code,{children:"true"})," if the collection is empty; otherwise, ",(0,s.jsx)(n.code,{children:"false"})," is returned:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection().isEmpty();\n\n// true\n"})}),(0,s.jsx)(n.h4,{id:"method-isnotempty",children:(0,s.jsx)(n.code,{children:"isNotEmpty()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"isNotEmpty"})," method returns ",(0,s.jsx)(n.code,{children:"true"})," if the collection is not empty; otherwise, ",(0,s.jsx)(n.code,{children:"false"})," is returned:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection().isNotEmpty();\n\n// false\n"})}),(0,s.jsx)(n.h4,{id:"method-last",children:(0,s.jsx)(n.code,{children:"last()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"last"})," method returns the last model in the collection that passes a given truth test:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n {{"name", "Rose"}, {"votes", 350}},\n};\n\nUser *user = users.last([](User *const user)\n{\n return user->getAttribute("votes") < 300;\n});\n\n// {{"name", "John"}, {"votes", 200}}\n'})}),(0,s.jsxs)(n.p,{children:["If no model passes a given truth test then the value of the second ",(0,s.jsx)(n.code,{children:"defaultModel"})," argument will be returned, its default value is the ",(0,s.jsx)(n.code,{children:"nullptr"}),"."]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using NullVariant = Orm::Utils::NullVariant;\n\nUser defaultUser {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}};\n\nUser *user = users.last([](User *const user)\n{\n return user->getAttribute("votes") < 100;\n},\n &defaultUser);\n\n/*\n {{"name", NullVariant::QString()},\n {"votes", NullVariant::ULongLong()}}\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"last"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#last",children:(0,s.jsx)(n.code,{children:"QList::last"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-load",children:(0,s.jsx)(n.code,{children:"load()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"load"})," method eager loads the given relationships for all models in the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'users.load({"comments", "posts"});\n\nusers.load("comments.author");\n\nusers.load({{"comments"}, {"posts", [](auto &query)\n{\n query.whereEq("active", true);\n}}});\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"relations"})," argument format is the same as for TinyBuilder's ",(0,s.jsx)(n.a,{href:"/tinyorm/relationships#lazy-eager-loading",children:(0,s.jsx)(n.code,{children:"load"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-map",children:(0,s.jsx)(n.code,{children:"map()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"map"})," method iterates through the collection and passes a ",(0,s.jsx)(n.strong,{children:"copy"})," of each model to the given lambda expression. The lambda expression is free to modify the model and return it, thus forming a new collection of modified models:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nauto usersAdded = users.map([](User &&userCopy)\n{\n if (userCopy.getAttribute("name") == "John")\n userCopy["votes"] = userCopy.getAttribute("votes") + 1;\n\n return std::move(userCopy);\n});\n\n/*\n {\n {{"name", "John"}, {"price", 201}},\n {{"name", "Jack"}, {"price", 400}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["The second ",(0,s.jsx)(n.code,{children:"map"})," overload allows to return the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'QList usersAdded = users.map([](User &&userCopy)\n{\n const auto votesRef = userCopy["votes"];\n\n if (userCopy.getAttribute("name") == "John")\n votesRef = userCopy.getAttribute("votes") + 1;\n\n return votesRef->value();\n});\n\n// {201, 400}\n'})}),(0,s.jsxs)(n.p,{children:["Both overloads allow to pass the lambda expression with two arguments, whereas the second argument can be an index of the ",(0,s.jsx)(n.code,{children:"std::size_t"})," type."]}),(0,s.jsx)(n.admonition,{type:"caution",children:(0,s.jsxs)(n.p,{children:["Like most other collection methods, ",(0,s.jsx)(n.code,{children:"map"})," returns a new collection instance; it does not modify the collection it is called on. If you want to modify the original collection in place, use the ",(0,s.jsx)(n.a,{href:"#method-each",children:(0,s.jsx)(n.code,{children:"each"})})," method."]})}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The model copy is passed to the lambda expression even if the ",(0,s.jsx)(n.code,{children:"map"})," iterates over a collection of model pointers ",(0,s.jsx)(n.code,{children:"ModelsCollection"}),". The models are dereferenced behind the scene."]})}),(0,s.jsx)(n.h4,{id:"method-mapwithkeys",children:(0,s.jsx)(n.code,{children:"mapWithKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"mapWithKeys"})," method iterates through the collection and passes each model to the given lambda expression. It returns the ",(0,s.jsx)(n.code,{children:"std::unordered_map"})," and the lambda expression should return the ",(0,s.jsx)(n.code,{children:"std::pair"})," containing a single column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 1}, {"name", "John"}, {"email", "john@example.com"}},\n {{"id", 2}, {"name", "Jill"}, {"email", "jill@example.com"}},\n};\n\nauto usersMap = users.mapWithKeys(\n [](User *const user) -> std::pair\n{\n return {user->getKeyCasted(), user->getAttribute("name")};\n});\n\n// {{1, \'John\'}, {2, \'Jill\'}}\n'})}),(0,s.jsx)(n.p,{children:"You can also map IDs to the model pointers:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"auto usersMap = users.mapWithKeys(\n [](User *const user) -> std::pair\n{\n return {user->getKeyCasted(), user};\n});\n"})}),(0,s.jsx)(n.h4,{id:"method-mapwithmodelkeys",children:(0,s.jsx)(n.code,{children:"mapWithModelKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"mapWithModelKeys"})," maps the primary keys to the ",(0,s.jsx)(n.code,{children:"Model *"}),", it returns the ",(0,s.jsx)(n.code,{children:"std::unordered_map"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"auto usersMap = users.mapWithModelKeys();\n"})}),(0,s.jsx)(n.h4,{id:"method-modelkeys",children:(0,s.jsx)(n.code,{children:"modelKeys()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"modelKeys"})," method returns the primary keys for all models in the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 1}, {"name", "John"}},\n {{"id", 2}, {"name", "Jill"}},\n {{"id", 3}, {"name", "Kate"}},\n {{"id", 5}, {"name", "Rose"}},\n};\n\nusers.modelKeys(); // Returns QList\nusers.modelKeys();\n\n// {1, 2, 3, 5}\n'})}),(0,s.jsx)(n.h4,{id:"method-only",children:(0,s.jsx)(n.code,{children:"only()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"only"})," method returns all of the models that have the given primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"ModelsCollection usersResult = users.only({1, 2, 3});\n"})}),(0,s.jsxs)(n.p,{children:["An empty collection is returned if the ",(0,s.jsx)(n.code,{children:"ids"})," argument is empty ",(0,s.jsx)(n.code,{children:"only({})"}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsxs)(n.p,{children:["For the inverse of ",(0,s.jsx)(n.code,{children:"only"}),", see the ",(0,s.jsx)(n.a,{href:"#method-except",children:"except"})," method."]}),(0,s.jsx)(n.h4,{id:"method-pluck",children:(0,s.jsx)(n.code,{children:"pluck()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"pluck"})," method retrieves all of the values for a given column, the following overload returns the ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"id", 1}, {"name", "Desk"}},\n {{"id", 2}, {"name", "Chair"}},\n};\n\nauto plucked = products.pluck("name");\n\n// {Desk, Chair}\n'})}),(0,s.jsxs)(n.p,{children:["The second overload allows returning the custom type ",(0,s.jsx)(n.code,{children:"QList"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto plucked = products.pluck("name");\n'})}),(0,s.jsxs)(n.p,{children:["You may also specify how you wish the resulting collection to be keyed, this overload returns the ",(0,s.jsx)(n.code,{children:"std::map"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto plucked = products.pluck("name", "id");\n\n// {{1, "Desk"}, {2, "Chair"}}\n'})}),(0,s.jsx)(n.p,{children:"If duplicate keys exist, the last matching attribute will be inserted into the plucked collection:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection collection {\n {{"brand", "Tesla"}, {"color", "red"}},\n {{"brand", "Pagani"}, {"color", "white"}},\n {{"brand", "Tesla"}, {"color", "black"}},\n {{"brand", "Pagani"}, {"color", "orange"}},\n};\n\nauto plucked = collection.pluck("color", "brand");\n\n// {{\'Tesla\', \'black\'}, {\'Pagani\', \'orange"}}\n'})}),(0,s.jsx)(n.h4,{id:"method-reject",children:(0,s.jsx)(n.code,{children:"reject()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"reject"})," method filters the collection using the given lambda expression. The lambda should return ",(0,s.jsx)(n.code,{children:"true"})," if the model should be removed from the resulting collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto usersWithNote = users.reject([](const User *const user)\n{\n return user->getAttribute("note").isNull();\n});\n'})}),(0,s.jsxs)(n.p,{children:["You may also pass the lambda expression with two arguments, whereas the second argument can be an index of the ",(0,s.jsx)(n.code,{children:"std::size_t"})," type."]}),(0,s.jsxs)(n.p,{children:["For the inverse of the ",(0,s.jsx)(n.code,{children:"reject"})," method, see the ",(0,s.jsx)(n.a,{href:"#method-filter",children:(0,s.jsx)(n.code,{children:"filter"})})," method."]}),(0,s.jsx)(n.h4,{id:"method-sort",children:(0,s.jsx)(n.code,{children:"sort()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"sort"})," method sorts the models collection by primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto sorted = users.sort();\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["You may pass a predicate and projection callbacks to the ",(0,s.jsx)(n.code,{children:"sort"})," method with your own algorithms. Refer to the CPP reference documentation on ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/sort",children:(0,s.jsx)(n.code,{children:"ranges::sort"})}),", which is what the ",(0,s.jsx)(n.code,{children:"sort"})," method calls internally."]}),(0,s.jsxs)(n.p,{children:["You can eg. sort by multiple columns, for an alternative method of multi-column sorting look at ",(0,s.jsx)(n.a,{href:"#method-sortby",children:"sortBy"}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 200}},\n};\n\nauto sorted = users.sort([](const User *const left,\n const User *const right)\n{\n const auto leftValue = left->getAttribute("name");\n const auto rightValue = right->getAttribute("name");\n\n if (leftValue == rightValue)\n return left->getAttribute("votes") <\n right->getAttribute("votes");\n\n return leftValue < rightValue;\n});\n\n/*\n {\n {{"name", "John"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 350}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsx)(n.a,{href:"#method-stablesort",children:"stable"})," sort method variants to preserve the order of equal models."]})}),(0,s.jsx)(n.h4,{id:"method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"sortBy"})," method sorts the collection by the given column, this overload needs the template argument so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nauto sorted = users.sortBy("name");\n\n/*\n {\n {{"name", "Jack"}, {"votes", 400}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Kate"}, {"votes", 150}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"You may pass the projection callback to determine how to sort the collection's models:"}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto sorted = users.sortBy([](User *const user)\n{\n return user->getAttribute("votes");\n});\n\n/*\n {\n {{"name", "Kate"}, {"votes", 150}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["If you would like to sort your collection by multiple columns, you may pass a vector of comparison lambda expressions that define each sort operation to the ",(0,s.jsx)(n.code,{children:"sortBy"})," method, in the following example is the ",(0,s.jsx)(n.code,{children:"name"})," column sorted in ascending order and the second ",(0,s.jsx)(n.code,{children:"votes"})," column is sorted in descending order:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using AttributeUtils = Orm::Tiny::Utils::Attribute;\n\nModelsCollection users {\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 200}},\n};\n\nauto sorted = users.sortBy({\n [](const User *const left, const User *const right)\n {\n return AttributeUtils::compareForSortBy(\n left->getAttribute("name"),\n right->getAttribute("name"));\n },\n [](const User *const left, const User *const right)\n {\n return AttributeUtils::compareForSortByDesc(\n left->getAttribute("votes"),\n right->getAttribute("votes"));\n },\n});\n\n/*\n {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "John"}, {"votes", 150}},\n {{"name", "Kate"}, {"votes", 350}},\n {{"name", "Kate"}, {"votes", 200}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"AttributeUtils::compareForSortBy"})," and ",(0,s.jsx)(n.code,{children:"compareForSortByDesc"})," methods are helper methods, they are needed because the Qt framework doesn't define ",(0,s.jsx)(n.code,{children:"<=>"})," spaceship operator on its types, it doesn't support the three-way comparison."]}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-sortbydesc",children:(0,s.jsx)(n.code,{children:"sortByDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy"})})," method but will sort the collection in the opposite order."]}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-sortdesc",children:(0,s.jsx)(n.code,{children:"sortDesc()"})}),(0,s.jsxs)(n.p,{children:["This method will sort the collection in the opposite order as the ",(0,s.jsx)(n.a,{href:"#method-sort",children:(0,s.jsx)(n.code,{children:"sort"})})," method:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto sorted = users.sortDesc();\n\n/*\n {\n {{"id", 3}, {"name", "John"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n }\n*/\n'})}),(0,s.jsx)(n.p,{children:"The order of equal elements is not guaranteed to be preserved."}),(0,s.jsx)(n.h4,{id:"method-stablesort",children:(0,s.jsx)(n.code,{children:"stableSort()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sort",children:(0,s.jsx)(n.code,{children:"sort"})})," method but will preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortby",children:(0,s.jsx)(n.code,{children:"stableSortBy()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortby",children:(0,s.jsx)(n.code,{children:"sortBy"})})," method but will preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortbydesc",children:(0,s.jsx)(n.code,{children:"stableSortByDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortbydesc",children:(0,s.jsx)(n.code,{children:"sortByDesc"})})," method but will sort the collection in the opposite order and preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-stablesortdesc",children:(0,s.jsx)(n.code,{children:"stableSortDesc()"})}),(0,s.jsxs)(n.p,{children:["This method has the same signature as the ",(0,s.jsx)(n.a,{href:"#method-sortdesc",children:(0,s.jsx)(n.code,{children:"sortDesc"})})," method but will sort the collection in the opposite order and preserve the order of equal elements (guaranteed to be preserved)."]}),(0,s.jsx)(n.h4,{id:"method-tap",children:(0,s.jsx)(n.code,{children:"tap()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tap"}),' method passes a collection to the given lambda expression, allowing you to "tap" into the collection at a specific point and do something with the models while not affecting the collection itself:']}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nusers.sort()\n .tap([](/*const */ModelsCollection &usersRef)\n{\n qDebug() << "IDs after sorting:"\n << usersRef.template modelKeys();\n})\n .value("id");\n\n// 1\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tap"})," method returns an lvalue ",(0,s.jsx)(n.strong,{children:"reference"})," to the currently processed collection."]}),(0,s.jsxs)(n.p,{children:["It can be also called on ",(0,s.jsx)(n.code,{children:"ModelsCollection"})," rvalues, it returns an rvalue reference in this case."]}),(0,s.jsx)(n.h4,{id:"method-tobase",children:(0,s.jsx)(n.code,{children:"toBase()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toBase"})," method returns a copy of the underlying vector represented by the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"QList = users.toBase();\n"})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#method-tobase",children:(0,s.jsx)(n.code,{children:"toBase"})})," is an alias to the ",(0,s.jsx)(n.code,{children:"all"})," method."]})}),(0,s.jsx)(n.h4,{id:"method-tojson",children:(0,s.jsx)(n.code,{children:"toJson()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJson"})," method converts the collection of models with all nested relations into a JSON serialized ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qbytearray.html",children:(0,s.jsx)(n.code,{children:"QByteArray"})}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty array for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and ",(0,s.jsx)(n.code,{children:"null"})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJson"})," method accepts the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html#JsonFormat-enum",children:(0,s.jsx)(n.code,{children:"QJsonDocument::JsonFormat"})}),", possible values are ",(0,s.jsx)(n.code,{children:"QJsonDocument::Indented"})," or ",(0,s.jsx)(n.code,{children:"QJsonDocument::Compact"}),"."]})}),(0,s.jsx)(n.h4,{id:"method-tojsonarray",children:(0,s.jsx)(n.code,{children:"toJsonArray()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJsonArray"})," method converts the collection of models with all nested relations into a ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsonarray.html",children:(0,s.jsx)(n.code,{children:"QJsonArray"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-tojsondocument",children:(0,s.jsx)(n.code,{children:"toJsonDocument()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toJsonDocument"})," method converts the collection of models with all nested relations into a ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qjsondocument.html",children:(0,s.jsx)(n.code,{children:"QJsonDocument"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-tomap",children:(0,s.jsx)(n.code,{children:"toMap()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMap"})," method converts the collection of models with all nested relations into an attributes map ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.h4,{id:"method-tomapvariantlist",children:(0,s.jsx)(n.code,{children:"toMapVariantList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMapVariantList"})," method converts the collection of models with all nested relations into an attributes map, but it returns the ",(0,s.jsx)("abbr",{title:"QList",children:(0,s.jsx)(n.code,{children:"QVariantList"})})," instead of the ",(0,s.jsx)(n.code,{children:"QList"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toMapVariantList"})," method is internally needed by the ",(0,s.jsx)(n.code,{children:"toJson"})," related methods."]})}),(0,s.jsx)(n.h4,{id:"method-toquery",children:(0,s.jsx)(n.code,{children:"toQuery()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toQuery"})," method returns the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," instance containing a ",(0,s.jsx)(n.code,{children:"whereIn"})," constraint with the collection of models' primary keys:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Models::User;\n\nModelsCollection users = User::whereEq("status", "VIP")->get();\n\nusers.toQuery()->update({\n {"status", "Administrator"},\n});\n'})}),(0,s.jsx)(n.h4,{id:"method-tolist",children:(0,s.jsx)(n.code,{children:"toList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toList"})," method converts the collection of models with all nested relations into an attributes vector ",(0,s.jsx)(n.code,{children:"QList>"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.h4,{id:"method-tolistvariantlist",children:(0,s.jsx)(n.code,{children:"toListVariantList()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toListVariantList"})," method converts the collection of models with all nested relations into an attributes vector, but it returns the ",(0,s.jsx)("abbr",{title:"QList",children:(0,s.jsx)(n.code,{children:"QVariantList"})})," instead of the ",(0,s.jsx)(n.code,{children:"QList>"}),"."]}),(0,s.jsxs)(n.p,{children:["It returns an empty ",(0,s.jsx)(n.code,{children:"QVariantList"})," for empty ",(0,s.jsx)(n.code,{children:"many"})," type relations and a null ",(0,s.jsx)("abbr",{title:"QVariant::fromValue(nullptr)",children:(0,s.jsx)(n.code,{children:"QVariant"})})," for empty ",(0,s.jsx)(n.code,{children:"one"})," type relations."]}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"toListVariantList"})," method is internally needed by the ",(0,s.jsx)(n.code,{children:"toJson"})," related methods."]})}),(0,s.jsx)(n.h4,{id:"method-unique",children:(0,s.jsx)(n.code,{children:"unique()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"unique"})," method returns all of the unique models in the ",(0,s.jsx)(n.strong,{children:"sorted"})," collection. Any models with the same primary key as another model in the collection are removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto unique = users.unique();\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["It sorts the collection internally because the ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/unique",children:(0,s.jsx)(n.code,{children:"ranges::unique"})})," can correctly operate only on the sorted container. You can disable it by passing ",(0,s.jsx)(n.code,{children:"false"})," using the first ",(0,s.jsx)(n.code,{children:"sort"})," parameter:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto unique = users.sort().unique(false);\n\n/*\n {\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniqueby",children:(0,s.jsx)(n.code,{children:"uniqueBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueBy"})," method returns all of the unique models in the ",(0,s.jsx)(n.strong,{children:"sorted"})," collection by the given column. Any models with the same column value as another model in the collection are removed. It needs the template argument, so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Jack"}},\n};\n\nauto unique = users.uniqueBy("name");\n\n/*\n {\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Kate"}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["It sorts the collection internally because the ",(0,s.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/algorithm/ranges/unique",children:(0,s.jsx)(n.code,{children:"ranges::unique"})})," can correctly operate only on the sorted container. You can disable it by passing ",(0,s.jsx)(n.code,{children:"false"})," using the second ",(0,s.jsx)(n.code,{children:"sort"})," parameter:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto unique = users.sortBy("name")\n .uniqueBy("name", false);\n\n/*\n {\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Kate"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniquerelaxed",children:(0,s.jsx)(n.code,{children:"uniqueRelaxed()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueRelaxed"})," method returns all of the unique models in the collection, it doesn't need a sorted collection. Any models with the same primary key as another model in the collection are removed:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n {{"id", 1}, {"name", "Jack"}},\n};\n\nauto unique = users.uniqueRelaxed();\n\n/*\n {\n {{"id", 2}, {"name", "Kate"}},\n {{"id", 1}, {"name", "Jack"}},\n {{"id", 3}, {"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-uniquerelaxedby",children:(0,s.jsx)(n.code,{children:"uniqueRelaxedBy()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"uniqueRelaxedBy"})," method returns all of the unique models in the collection by the given column, it doesn't need a sorted collection, but it needs the template argument, so it can cast the attribute value before comparing:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n {{"name", "Jack"}},\n};\n\nauto unique = users.uniqueRelaxedBy("name");\n\n/*\n {\n {{"name", "Kate"}},\n {{"name", "Jack"}},\n {{"name", "John"}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-value",children:(0,s.jsx)(n.code,{children:"value()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"value"})," method retrieves a given value from the first model of the collection:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection users {\n {{"name", "John"}, {"votes", 200}},\n {{"name", "Jack"}, {"votes", 400}},\n};\n\nQVariant votes = users.value("votes");\n\n// 200\n'})}),(0,s.jsxs)(n.p,{children:["Alternatively, you can cast an obtained ",(0,s.jsx)(n.code,{children:"QVariant"})," value to the given type by the second ",(0,s.jsx)(n.code,{children:"value"})," overload:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'quint64 votes = users.value("votes");\n'})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"value"})," method also accepts the second ",(0,s.jsx)(n.code,{children:"defaultValue"})," argument, which will be returned if a collection is empty, the first model is ",(0,s.jsx)(n.code,{children:"nullptr"}),", or a model doesn't contain the given column:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto votes = ModelsCollection().value("votes", 0);\n\n// 0\n'})}),(0,s.jsxs)(n.p,{children:["You can also call all ",(0,s.jsx)(n.code,{children:"value"})," overloads provided by the ",(0,s.jsx)(n.a,{href:"https://doc.qt.io/qt/qlist.html#value",children:(0,s.jsx)(n.code,{children:"QList::value"})}),"."]}),(0,s.jsx)(n.h4,{id:"method-where",children:(0,s.jsx)(n.code,{children:"where()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"where"})," method filters the collection by a given column / value pair:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.where("price", "=", 100);\n\n/*\n {\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Door"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["For convenience, if you want to verify that a column is ",(0,s.jsx)(n.code,{children:"="})," to a given value, you may call ",(0,s.jsx)(n.code,{children:"whereEq"})," method. Similar ",(0,s.jsx)(n.code,{children:"XxxEq"})," methods are also defined for other commands:"]}),(0,s.jsx)(n.p,{children:'auto filtered = products.whereEq("price", 100);'}),(0,s.jsxs)(n.p,{children:["Optionally, you may pass a comparison operator as the second argument.",(0,s.jsx)("br",{}),"Supported operators are ",(0,s.jsx)(n.code,{children:"="}),", ",(0,s.jsx)(n.code,{children:"!="}),", ",(0,s.jsx)(n.code,{children:"<"}),", ",(0,s.jsx)(n.code,{children:">"}),", ",(0,s.jsx)(n.code,{children:"<="}),", and ",(0,s.jsx)(n.code,{children:">="}),":"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.where("price", ">", 150);\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Door"}, {"price", 250}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherebetween",children:(0,s.jsx)(n.code,{children:"whereBetween()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereBetween"})," method filters the collection by determining if a specified models' attribute value is within a given range:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Pencil"}, {"price", 30}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.whereBetween("price", {100, 200});\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherein",children:(0,s.jsx)(n.code,{children:"whereIn()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereIn"})," method filters models from the collection that have a specified attribute value that is contained within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.whereIn("price", {100, 200});\n\n/*\n {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["An empty collection is returned if the ",(0,s.jsx)(n.code,{children:"values"})," argument is empty ",(0,s.jsx)(n.code,{children:'whereIn("price", {})'}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsx)(n.h4,{id:"method-wherenotbetween",children:(0,s.jsx)(n.code,{children:"whereNotBetween()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotBetween"})," method filters the collection by determining if a specified models' attribute value is outside of a given range:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Pencil"}, {"price", 30}},\n {{"product", "Door"}, {"price", 100}},\n};\n\nauto filtered = products.whereNotBetween("price", {100, 200});\n\n/*\n {\n {{"product", "Chair"}, {"price", 80}},\n {{"product", "Pencil"}, {"price", 30}},\n }\n*/\n'})}),(0,s.jsx)(n.h4,{id:"method-wherenotin",children:(0,s.jsx)(n.code,{children:"whereNotIn()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotIn"})," method removes models from the collection that have a specified attribute value that is contained within the given unordered set:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'ModelsCollection products {\n {{"product", "Desk"}, {"price", 200}},\n {{"product", "Chair"}, {"price", 100}},\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n};\n\nauto filtered = products.whereNotIn("price", {100, 200});\n\n/*\n {\n {{"product", "Bookcase"}, {"price", 150}},\n {{"product", "Door"}, {"price", 250}},\n }\n*/\n'})}),(0,s.jsxs)(n.p,{children:["All of the models are returned if the ",(0,s.jsx)(n.code,{children:"values"})," argument is empty ",(0,s.jsx)(n.code,{children:'whereNotIn("price", {})'}),"."]}),(0,s.jsx)(n.p,{children:"The order of models in the collection is preserved."}),(0,s.jsx)(n.h4,{id:"method-wherenotnull",children:(0,s.jsx)(n.code,{children:"whereNotNull()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNotNull"})," method returns models from the collection where the given column is not ",(0,s.jsx)(n.code,{children:"null"})," QVariant:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "John"}},\n {{"name", NullVariant::QString()}},\n {{"name", "Jack"}},\n};\n\nauto filtered = users.whereNotNull("name");\n\n/*\n {\n {{"name", "John"}},\n {{"name", "Jack"}},\n }\n*/\n'})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"NullVariant"})," class returns the correct ",(0,s.jsx)(n.code,{children:"null"})," QVariant for both Qt 5 ",(0,s.jsx)(n.code,{children:"QVariant(QVariant::String)"})," and also Qt 6 ",(0,s.jsx)(n.code,{children:"QVariant(QMetaType(QMetaType::QString))"}),". The reason why this class still exists even after Qt v5.15 support was removed is the performance boost."]})}),(0,s.jsx)(n.h4,{id:"method-wherenull",children:(0,s.jsx)(n.code,{children:"whereNull()"})}),(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"whereNull"})," method returns models from the collection where the given column is ",(0,s.jsx)(n.code,{children:"null"})," QVariant:"]}),(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing NullVariant = Orm::Utils::NullVariant;\n\nModelsCollection users {\n {{"name", "John"}},\n {{"name", NullVariant::QString()}},\n {{"name", "Jack"}},\n};\n\nauto filtered = users.whereNotNull("name");\n\n// {{"name", NullVariant::QString()}}\n'})}),(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"NullVariant"})," class returns the correct ",(0,s.jsx)(n.code,{children:"null"})," QVariant for both Qt 5 ",(0,s.jsx)(n.code,{children:"QVariant(QVariant::String)"})," and also Qt 6 ",(0,s.jsx)(n.code,{children:"QVariant(QMetaType(QMetaType::QString))"}),". The reason why this class still exists even after Qt v5.15 support was removed is the performance boost."]})})]})]})}function u(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>i});var s=t(6540);const o={},r=s.createContext(o);function l(e){const n=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:l(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/462.0011555c.js b/assets/js/462.0011555c.js deleted file mode 100644 index 61621e71e..000000000 --- a/assets/js/462.0011555c.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[462],{9462:(e,t,r)=>{function n(e,t){var r=void 0;return function(){for(var n=arguments.length,o=new Array(n),i=0;ivn});var a=function(){};function c(e){var t=e.item,r=e.items;return{index:t.__autocomplete_indexName,items:[t],positions:[1+r.findIndex((function(e){return e.objectID===t.objectID}))],queryID:t.__autocomplete_queryID,algoliaSource:["autocomplete"]}}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],l=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);l=!0);}catch(s){u=!0,o=s}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t=3||2===r&&n>=4||1===r&&n>=10);function i(t,r,n){if(o&&void 0!==n){var i=n[0].__autocomplete_algoliaCredentials,a={"X-Algolia-Application-Id":i.appId,"X-Algolia-API-Key":i.apiKey};e.apply(void 0,[t].concat(p(r),[{headers:a}]))}else e.apply(void 0,[t].concat(p(r)))}return{init:function(t,r){e("init",{appId:t,apiKey:r})},setUserToken:function(t){e("setUserToken",t)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&i("clickedObjectIDsAfterSearch",g(t),t[0].items)},clickedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&i("clickedObjectIDs",g(t),t[0].items)},clickedFilters:function(){for(var t=arguments.length,r=new Array(t),n=0;n0&&e.apply(void 0,["clickedFilters"].concat(r))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&i("convertedObjectIDsAfterSearch",g(t),t[0].items)},convertedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&i("convertedObjectIDs",g(t),t[0].items)},convertedFilters:function(){for(var t=arguments.length,r=new Array(t),n=0;n0&&e.apply(void 0,["convertedFilters"].concat(r))},viewedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),r=0;r0&&t.reduce((function(e,t){var r=t.items,n=d(t,f);return[].concat(p(e),p(function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=[],n=0;n0&&e.apply(void 0,["viewedFilters"].concat(r))}}}function S(e){var t=e.items.reduce((function(e,t){var r;return e[t.__autocomplete_indexName]=(null!==(r=e[t.__autocomplete_indexName])&&void 0!==r?r:[]).concat(t),e}),{});return Object.keys(t).map((function(e){return{index:e,items:t[e],algoliaSource:["autocomplete"]}}))}function j(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}function E(e){return function(e){if(Array.isArray(e))return P(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&C({onItemsChange:o,items:r,insights:f,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,r=e.onSelect,n=e.onActive;s("addAlgoliaAgent","insights-plugin"),t({algoliaInsightsPlugin:{__algoliaSearchParameters:{clickAnalytics:!0},insights:f}}),r((function(e){var t=e.item,r=e.state,n=e.event;j(t)&&l({state:r,event:n,insights:f,item:t,insightsEvents:[D({eventName:"Item Selected"},c({item:t,items:m.current}))]})})),n((function(e){var t=e.item,r=e.state,n=e.event;j(t)&&u({state:r,event:n,insights:f,item:t,insightsEvents:[D({eventName:"Item Active"},c({item:t,items:m.current}))]})}))},onStateChange:function(e){var t=e.state;p({state:t})},__autocomplete_pluginOptions:e}}function N(e){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N(e)}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function q(e,t,r){return(t=function(e){var t=function(e,t){if("object"!==N(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===N(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function R(e,t,r){var n,o=t.initialState;return{getState:function(){return o},dispatch:function(n,i){var a=function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0},reshape:function(e){return e.sources}},e),{},{id:null!==(r=e.id)&&void 0!==r?r:"autocomplete-".concat(V++),plugins:o,initialState:X({activeItemId:null,query:"",completion:null,collections:[],isOpen:!1,status:"idle",context:{}},e.initialState),onStateChange:function(t){var r;null===(r=e.onStateChange)||void 0===r||r.call(e,t),o.forEach((function(e){var r;return null===(r=e.onStateChange)||void 0===r?void 0:r.call(e,t)}))},onSubmit:function(t){var r;null===(r=e.onSubmit)||void 0===r||r.call(e,t),o.forEach((function(e){var r;return null===(r=e.onSubmit)||void 0===r?void 0:r.call(e,t)}))},onReset:function(t){var r;null===(r=e.onReset)||void 0===r||r.call(e,t),o.forEach((function(e){var r;return null===(r=e.onReset)||void 0===r?void 0:r.call(e,t)}))},getSources:function(r){return Promise.all([].concat(Q(o.map((function(e){return e.getSources}))),[e.getSources]).filter(Boolean).map((function(e){return function(e,t){var r=[];return Promise.resolve(e(t)).then((function(e){return Array.isArray(e),Promise.all(e.filter((function(e){return Boolean(e)})).map((function(e){if(e.sourceId,r.includes(e.sourceId))throw new Error("[Autocomplete] The `sourceId` ".concat(JSON.stringify(e.sourceId)," is not unique."));r.push(e.sourceId);var t={getItemInputValue:function(e){return e.state.query},getItemUrl:function(){},onSelect:function(e){(0,e.setIsOpen)(!1)},onActive:a,onResolve:a};Object.keys(t).forEach((function(e){t[e].__default=!0}));var n=$($({},t),e);return Promise.resolve(n)})))}))}(e,r)}))).then((function(e){return L(e)})).then((function(e){return e.map((function(e){return X(X({},e),{},{onSelect:function(r){e.onSelect(r),t.forEach((function(e){var t;return null===(t=e.onSelect)||void 0===t?void 0:t.call(e,r)}))},onActive:function(r){e.onActive(r),t.forEach((function(e){var t;return null===(t=e.onActive)||void 0===t?void 0:t.call(e,r)}))},onResolve:function(r){e.onResolve(r),t.forEach((function(e){var t;return null===(t=e.onResolve)||void 0===t?void 0:t.call(e,r)}))}})}))}))},navigator:X({navigate:function(e){var t=e.itemUrl;n.location.assign(t)},navigateNewTab:function(e){var t=e.itemUrl,r=n.open(t,"_blank","noopener");null==r||r.focus()},navigateNewWindow:function(e){var t=e.itemUrl;n.open(t,"_blank","noopener")}},e.navigator)})}function te(e){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},te(e)}function re(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ne(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var Ie,De,Ae,ke=null,xe=(Ie=-1,De=-1,Ae=void 0,function(e){var t=++Ie;return Promise.resolve(e).then((function(e){return Ae&&t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var Me=/((gt|sm)-|galaxy nexus)|samsung[- ]|samsungbrowser/i;function He(e){return He="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},He(e)}var Fe=["props","refresh","store"],Ue=["inputElement","formElement","panelElement"],Be=["inputElement"],Ve=["inputElement","maxLength"],Ke=["sourceIndex"],$e=["sourceIndex"],Je=["item","source","sourceIndex"];function ze(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function We(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Ge(e){var t=e.props,r=e.refresh,n=e.store,o=Ze(e,Fe),i=function(e,t){return void 0!==t?"".concat(e,"-").concat(t):e};return{getEnvironmentProps:function(e){var r=e.inputElement,o=e.formElement,i=e.panelElement;function a(e){!n.getState().isOpen&&n.pendingRequests.isEmpty()||e.target===r||!1===[o,i].some((function(t){return r=t,n=e.target,r===n||r.contains(n);var r,n}))&&(n.dispatch("blur",null),t.debug||n.pendingRequests.cancelAll())}return We({onTouchStart:a,onMouseDown:a,onTouchMove:function(e){!1!==n.getState().isOpen&&r===t.environment.document.activeElement&&e.target!==r&&r.blur()}},Ze(e,Ue))},getRootProps:function(e){return We({role:"combobox","aria-expanded":n.getState().isOpen,"aria-haspopup":"listbox","aria-owns":n.getState().isOpen?"".concat(t.id,"-list"):void 0,"aria-labelledby":"".concat(t.id,"-label")},e)},getFormProps:function(e){e.inputElement;return We({action:"",noValidate:!0,role:"search",onSubmit:function(i){var a;i.preventDefault(),t.onSubmit(We({event:i,refresh:r,state:n.getState()},o)),n.dispatch("submit",null),null===(a=e.inputElement)||void 0===a||a.blur()},onReset:function(i){var a;i.preventDefault(),t.onReset(We({event:i,refresh:r,state:n.getState()},o)),n.dispatch("reset",null),null===(a=e.inputElement)||void 0===a||a.focus()}},Ze(e,Be))},getLabelProps:function(e){var r=e||{},n=r.sourceIndex,o=Ze(r,Ke);return We({htmlFor:"".concat(i(t.id,n),"-input"),id:"".concat(i(t.id,n),"-label")},o)},getInputProps:function(e){var i;function c(e){(t.openOnFocus||Boolean(n.getState().query))&&Ce(We({event:e,props:t,query:n.getState().completion||n.getState().query,refresh:r,store:n},o)),n.dispatch("focus",null)}var l=e||{},u=(l.inputElement,l.maxLength),s=void 0===u?512:u,f=Ze(l,Ve),m=ge(n.getState()),p=function(e){return Boolean(e&&e.match(Me))}((null===(i=t.environment.navigator)||void 0===i?void 0:i.userAgent)||""),v=null!=m&&m.itemUrl&&!p?"go":"search";return We({"aria-autocomplete":"both","aria-activedescendant":n.getState().isOpen&&null!==n.getState().activeItemId?"".concat(t.id,"-item-").concat(n.getState().activeItemId):void 0,"aria-controls":n.getState().isOpen?"".concat(t.id,"-list"):void 0,"aria-labelledby":"".concat(t.id,"-label"),value:n.getState().completion||n.getState().query,id:"".concat(t.id,"-input"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",enterKeyHint:v,spellCheck:"false",autoFocus:t.autoFocus,placeholder:t.placeholder,maxLength:s,type:"search",onChange:function(e){Ce(We({event:e,props:t,query:e.currentTarget.value.slice(0,s),refresh:r,store:n},o))},onKeyDown:function(e){!function(e){var t=e.event,r=e.props,n=e.refresh,o=e.store,i=Le(e,Ne);if("ArrowUp"===t.key||"ArrowDown"===t.key){var a=function(){var e=r.environment.document.getElementById("".concat(r.id,"-item-").concat(o.getState().activeItemId));e&&(e.scrollIntoViewIfNeeded?e.scrollIntoViewIfNeeded(!1):e.scrollIntoView(!1))},c=function(){var e=ge(o.getState());if(null!==o.getState().activeItemId&&e){var r=e.item,a=e.itemInputValue,c=e.itemUrl,l=e.source;l.onActive(qe({event:t,item:r,itemInputValue:a,itemUrl:c,refresh:n,source:l,state:o.getState()},i))}};t.preventDefault(),!1===o.getState().isOpen&&(r.openOnFocus||Boolean(o.getState().query))?Ce(qe({event:t,props:r,query:o.getState().query,refresh:n,store:o},i)).then((function(){o.dispatch(t.key,{nextActiveItemId:r.defaultActiveItemId}),c(),setTimeout(a,0)})):(o.dispatch(t.key,{}),c(),a())}else if("Escape"===t.key)t.preventDefault(),o.dispatch(t.key,null),o.pendingRequests.cancelAll();else if("Tab"===t.key)o.dispatch("blur",null),o.pendingRequests.cancelAll();else if("Enter"===t.key){if(null===o.getState().activeItemId||o.getState().collections.every((function(e){return 0===e.items.length})))return void(r.debug||o.pendingRequests.cancelAll());t.preventDefault();var l=ge(o.getState()),u=l.item,s=l.itemInputValue,f=l.itemUrl,m=l.source;if(t.metaKey||t.ctrlKey)void 0!==f&&(m.onSelect(qe({event:t,item:u,itemInputValue:s,itemUrl:f,refresh:n,source:m,state:o.getState()},i)),r.navigator.navigateNewTab({itemUrl:f,item:u,state:o.getState()}));else if(t.shiftKey)void 0!==f&&(m.onSelect(qe({event:t,item:u,itemInputValue:s,itemUrl:f,refresh:n,source:m,state:o.getState()},i)),r.navigator.navigateNewWindow({itemUrl:f,item:u,state:o.getState()}));else if(t.altKey);else{if(void 0!==f)return m.onSelect(qe({event:t,item:u,itemInputValue:s,itemUrl:f,refresh:n,source:m,state:o.getState()},i)),void r.navigator.navigate({itemUrl:f,item:u,state:o.getState()});Ce(qe({event:t,nextState:{isOpen:!1},props:r,query:s,refresh:n,store:o},i)).then((function(){m.onSelect(qe({event:t,item:u,itemInputValue:s,itemUrl:f,refresh:n,source:m,state:o.getState()},i))}))}}}(We({event:e,props:t,refresh:r,store:n},o))},onFocus:c,onBlur:a,onClick:function(r){e.inputElement!==t.environment.document.activeElement||n.getState().isOpen||c(r)}},f)},getPanelProps:function(e){return We({onMouseDown:function(e){e.preventDefault()},onMouseLeave:function(){n.dispatch("mouseleave",null)}},e)},getListProps:function(e){var r=e||{},n=r.sourceIndex,o=Ze(r,$e);return We({role:"listbox","aria-labelledby":"".concat(i(t.id,n),"-label"),id:"".concat(i(t.id,n),"-list")},o)},getItemProps:function(e){var a=e.item,c=e.source,l=e.sourceIndex,u=Ze(e,Je);return We({id:"".concat(i(t.id,l),"-item-").concat(a.__autocomplete_id),role:"option","aria-selected":n.getState().activeItemId===a.__autocomplete_id,onMouseMove:function(e){if(a.__autocomplete_id!==n.getState().activeItemId){n.dispatch("mousemove",a.__autocomplete_id);var t=ge(n.getState());if(null!==n.getState().activeItemId&&t){var i=t.item,c=t.itemInputValue,l=t.itemUrl,u=t.source;u.onActive(We({event:e,item:i,itemInputValue:c,itemUrl:l,refresh:r,source:u,state:n.getState()},o))}}},onMouseDown:function(e){e.preventDefault()},onClick:function(e){var i=c.getItemInputValue({item:a,state:n.getState()}),l=c.getItemUrl({item:a,state:n.getState()});(l?Promise.resolve():Ce(We({event:e,nextState:{isOpen:!1},props:t,query:i,refresh:r,store:n},o))).then((function(){c.onSelect(We({event:e,item:a,itemInputValue:i,itemUrl:l,refresh:r,source:c,state:n.getState()},o))}))}},u)}}}var Xe=[{segment:"autocomplete-core",version:"1.9.3"}];function Ye(e){return Ye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ye(e)}function et(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function tt(e){for(var t=1;t=r?null===n?null:0:o}function at(e){return at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},at(e)}function ct(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function lt(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function kt(e){var t=e.translations,r=void 0===t?{}:t,n=At(e,Pt),o=r.noResultsText,i=void 0===o?"No results for":o,a=r.suggestedQueryText,c=void 0===a?"Try searching for":a,l=r.reportMissingResultsText,u=void 0===l?"Believe this query should return results?":l,s=r.reportMissingResultsLinkText,f=void 0===s?"Let us know.":s,m=n.state.context.searchSuggestions;return yt.createElement("div",{className:"DocSearch-NoResults"},yt.createElement("div",{className:"DocSearch-Screen-Icon"},yt.createElement(Et,null)),yt.createElement("p",{className:"DocSearch-Title"},i,' "',yt.createElement("strong",null,n.state.query),'"'),m&&m.length>0&&yt.createElement("div",{className:"DocSearch-NoResults-Prefill-List"},yt.createElement("p",{className:"DocSearch-Help"},c,":"),yt.createElement("ul",null,m.slice(0,3).reduce((function(e,t){return[].concat(It(e),[yt.createElement("li",{key:t},yt.createElement("button",{className:"DocSearch-Prefill",key:t,type:"button",onClick:function(){n.setQuery(t.toLowerCase()+" "),n.refresh(),n.inputRef.current.focus()}},t))])}),[]))),n.getMissingResultsUrl&&yt.createElement("p",{className:"DocSearch-Help"},"".concat(u," "),yt.createElement("a",{href:n.getMissingResultsUrl({query:n.state.query}),target:"_blank",rel:"noopener noreferrer"},f)))}var xt=function(){return yt.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20"},yt.createElement("path",{d:"M17 6v12c0 .52-.2 1-1 1H4c-.7 0-1-.33-1-1V2c0-.55.42-1 1-1h8l5 5zM14 8h-3.13c-.51 0-.87-.34-.87-.87V4",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinejoin:"round"}))};function Ct(e){switch(e.type){case"lvl1":return yt.createElement(xt,null);case"content":return yt.createElement(Nt,null);default:return yt.createElement(_t,null)}}function _t(){return yt.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20"},yt.createElement("path",{d:"M13 13h4-4V8H7v5h6v4-4H7V8H3h4V3v5h6V3v5h4-4v5zm-6 0v4-4H3h4z",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"}))}function Nt(){return yt.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20"},yt.createElement("path",{d:"M17 5H3h14zm0 5H3h14zm0 5H3h14z",stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinejoin:"round"}))}function Tt(){return yt.createElement("svg",{className:"DocSearch-Hit-Select-Icon",width:"20",height:"20",viewBox:"0 0 20 20"},yt.createElement("g",{stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},yt.createElement("path",{d:"M18 3v4c0 2-2 4-4 4H2"}),yt.createElement("path",{d:"M8 17l-6-6 6-6"})))}var qt=["hit","attribute","tagName"];function Rt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Lt(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Ft(e,t){return t.split(".").reduce((function(e,t){return null!=e&&e[t]?e[t]:null}),e)}function Ut(e){var t=e.hit,r=e.attribute,n=e.tagName,o=void 0===n?"span":n,i=Ht(e,qt);return(0,yt.createElement)(o,Lt(Lt({},i),{},{dangerouslySetInnerHTML:{__html:Ft(t,"_snippetResult.".concat(r,".value"))||Ft(t,r)}}))}function Bt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(l){c=!0,o=l}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Vt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Vt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Vt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r|<\/mark>)/g,Wt=RegExp(zt.source);function Qt(e){var t,r,n=e;if(!n.__docsearch_parent&&!e._highlightResult)return e.hierarchy.lvl0;var o=((n.__docsearch_parent?null===(t=n.__docsearch_parent)||void 0===t||null===(t=t._highlightResult)||void 0===t||null===(t=t.hierarchy)||void 0===t?void 0:t.lvl0:null===(r=e._highlightResult)||void 0===r||null===(r=r.hierarchy)||void 0===r?void 0:r.lvl0)||{}).value;return o&&Wt.test(o)?o.replace(zt,""):o}function Zt(){return Zt=Object.assign||function(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function or(e){var t=e.translations,r=void 0===t?{}:t,n=nr(e,tr),o=r.recentSearchesTitle,i=void 0===o?"Recent":o,a=r.noRecentSearchesText,c=void 0===a?"No recent searches":a,l=r.saveRecentSearchButtonTitle,u=void 0===l?"Save this search":l,s=r.removeRecentSearchButtonTitle,f=void 0===s?"Remove this search from history":s,m=r.favoriteSearchesTitle,p=void 0===m?"Favorite":m,v=r.removeFavoriteSearchButtonTitle,d=void 0===v?"Remove this search from favorites":v;return"idle"===n.state.status&&!1===n.hasCollections?n.disableUserPersonalization?null:yt.createElement("div",{className:"DocSearch-StartScreen"},yt.createElement("p",{className:"DocSearch-Help"},c)):!1===n.hasCollections?null:yt.createElement("div",{className:"DocSearch-Dropdown-Container"},yt.createElement($t,rr({},n,{title:i,collection:n.state.collections[0],renderIcon:function(){return yt.createElement("div",{className:"DocSearch-Hit-icon"},yt.createElement(Xt,null))},renderAction:function(e){var t=e.item,r=e.runFavoriteTransition,o=e.runDeleteTransition;return yt.createElement(yt.Fragment,null,yt.createElement("div",{className:"DocSearch-Hit-action"},yt.createElement("button",{className:"DocSearch-Hit-action-button",title:u,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),r((function(){n.favoriteSearches.add(t),n.recentSearches.remove(t),n.refresh()}))}},yt.createElement(Yt,null))),yt.createElement("div",{className:"DocSearch-Hit-action"},yt.createElement("button",{className:"DocSearch-Hit-action-button",title:f,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),o((function(){n.recentSearches.remove(t),n.refresh()}))}},yt.createElement(er,null))))}})),yt.createElement($t,rr({},n,{title:p,collection:n.state.collections[1],renderIcon:function(){return yt.createElement("div",{className:"DocSearch-Hit-icon"},yt.createElement(Yt,null))},renderAction:function(e){var t=e.item,r=e.runDeleteTransition;return yt.createElement("div",{className:"DocSearch-Hit-action"},yt.createElement("button",{className:"DocSearch-Hit-action-button",title:d,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),r((function(){n.favoriteSearches.remove(t),n.refresh()}))}},yt.createElement(er,null)))}})))}var ir=["translations"];function ar(){return ar=Object.assign||function(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var lr=yt.memo((function(e){var t=e.translations,r=void 0===t?{}:t,n=cr(e,ir);if("error"===n.state.status)return yt.createElement(wt,{translations:null==r?void 0:r.errorScreen});var o=n.state.collections.some((function(e){return e.items.length>0}));return n.state.query?!1===o?yt.createElement(kt,ar({},n,{translations:null==r?void 0:r.noResultsScreen})):yt.createElement(Gt,n):yt.createElement(or,ar({},n,{hasCollections:o,translations:null==r?void 0:r.startScreen}))}),(function(e,t){return"loading"===t.state.status||"stalled"===t.state.status}));function ur(){return yt.createElement("svg",{viewBox:"0 0 38 38",stroke:"currentColor",strokeOpacity:".5"},yt.createElement("g",{fill:"none",fillRule:"evenodd"},yt.createElement("g",{transform:"translate(1 1)",strokeWidth:"2"},yt.createElement("circle",{strokeOpacity:".3",cx:"18",cy:"18",r:"18"}),yt.createElement("path",{d:"M36 18c0-9.94-8.06-18-18-18"},yt.createElement("animateTransform",{attributeName:"transform",type:"rotate",from:"0 18 18",to:"360 18 18",dur:"1s",repeatCount:"indefinite"})))))}var sr=r(9188),fr=["translations"];function mr(){return mr=Object.assign||function(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function vr(e){var t=e.translations,r=void 0===t?{}:t,n=pr(e,fr),o=r.resetButtonTitle,i=void 0===o?"Clear the query":o,a=r.resetButtonAriaLabel,c=void 0===a?"Clear the query":a,l=r.cancelButtonText,u=void 0===l?"Cancel":l,s=r.cancelButtonAriaLabel,f=void 0===s?"Cancel":s,m=r.searchInputLabel,p=void 0===m?"Search":m,v=n.getFormProps({inputElement:n.inputRef.current}).onReset;return yt.useEffect((function(){n.autoFocus&&n.inputRef.current&&n.inputRef.current.focus()}),[n.autoFocus,n.inputRef]),yt.useEffect((function(){n.isFromSelection&&n.inputRef.current&&n.inputRef.current.select()}),[n.isFromSelection,n.inputRef]),yt.createElement(yt.Fragment,null,yt.createElement("form",{className:"DocSearch-Form",onSubmit:function(e){e.preventDefault()},onReset:v},yt.createElement("label",mr({className:"DocSearch-MagnifierLabel"},n.getLabelProps()),yt.createElement(sr.W,null),yt.createElement("span",{className:"DocSearch-VisuallyHiddenForAccessibility"},p)),yt.createElement("div",{className:"DocSearch-LoadingIndicator"},yt.createElement(ur,null)),yt.createElement("input",mr({className:"DocSearch-Input",ref:n.inputRef},n.getInputProps({inputElement:n.inputRef.current,autoFocus:n.autoFocus,maxLength:ht}))),yt.createElement("button",{type:"reset",title:i,className:"DocSearch-Reset","aria-label":c,hidden:!n.state.query},yt.createElement(er,null))),yt.createElement("button",{className:"DocSearch-Cancel",type:"reset","aria-label":f,onClick:n.onClose},u))}var dr=["_highlightResult","_snippetResult"];function yr(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function hr(e){return!1===function(){var e="__TEST_KEY__";try{return localStorage.setItem(e,""),localStorage.removeItem(e),!0}catch(t){return!1}}()?{setItem:function(){},getItem:function(){return[]}}:{setItem:function(t){return window.localStorage.setItem(e,JSON.stringify(t))},getItem:function(){var t=window.localStorage.getItem(e);return t?JSON.parse(t):[]}}}function br(e){var t=e.key,r=e.limit,n=void 0===r?5:r,o=hr(t),i=o.getItem().slice(0,n);return{add:function(e){var t=e,r=(t._highlightResult,t._snippetResult,yr(t,dr)),a=i.findIndex((function(e){return e.objectID===r.objectID}));a>-1&&i.splice(a,1),i.unshift(r),i=i.slice(0,n),o.setItem(i)},remove:function(e){i=i.filter((function(t){return t.objectID!==e.objectID})),o.setItem(i)},getAll:function(){return i}}}function gr(e){const t=`algoliasearch-client-js-${e.key}`;let r;const n=()=>(void 0===r&&(r=e.localStorage||window.localStorage),r),o=()=>JSON.parse(n().getItem(t)||"{}"),i=e=>{n().setItem(t,JSON.stringify(e))};return{get:(t,r,n={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{(()=>{const t=e.timeToLive?1e3*e.timeToLive:null,r=o(),n=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(i(n),!t)return;const a=Object.fromEntries(Object.entries(n).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+tPromise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||n.miss(e)]))).then((([e])=>e)),set:(e,r)=>Promise.resolve().then((()=>{const i=o();return i[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:r},n().setItem(t,JSON.stringify(i)),r})),delete:e=>Promise.resolve().then((()=>{const r=o();delete r[JSON.stringify(e)],n().setItem(t,JSON.stringify(r))})),clear:()=>Promise.resolve().then((()=>{n().removeItem(t)}))}}function Or(e){const t=[...e.caches],r=t.shift();return void 0===r?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,n,o={miss:()=>Promise.resolve()})=>r.get(e,n,o).catch((()=>Or({caches:t}).get(e,n,o))),set:(e,n)=>r.set(e,n).catch((()=>Or({caches:t}).set(e,n))),delete:e=>r.delete(e).catch((()=>Or({caches:t}).delete(e))),clear:()=>r.clear().catch((()=>Or({caches:t}).clear()))}}function Sr(e={serializable:!0}){let t={};return{get(r,n,o={miss:()=>Promise.resolve()}){const i=JSON.stringify(r);if(i in t)return Promise.resolve(e.serializable?JSON.parse(t[i]):t[i]);const a=n(),c=o&&o.miss||(()=>Promise.resolve());return a.then((e=>c(e))).then((()=>a))},set:(r,n)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}function jr(e){let t=e.length-1;for(;t>0;t--){const r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function wr(e,t){return t?(Object.keys(t).forEach((r=>{e[r]=t[r](e)})),e):e}function Er(e,...t){let r=0;return e.replace(/%s/g,(()=>encodeURIComponent(t[r++])))}const Pr="4.23.3",Ir={WithinQueryParameters:0,WithinHeaders:1};function Dr(e,t){const r=e||{},n=r.data||{};return Object.keys(r).forEach((e=>{-1===["timeout","headers","queryParameters","data","cacheable"].indexOf(e)&&(n[e]=r[e])})),{data:Object.entries(n).length>0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}const Ar={Read:1,Write:2,Any:3},kr={Up:1,Down:2,Timeouted:3},xr=12e4;function Cr(e,t=kr.Up){return{...e,status:t,lastUpdate:Date.now()}}function _r(e){return"string"==typeof e?{protocol:"https",url:e,accept:Ar.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||Ar.Any}}const Nr={Delete:"DELETE",Get:"GET",Post:"POST",Put:"PUT"};function Tr(e,t){return Promise.all(t.map((t=>e.get(t,(()=>Promise.resolve(Cr(t))))))).then((e=>{const r=e.filter((e=>function(e){return e.status===kr.Up||Date.now()-e.lastUpdate>xr}(e))),n=e.filter((e=>function(e){return e.status===kr.Timeouted&&Date.now()-e.lastUpdate<=xr}(e))),o=[...r,...n];return{getTimeout:(e,t)=>(0===n.length&&0===e?1:n.length+3+e)*t,statelessHosts:o.length>0?o.map((e=>_r(e))):t}}))}const qr=(e,t)=>(e=>{const t=e.status;return e.isTimedOut||(({isTimedOut:e,status:t})=>!e&&!~~t)(e)||2!=~~(t/100)&&4!=~~(t/100)})(e)?t.onRetry(e):(({status:e})=>2==~~(e/100))(e)?t.onSuccess(e):t.onFail(e);function Rr(e,t,r,n){const o=[],i=function(e,t){if(e.method===Nr.Get||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(r,n),a=function(e,t){const r={...e.headers,...t.headers},n={};return Object.keys(r).forEach((e=>{const t=r[e];n[e.toLowerCase()]=t})),n}(e,n),c=r.method,l=r.method!==Nr.Get?{}:{...r.data,...n.data},u={"x-algolia-agent":e.userAgent.value,...e.queryParameters,...l,...n.queryParameters};let s=0;const f=(t,l)=>{const m=t.pop();if(void 0===m)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:Fr(o)};const p={data:i,headers:a,method:c,url:Mr(m,r.path,u),connectTimeout:l(s,e.timeouts.connect),responseTimeout:l(s,n.timeout)},v=e=>{const r={request:p,response:e,host:m,triesLeft:t.length};return o.push(r),r},d={onSuccess:e=>function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e),onRetry(r){const n=v(r);return r.isTimedOut&&s++,Promise.all([e.logger.info("Retryable failure",Ur(n)),e.hostsCache.set(m,Cr(m,r.isTimedOut?kr.Timeouted:kr.Down))]).then((()=>f(t,l)))},onFail(e){throw v(e),function({content:e,status:t},r){let n=e;try{n=JSON.parse(e).message}catch(o){}return function(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}(n,t,r)}(e,Fr(o))}};return e.requester.send(p).then((e=>qr(e,d)))};return Tr(e.hostsCache,t).then((e=>f([...e.statelessHosts].reverse(),e.getTimeout)))}function Lr(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}function Mr(e,t,r){const n=Hr(r);let o=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return n.length&&(o+=`?${n}`),o}function Hr(e){return Object.keys(e).map((t=>{return Er("%s=%s",t,(r=e[t],"[object Object]"===Object.prototype.toString.call(r)||"[object Array]"===Object.prototype.toString.call(r)?JSON.stringify(e[t]):e[t]));var r})).join("&")}function Fr(e){return e.map((e=>Ur(e)))}function Ur(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}const Br=e=>{const t=e.appId,r=function(e,t,r){const n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:()=>e===Ir.WithinHeaders?n:{},queryParameters:()=>e===Ir.WithinQueryParameters?n:{}}}(void 0!==e.authMode?e.authMode:Ir.WithinHeaders,t,e.apiKey),n=function(e){const{hostsCache:t,logger:r,requester:n,requestsCache:o,responsesCache:i,timeouts:a,userAgent:c,hosts:l,queryParameters:u,headers:s}=e,f={hostsCache:t,logger:r,requester:n,requestsCache:o,responsesCache:i,timeouts:a,userAgent:c,headers:s,queryParameters:u,hosts:l.map((e=>_r(e))),read(e,t){const r=Dr(t,f.timeouts.read),n=()=>Rr(f,f.hosts.filter((e=>!!(e.accept&Ar.Read))),e,r);if(!0!==(void 0!==r.cacheable?r.cacheable:e.cacheable))return n();const o={request:e,mappedRequestOptions:r,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(o,(()=>f.requestsCache.get(o,(()=>f.requestsCache.set(o,n()).then((e=>Promise.all([f.requestsCache.delete(o),e])),(e=>Promise.all([f.requestsCache.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>f.responsesCache.set(o,e)})},write:(e,t)=>Rr(f,f.hosts.filter((e=>!!(e.accept&Ar.Write))),e,Dr(t,f.timeouts.write))};return f}({hosts:[{url:`${t}-dsn.algolia.net`,accept:Ar.Read},{url:`${t}.algolia.net`,accept:Ar.Write}].concat(jr([{url:`${t}-1.algolianet.com`},{url:`${t}-2.algolianet.com`},{url:`${t}-3.algolianet.com`}])),...e,headers:{...r.headers(),"content-type":"application/x-www-form-urlencoded",...e.headers},queryParameters:{...r.queryParameters(),...e.queryParameters}}),o={transporter:n,appId:t,addAlgoliaAgent(e,t){n.userAgent.add({segment:e,version:t})},clearCache:()=>Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then((()=>{}))};return wr(o,e.methods)},Vr=e=>(t,r)=>t.method===Nr.Get?e.transporter.read(t,r):e.transporter.write(t,r),Kr=e=>(t,r={})=>wr({transporter:e.transporter,appId:e.appId,indexName:t},r.methods),$r=e=>(t,r)=>{const n=t.map((e=>({...e,params:Hr(e.params||{})})));return e.transporter.read({method:Nr.Post,path:"1/indexes/*/queries",data:{requests:n},cacheable:!0},r)},Jr=e=>(t,r)=>Promise.all(t.map((t=>{const{facetName:n,facetQuery:o,...i}=t.params;return Kr(e)(t.indexName,{methods:{searchForFacetValues:Qr}}).searchForFacetValues(n,o,{...r,...i})}))),zr=e=>(t,r,n)=>e.transporter.read({method:Nr.Post,path:Er("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n),Wr=e=>(t,r)=>e.transporter.read({method:Nr.Post,path:Er("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r),Qr=e=>(t,r,n)=>e.transporter.read({method:Nr.Post,path:Er("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n),Zr={Debug:1,Info:2,Error:3};const Gr=e=>(t,r)=>{const n=t.map((e=>({...e,threshold:e.threshold||0})));return e.transporter.read({method:Nr.Post,path:"1/indexes/*/recommendations",data:{requests:n},cacheable:!0},r)};function Xr(e,t,r){const n={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:e=>new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const n=(e,n)=>setTimeout((()=>{r.abort(),t({status:0,content:n,isTimedOut:!0})}),1e3*e),o=n(e.connectTimeout,"Connection timeout");let i;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===i&&(clearTimeout(o),i=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(o),clearTimeout(i),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(o),clearTimeout(i),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))},logger:(o=Zr.Error,{debug:(e,t)=>(Zr.Debug>=o&&console.debug(e,t),Promise.resolve()),info:(e,t)=>(Zr.Info>=o&&console.info(e,t),Promise.resolve()),error:(e,t)=>(console.error(e,t),Promise.resolve())}),responsesCache:Sr(),requestsCache:Sr({serializable:!1}),hostsCache:Or({caches:[gr({key:`${Pr}-${e}`}),Sr()]}),userAgent:Lr(Pr).add({segment:"Browser",version:"lite"}),authMode:Ir.WithinQueryParameters};var o;return Br({...n,...r,methods:{search:$r,searchForFacetValues:Jr,multipleQueries:$r,multipleSearchForFacetValues:Jr,customRequest:Vr,initIndex:e=>t=>Kr(e)(t,{methods:{search:Wr,searchForFacetValues:Qr,findAnswers:zr}}),getRecommendations:Gr}})}Xr.version=Pr;const Yr=Xr;var en="3.6.0";function tn(){}function rn(e){return e}function nn(e){return 1===e.button||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}function on(e,t,r){return e.reduce((function(e,n){var o=t(n);return e.hasOwnProperty(o)||(e[o]=[]),e[o].length<(r||5)&&e[o].push(n),e}),{})}var an=["footer","searchBox"];function cn(){return cn=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function vn(e){var t=e.appId,r=e.apiKey,n=e.indexName,o=e.placeholder,i=void 0===o?"Search docs":o,a=e.searchParameters,c=e.maxResultsPerGroup,l=e.onClose,u=void 0===l?tn:l,s=e.transformItems,f=void 0===s?rn:s,m=e.hitComponent,p=void 0===m?St:m,v=e.resultsFooterComponent,d=void 0===v?function(){return null}:v,y=e.navigator,h=e.initialScrollY,b=void 0===h?0:h,g=e.transformSearchClient,O=void 0===g?rn:g,S=e.disableUserPersonalization,j=void 0!==S&&S,w=e.initialQuery,E=void 0===w?"":w,P=e.translations,I=void 0===P?{}:P,D=e.getMissingResultsUrl,A=e.insights,k=void 0!==A&&A,x=I.footer,C=I.searchBox,_=pn(I,an),N=fn(yt.useState({query:"",collections:[],completion:null,context:{},isOpen:!1,activeItemId:null,status:"idle"}),2),T=N[0],q=N[1],R=yt.useRef(null),L=yt.useRef(null),M=yt.useRef(null),H=yt.useRef(null),F=yt.useRef(null),U=yt.useRef(10),B=yt.useRef("undefined"!=typeof window?window.getSelection().toString().slice(0,ht):"").current,V=yt.useRef(E||B).current,K=function(e,t,r){return yt.useMemo((function(){var n=Yr(e,t);return n.addAlgoliaAgent("docsearch",en),!1===/docsearch.js \(.*\)/.test(n.transporter.userAgent.value)&&n.addAlgoliaAgent("docsearch-react",en),r(n)}),[e,t,r])}(t,r,O),$=yt.useRef(br({key:"__DOCSEARCH_FAVORITE_SEARCHES__".concat(n),limit:10})).current,J=yt.useRef(br({key:"__DOCSEARCH_RECENT_SEARCHES__".concat(n),limit:0===$.getAll().length?7:4})).current,z=yt.useCallback((function(e){if(!j){var t="content"===e.type?e.__docsearch_parent:e;t&&-1===$.getAll().findIndex((function(e){return e.objectID===t.objectID}))&&J.add(t)}}),[$,J,j]),W=yt.useCallback((function(e){if(T.context.algoliaInsightsPlugin&&e.__autocomplete_id){var t=e,r={eventName:"Item Selected",index:t.__autocomplete_indexName,items:[t],positions:[e.__autocomplete_id],queryID:t.__autocomplete_queryID};T.context.algoliaInsightsPlugin.insights.clickedObjectIDsAfterSearch(r)}}),[T.context.algoliaInsightsPlugin]),Q=yt.useMemo((function(){return dt({id:"docsearch",defaultActiveItemId:0,placeholder:i,openOnFocus:!0,initialState:{query:V,context:{searchSuggestions:[]}},insights:k,navigator:y,onStateChange:function(e){q(e.state)},getSources:function(e){var o=e.query,i=e.state,l=e.setContext,s=e.setStatus;if(!o)return j?[]:[{sourceId:"recentSearches",onSelect:function(e){var t=e.item,r=e.event;z(t),nn(r)||u()},getItemUrl:function(e){return e.item.url},getItems:function(){return J.getAll()}},{sourceId:"favoriteSearches",onSelect:function(e){var t=e.item,r=e.event;z(t),nn(r)||u()},getItemUrl:function(e){return e.item.url},getItems:function(){return $.getAll()}}];var m=Boolean(k);return K.search([{query:o,indexName:n,params:un({attributesToRetrieve:["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"],attributesToSnippet:["hierarchy.lvl1:".concat(U.current),"hierarchy.lvl2:".concat(U.current),"hierarchy.lvl3:".concat(U.current),"hierarchy.lvl4:".concat(U.current),"hierarchy.lvl5:".concat(U.current),"hierarchy.lvl6:".concat(U.current),"content:".concat(U.current)],snippetEllipsisText:"\u2026",highlightPreTag:"",highlightPostTag:"",hitsPerPage:20,clickAnalytics:m},a)}]).catch((function(e){throw"RetryError"===e.name&&s("error"),e})).then((function(e){var o=e.results[0],a=o.hits,s=o.nbHits,p=on(a,(function(e){return Qt(e)}),c);i.context.searchSuggestions.length0&&(X(),F.current&&F.current.focus())}),[V,X]),yt.useEffect((function(){function e(){if(L.current){var e=.01*window.innerHeight;L.current.style.setProperty("--docsearch-vh","".concat(e,"px"))}}return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),yt.createElement("div",cn({ref:R},G({"aria-expanded":!0}),{className:["DocSearch","DocSearch-Container","stalled"===T.status&&"DocSearch-Container--Stalled","error"===T.status&&"DocSearch-Container--Errored"].filter(Boolean).join(" "),role:"button",tabIndex:0,onMouseDown:function(e){e.target===e.currentTarget&&u()}}),yt.createElement("div",{className:"DocSearch-Modal",ref:L},yt.createElement("header",{className:"DocSearch-SearchBar",ref:M},yt.createElement(vr,cn({},Q,{state:T,autoFocus:0===V.length,inputRef:F,isFromSelection:Boolean(V)&&V===B,translations:C,onClose:u}))),yt.createElement("div",{className:"DocSearch-Dropdown",ref:H},yt.createElement(lr,cn({},Q,{indexName:n,state:T,hitComponent:p,resultsFooterComponent:d,disableUserPersonalization:j,recentSearches:J,favoriteSearches:$,inputRef:F,translations:_,getMissingResultsUrl:D,onItemClick:function(e,t){W(e),z(e),nn(t)||u()}}))),yt.createElement("footer",{className:"DocSearch-Footer"},yt.createElement(Ot,{translations:x}))))}}}]); \ No newline at end of file diff --git a/assets/js/59b1a96c.19376fa2.js b/assets/js/59b1a96c.19376fa2.js deleted file mode 100644 index a9d604a76..000000000 --- a/assets/js/59b1a96c.19376fa2.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[485],{7777:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>c,frontMatter:()=>s,metadata:()=>d,toc:()=>o});var t=i(4848),r=i(8453);const s={sidebar_position:0,sidebar_label:"\ud83d\udd25 Prologue",slug:"/",hide_table_of_contents:!0,description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",keywords:["c++ orm","prologue","tinyorm"]},a="Prologue",d={id:"README",title:"Prologue",description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",source:"@site/docs/README.mdx",sourceDirName:".",slug:"/",permalink:"/",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"\ud83d\udd25 Prologue",slug:"/",hide_table_of_contents:!0,description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",keywords:["c++ orm","prologue","tinyorm"]},sidebar:"tinyormSidebar",next:{title:"\ud83d\udd27 Dependencies",permalink:"/dependencies"}},l={},o=[{value:"Documentation Sitemap",id:"documentation-sitemap",level:5},{value:"Current versions",id:"current-versions",level:5}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h5:"h5",li:"li",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"prologue",children:"Prologue"}),"\n",(0,t.jsxs)(n.p,{children:["TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the ",(0,t.jsx)(n.code,{children:"QtCore"})," and ",(0,t.jsx)(n.code,{children:"QtSql"})," libraries."]}),"\n",(0,t.jsxs)(n.p,{children:["The code is written in the modern C++20 way and is ",(0,t.jsx)(n.strong,{children:"heavily"})," tested with ",(0,t.jsx)(n.strong,{children:"3378"})," unit and functional tests. Almost all the query builder methods are unit tested. The TinyORM's query builder code and the code which is responsible for obtaining relationships, is tested by functional tests against all supported databases. The code coverage is good enough to guarantee API and behavior compatibility."]}),"\n",(0,t.jsx)(n.admonition,{type:"tip",children:(0,t.jsxs)(n.p,{children:["For a quick look at what's inside, check out the ",(0,t.jsx)(n.a,{href:"/features-summary",children:"Features Summary"}),"."]})}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["If you don't want to use full ",(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:(0,t.jsx)(n.code,{children:"ORM"})}),", then you can use only the ",(0,t.jsx)(n.a,{href:"/database/query-builder",children:(0,t.jsx)(n.code,{children:"Query Builder"})}),", which is outstanding. \ud83d\udd25 This way you can avoid writing raw SQL queries and your code will run on all ",(0,t.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"}),"."]})}),"\n",(0,t.jsx)(n.h5,{id:"documentation-sitemap",children:"Documentation Sitemap"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/dependencies",children:"Dependencies"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/database/getting-started",children:"Database"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/getting-started",children:"Getting Started"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/query-builder",children:"Query Builder"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/migrations",children:"Migrations"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/seeding",children:"Seeding"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:"Getting Started"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/relationships",children:"Relationships"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"Collections"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/casts",children:"Casts"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/serialization",children:"Serialization"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"TinyDrivers"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"Getting Started"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/building/tinyorm",children:"Building"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/tinyorm",children:"TinyORM"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/hello-world",children:"Hello world"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/migrations",children:"Migrations"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/features-summary",children:"Features Summary"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/sponsors",children:"Sponsors"})}),"\n"]}),"\n",(0,t.jsx)(n.h5,{id:"current-versions",children:"Current versions"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyORM"})," v0.38.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"tom"})," v0.10.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyDrivers"})," v0.2.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyMySql"})," v0.2.0"]}),"\n"]})]})}function c(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>a,x:()=>d});var t=i(6540);const r={},s=t.createContext(r);function a(e){const n=t.useContext(s);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/59b1a96c.b7f822ba.js b/assets/js/59b1a96c.b7f822ba.js new file mode 100644 index 000000000..530818e2a --- /dev/null +++ b/assets/js/59b1a96c.b7f822ba.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[485],{7777:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>c,frontMatter:()=>s,metadata:()=>d,toc:()=>o});var t=i(4848),r=i(8453);const s={sidebar_position:0,sidebar_label:"\ud83d\udd25 Prologue",slug:"/",hide_table_of_contents:!0,description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",keywords:["c++ orm","prologue","tinyorm"]},a="Prologue",d={id:"README",title:"Prologue",description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",source:"@site/docs/README.mdx",sourceDirName:".",slug:"/",permalink:"/",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"\ud83d\udd25 Prologue",slug:"/",hide_table_of_contents:!0,description:"TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the QtCore and QtSql libraries. The code is written in the modern C++20 way and is heavily tested with 3378 unit and functional tests.",keywords:["c++ orm","prologue","tinyorm"]},sidebar:"tinyormSidebar",next:{title:"\ud83d\udd27 Dependencies",permalink:"/dependencies"}},l={},o=[{value:"Documentation Sitemap",id:"documentation-sitemap",level:5},{value:"Current versions",id:"current-versions",level:5}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h5:"h5",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"prologue",children:"Prologue"})}),"\n",(0,t.jsxs)(n.p,{children:["TinyORM is a modern C++ ORM library that makes interacting with a database extremely simple. It depends on the ",(0,t.jsx)(n.code,{children:"QtCore"})," and ",(0,t.jsx)(n.code,{children:"QtSql"})," libraries."]}),"\n",(0,t.jsxs)(n.p,{children:["The code is written in the modern C++20 way and is ",(0,t.jsx)(n.strong,{children:"heavily"})," tested with ",(0,t.jsx)(n.strong,{children:"3378"})," unit and functional tests. Almost all the query builder methods are unit tested. The TinyORM's query builder code and the code which is responsible for obtaining relationships, is tested by functional tests against all supported databases. The code coverage is good enough to guarantee API and behavior compatibility."]}),"\n",(0,t.jsx)(n.admonition,{type:"tip",children:(0,t.jsxs)(n.p,{children:["For a quick look at what's inside, check out the ",(0,t.jsx)(n.a,{href:"/features-summary",children:"Features Summary"}),"."]})}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["If you don't want to use full ",(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:(0,t.jsx)(n.code,{children:"ORM"})}),", then you can use only the ",(0,t.jsx)(n.a,{href:"/database/query-builder",children:(0,t.jsx)(n.code,{children:"Query Builder"})}),", which is outstanding. \ud83d\udd25 This way you can avoid writing raw SQL queries and your code will run on all ",(0,t.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"}),"."]})}),"\n",(0,t.jsx)(n.h5,{id:"documentation-sitemap",children:"Documentation Sitemap"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/dependencies",children:"Dependencies"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/supported-compilers",children:"Supported Compilers"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/database/getting-started",children:"Database"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/getting-started",children:"Getting Started"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/query-builder",children:"Query Builder"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/migrations",children:"Migrations"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/database/seeding",children:"Seeding"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/getting-started",children:"Getting Started"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/relationships",children:"Relationships"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/collections",children:"Collections"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/casts",children:"Casts"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinyorm/serialization",children:"Serialization"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"TinyDrivers"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/tinydrivers/getting-started",children:"Getting Started"})}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"/building/tinyorm",children:"Building"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/tinyorm",children:"TinyORM"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/hello-world",children:"Hello world"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/building/migrations",children:"Migrations"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/features-summary",children:"Features Summary"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/sponsors",children:"Sponsors"})}),"\n"]}),"\n",(0,t.jsx)(n.h5,{id:"current-versions",children:"Current versions"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyORM"})," v0.38.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"tom"})," v0.10.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyDrivers"})," v0.2.0"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"TinyMySql"})," v0.2.0"]}),"\n"]})]})}function c(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>a,x:()=>d});var t=i(6540);const r={},s=t.createContext(r);function a(e){const n=t.useContext(s);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/5b254f70.d6445683.js b/assets/js/5b254f70.d6445683.js deleted file mode 100644 index a2bff00f6..000000000 --- a/assets/js/5b254f70.d6445683.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[82],{560:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>c});var i=t(4848),s=t(8453),a=t(8774);const l={sidebar_position:0,sidebar_label:"Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',keywords:["c++ orm","orm","getting started","tinyorm"]},d="TinyORM: Getting Started",r={id:"tinyorm/getting-started",title:"TinyORM: Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',source:"@site/docs/tinyorm/getting-started.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/getting-started",permalink:"/tinyorm/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',keywords:["c++ orm","orm","getting started","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Seeding",permalink:"/database/seeding"},next:{title:"Relationships",permalink:"/tinyorm/relationships"}},o={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Generating Model Classes",id:"generating-model-classes",level:2},{value:"TinyORM Model Conventions",id:"tinyorm-model-conventions",level:2},{value:"Table Names",id:"table-names",level:3},{value:"Primary Keys",id:"primary-keys",level:3},{value:""Composite" Primary Keys",id:"composite-primary-keys",level:4},{value:"Timestamps",id:"timestamps",level:3},{value:"Unix timestamps",id:"unix-timestamps",level:5},{value:"Custom timestamp column names",id:"custom-timestamp-column-names",level:5},{value:"Touching timestamps",id:"touching-timestamps",level:4},{value:"Database Connections",id:"database-connections",level:3},{value:"Default Attribute Values",id:"default-attribute-values",level:2},{value:"QDateTime and connection name problem",id:"qdatetime-and-connection-name-problem",level:5},{value:"Retrieving Models",id:"retrieving-models",level:2},{value:"Building Queries",id:"building-queries",level:4},{value:"Refreshing Models",id:"refreshing-models",level:4},{value:"Containers",id:"containers",level:3},{value:"Chunking Results",id:"chunking-results",level:3},{value:"Advanced Subqueries",id:"advanced-subqueries",level:3},{value:"Subquery Selects",id:"subquery-selects",level:4},{value:"Subquery Ordering",id:"subquery-ordering",level:4},{value:"Retrieving Single Models / Aggregates",id:"retrieving-single-models-and-aggregates",level:2},{value:"Not Found Exceptions",id:"not-found-exceptions",level:4},{value:"Retrieving Or Creating Models",id:"retrieving-or-creating-models",level:3},{value:"Retrieving Aggregates",id:"retrieving-aggregates",level:3},{value:"Inserting & Updating Models",id:"inserting-and-updating-models",level:2},{value:"Inserts",id:"inserts",level:3},{value:"Updates",id:"updates",level:3},{value:"Mass Updates",id:"mass-updates",level:4},{value:"Examining Attribute Changes",id:"examining-attribute-changes",level:4},{value:"Mass Assignment",id:"mass-assignment",level:3},{value:"Allowing Mass Assignment",id:"allowing-mass-assignment",level:4},{value:"Upserts",id:"upserts",level:3},{value:"Deleting Models",id:"deleting-models",level:2},{value:"Deleting An Existing Model By Its Primary Key",id:"deleting-an-existing-model-by-its-primary-key",level:4},{value:"Deleting Models Using Queries",id:"deleting-models-using-queries",level:4},{value:"Soft Deleting",id:"soft-deleting",level:3},{value:"Restoring Soft Deleted Models",id:"restoring-soft-deleted-models",level:4},{value:"Permanently Deleting Models",id:"permanently-deleting-models",level:4},{value:"Querying Soft Deleted Models",id:"querying-soft-deleted-models",level:3},{value:"Including Soft Deleted Models",id:"including-soft-deleted-models",level:4},{value:"Retrieving Only Soft Deleted Models",id:"retrieving-only-soft-deleted-models",level:4},{value:"Excluding Soft Deleted Models",id:"excluding-soft-deleted-models",level:4},{value:"Truncate Table",id:"truncate-table",level:3},{value:"Replicating Models",id:"replicating-models",level:2},{value:"Comparing Models",id:"comparing-models",level:2},{value:"Equality comparison",id:"equality-comparison",level:5}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"tinyorm-getting-started",children:"TinyORM: Getting Started"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#generating-model-classes",children:"Generating Model Classes"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#tinyorm-model-conventions",children:"TinyORM Model Conventions"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#table-names",children:"Table Names"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#primary-keys",children:"Primary Keys"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#timestamps",children:"Timestamps"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#database-connections",children:"Database Connections"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#default-attribute-values",children:"Default Attribute Values"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#retrieving-models",children:"Retrieving Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#containers",children:"Containers"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#chunking-results",children:"Chunking Results"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#advanced-subqueries",children:"Advanced Subqueries"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#retrieving-single-models-and-aggregates",children:"Retrieving Single Models / Aggregates"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#retrieving-or-creating-models",children:"Retrieving Or Creating Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#retrieving-aggregates",children:"Retrieving Aggregates"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#inserting-and-updating-models",children:"Inserting & Updating Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#inserts",children:"Inserts"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#updates",children:"Updates"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#mass-assignment",children:"Mass Assignment"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#upserts",children:"Upserts"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#deleting-models",children:"Deleting Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#soft-deleting",children:"Soft Deleting"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#querying-soft-deleted-models",children:"Querying Soft Deleted Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#truncate-table",children:"Truncate Table"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#replicating-models",children:"Replicating Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#comparing-models",children:"Comparing Models"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{class:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsx)(n.p,{children:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.'}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["Before getting started, be sure to configure a database connection in your application. For more information on configuring your database, check out the ",(0,i.jsx)(n.a,{href:"/database/getting-started#configuration",children:"database configuration documentation"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["If you want to see a model in which are used all possible TinyORM features you can look at the ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/models/models/torrent.hpp",children:(0,i.jsx)(n.code,{children:"torrent.hpp"})})," in the TinyORM's tests, this ",(0,i.jsx)(n.code,{children:"Models::Torrent"})," class serves also as a showcase, so all possible features are defined in it."]})}),"\n",(0,i.jsx)(n.h2,{id:"generating-model-classes",children:"Generating Model Classes"}),"\n",(0,i.jsxs)(n.p,{children:["To get started, let's create the simplest TinyORM model. Models typically live in the ",(0,i.jsx)(n.code,{children:"database\\models"})," directory and extend the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class. You may use the ",(0,i.jsx)(n.code,{children:"make:model"})," command to generate a new model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User\n"})}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to generate a database ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"migration"})," or ",(0,i.jsx)(n.a,{href:"/database/seeding",children:"seeder"})," when you generate the model, you may use the ",(0,i.jsx)(n.code,{children:"--migration"}),"/",(0,i.jsx)(n.code,{children:"-m"})," or ",(0,i.jsx)(n.code,{children:"--seeder"}),"/",(0,i.jsx)(n.code,{children:"-s"})," options:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User --migration --seeder\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"--force"})," option forces overwriting of existing files:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User --migration --seeder --force\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"make:model"})," is king \ud83d\udc51 among scaffolding commands that you can use to generate complete TinyORM model classes, it supports all features that TinyORM models offer. All advanced features are described in the ",(0,i.jsx)(n.code,{children:"make:model"})," help command:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model --help\n"})}),"\n",(0,i.jsx)(n.p,{children:"Few examples:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-powershell",children:"# Setting some model attributes\ntom make:model User --table=users --fillable=name,email,banned_at `\n --guarded=password --dates=banned_at\n\n# Generate relationship methods\ntom make:model User --one-to-one=Passport `\n --one-to-many=Post --foreign-key=post_id `\n --one-to-many=Car\n\n# Generate a basic many-to-many relationship\ntom make:model User --belongs-to-many=Tag --with-timestamps\n\n# Generate a many-to-many relationship\ntom make:model User --belongs-to-many=Tag --foreign-key=tag_id `\n --pivot-table=user_tag --as=tagged `\n --with-pivot=active,soft --with-timestamps `\n --pivot=Tagged\n\n# Generate a pivot model\ntom make:model Tagged --pivot-model\ntom make:model Tagged --pivot-model --incrementing\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Writing a ",(0,i.jsx)(n.code,{children:"make:model"})," commands is superb with the ",(0,i.jsx)(n.a,{href:"/database/migrations#tab-completion",children:"tab completion"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"--path"})," and ",(0,i.jsx)(n.code,{children:"--realpath"})," options work the same as for the ",(0,i.jsx)(n.a,{href:"/database/migrations#generating-migrations",children:(0,i.jsx)(n.code,{children:"make:migration"})})," command."]})}),"\n",(0,i.jsx)(n.h2,{id:"tinyorm-model-conventions",children:"TinyORM Model Conventions"}),"\n",(0,i.jsx)(n.p,{children:"Let's examine a basic model class and discuss some of TinyORM's key conventions:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#pragma once\n#ifndef FLIGHT_HPP\n#define FLIGHT_HPP\n\n#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n};\n\n#endif // FLIGHT_HPP\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/models/models/torrent.hpp#L45",children:(0,i.jsx)(n.code,{children:"Torrent"})})," example model that also acts as the full-fledged example model. It has defined and also nicely commented all possible features that model classes can use or define."]})}),"\n",(0,i.jsx)(n.h3,{id:"table-names",children:"Table Names"}),"\n",(0,i.jsxs)(n.p,{children:["After glancing at the example above, you may have noticed that we did not tell TinyORM which database table corresponds to our ",(0,i.jsx)(n.code,{children:"Flight"}),' model. By convention, the "snake_case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, TinyORM will assume the ',(0,i.jsx)(n.code,{children:"Flight"})," model stores records in the ",(0,i.jsx)(n.code,{children:"flights"})," table, while an ",(0,i.jsx)(n.code,{children:"AirTrafficController"})," model would store records in an ",(0,i.jsx)(n.code,{children:"air_traffic_controllers"})," table."]}),"\n",(0,i.jsxs)(n.p,{children:["If your model's corresponding database table does not fit this convention, you may manually specify the model's table name by defining the private ",(0,i.jsx)(n.code,{children:"u_table"})," data member on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The table associated with the model. */\n QString u_table {"flights"};\n};\n'})}),"\n",(0,i.jsx)(n.h3,{id:"primary-keys",children:"Primary Keys"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM will also assume that each model's corresponding database table has a primary key column named ",(0,i.jsx)(n.code,{children:"id"}),". If necessary, you may define a private ",(0,i.jsx)(n.code,{children:"u_primaryKey"})," data member on your model to specify a different column that serves as your model's primary key:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The primary key associated with the table. */\n QString u_primaryKey {"id"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In addition, TinyORM assumes that the primary key is an incrementing integer value. If you wish to use a non-incrementing or a non-numeric primary key you must define a private ",(0,i.jsx)(n.code,{children:"u_incrementing"})," data member on your model that is set to ",(0,i.jsx)(n.code,{children:"false"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! Indicates if the model's ID is auto-incrementing. */\n bool u_incrementing = false;\n};\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["Non-numeric primary keys are not currently implemented, ",(0,i.jsx)(n.code,{children:"u_incrementing"})," code logic is fully implemented, but it is only one part to make it fully work."]})}),"\n",(0,i.jsx)(n.h4,{id:"composite-primary-keys",children:'"Composite" Primary Keys'}),"\n",(0,i.jsx)(n.p,{children:'TinyORM requires each model to have at least one uniquely identifying "ID" that can serve as its primary key. "Composite" primary keys are not supported by TinyORM models. However, you are free to add additional multi-column unique indexes to your database tables, in addition to the table\'s uniquely identifying primary key.'}),"\n",(0,i.jsx)(n.h3,{id:"timestamps",children:"Timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["By default, TinyORM expects ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," columns to exist on your model's corresponding database table. TinyORM will automatically set these column's values when models are created or updated. If you do not want these columns to be automatically managed by TinyORM, you should define a private ",(0,i.jsx)(n.code,{children:"u_timestamps"})," data member on your model with a value of ",(0,i.jsx)(n.code,{children:"false"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! Indicates if the model should be timestamped. */\n bool u_timestamps = false;\n};\n"})}),"\n",(0,i.jsx)(a.A,{id:"timestamps-u_dates"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"u_dates"})," static data member controls the casting of timestamp attributes. The ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," columns are automatically added to the ",(0,i.jsx)(n.code,{children:"u_dates"})," string list when the ",(0,i.jsx)(n.code,{children:"u_timestamps"})," is ",(0,i.jsx)(n.code,{children:"true"}),". Also, the ",(0,i.jsx)(n.a,{href:"#soft-deleting",children:(0,i.jsx)(n.code,{children:"Soft Deleting"})})," feature adds the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to the ",(0,i.jsx)(n.code,{children:"u_dates"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You may add additional columns to the ",(0,i.jsx)(n.code,{children:"u_dates"})," list. After that, these columns will be automatically formatted using the format in the ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," data member during the ",(0,i.jsx)(n.code,{children:"setAttribute"})," method call:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'class Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The attributes that should be mutated to dates. */\n inline static const QStringList u_dates {"departure_at"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the format of your model's timestamps, set the private ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," data member on your model. This data member determines how date attributes are stored in the database, supported formats are described in the ",(0,i.jsx)(n.code,{children:"QDateTime"})," documentation:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The storage format of the model\'s date columns. */\n QString u_dateFormat {"yyyy-MM-dd HH:mm:ss"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the format of your model's time columns, set the private ",(0,i.jsx)(n.code,{children:"u_timeFormat"})," data member on your model. This data member determines how time attributes are stored in the database, supported formats are described in the ",(0,i.jsx)(n.code,{children:"QTime"})," documentation. The default value for ",(0,i.jsx)(n.code,{children:"u_timeFormat"})," is ",(0,i.jsx)(n.code,{children:"HH:mm:ss"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'/*! The storage format of the model\'s time columns. */\nQString u_timeFormat {"HH:mm:ss.zzz"};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The default value for datetime or timestamp columns is ",(0,i.jsx)(n.code,{children:"yyyy-MM-dd HH:mm:ss"})," and for time columns is ",(0,i.jsx)(n.code,{children:"HH:mm:ss"}),"."]}),"\n",(0,i.jsx)(n.h5,{id:"unix-timestamps",children:"Unix timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["You can set the ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," to ",(0,i.jsx)(n.code,{children:"U"})," if you want to store dates in the database as Unix timestamps:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"QString u_dateFormat {QLatin1Char('U')};\n"})}),"\n",(0,i.jsxs)(n.p,{children:["In this case ",(0,i.jsx)(n.strong,{children:"all"})," date attributes set in the ",(0,i.jsx)(n.code,{children:"u_dates"})," will be handled as Unix timestamps, so also the ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamp attributes."]}),"\n",(0,i.jsxs)(n.p,{children:["To create Unix timestamp columns using the ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"tom migrations"})," you should use ",(0,i.jsx)(n.code,{children:"integer"})," types:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Schema::table("flights", [](Blueprint &table)\n{\n table.bigInteger("created_at").nullable();\n table.bigInteger("updated_at").nullable();\n});\n'})}),"\n",(0,i.jsx)(n.h5,{id:"custom-timestamp-column-names",children:"Custom timestamp column names"}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the names of the columns used to store the timestamps, you may define ",(0,i.jsx)(n.code,{children:"CREATED_AT"})," and ",(0,i.jsx)(n.code,{children:"UPDATED_AT"})," private static getter methods on your model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The name of the "created at" column. */\n static QString CREATED_AT() { return QStringLiteral("creation_date"); }\n /*! The name of the "updated at" column. */\n static QString UPDATED_AT() { return QStringLiteral("updated_date"); }\n};\n'})}),"\n",(0,i.jsx)(n.h4,{id:"touching-timestamps",children:"Touching timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["You can explicitly touch timestamps using the ",(0,i.jsx)(n.code,{children:"touch"})," method defined on the Model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::find(1);\n\nflight->touch();\nflight->touch("added_on"); // Custom column name\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You can also touch multiple rows at once using the ",(0,i.jsx)(n.code,{children:"touch"})," method defined on the TinyBuilder:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto [affected, query] = Flight::whereEq("status", "new")->touch();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"touch"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'flight->history()->touch();\nflight->history()->whereEq("status", "new").touch();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"database-connections",children:"Database Connections"}),"\n",(0,i.jsxs)(n.p,{children:["By default, all TinyORM models will use the default database connection that is configured for your application. If you would like to specify a different connection that should be used when interacting with a particular model, you should define a ",(0,i.jsx)(n.code,{children:"u_connection"})," private data member on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The database connection that should be used by the model. */\n QString u_connection {"sqlite"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In special cases, when you want to query the database through a different connection, you can use ",(0,i.jsx)(n.code,{children:"Model::on"})," method, which takes the connection name as the first argument:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto user = User::on("sqlite")->find(1);\n'})}),"\n",(0,i.jsx)(n.h2,{id:"default-attribute-values",children:"Default Attribute Values"}),"\n",(0,i.jsxs)(n.p,{children:["By default, a newly instantiated model instance will not contain any attribute values. If you would like to define the default values for some of your model's attributes, you may define an ",(0,i.jsx)(n.code,{children:"u_attributes"})," data member on your model, it has to be ",(0,i.jsx)(n.strong,{children:"static"})," and can be ",(0,i.jsx)(n.strong,{children:"const"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The model\'s default values for attributes. */\n inline static const QList u_attributes {\n {"delayed", false},\n {"progress", 0},\n {"added_on", QDateTime::currentDateTimeUtc()},\n };\n};\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["Use the ",(0,i.jsx)(n.code,{children:"Model::instance"})," or ",(0,i.jsx)(n.code,{children:"Model::instanceHeap"})," related methods to instantiate a model that contains a ",(0,i.jsx)(n.code,{children:"QDateTime"})," in Default Attribute Values, or if attributes you want to pass to the model's constructor contain a ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance ",(0,i.jsx)("small",{children:"(problem is described below)"}),"."]})}),"\n",(0,i.jsx)(n.h5,{id:"qdatetime-and-connection-name-problem",children:"QDateTime and connection name problem"}),"\n",(0,i.jsxs)(n.p,{children:["If your Default Attribute Values or attributes that you can pass to the ",(0,i.jsx)(n.code,{children:"Model"})," constructor contain the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance, then ",(0,i.jsx)(n.code,{children:"TinyORM"})," throws an exception. You have to use the ",(0,i.jsx)(n.code,{children:"Model::instance"})," related methods to create such a Model."]}),"\n",(0,i.jsxs)(n.p,{children:["Virtually everything important is covered in the thrown exception, but let me summarize it. The problem is that the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance is converted to a string based on the ",(0,i.jsx)(n.code,{children:"Model::u_dateFormat"}),", or if not defined, the date format from ",(0,i.jsx)(n.code,{children:"Orm::Query::Grammars::Grammar"})," will be used. This ",(0,i.jsx)(n.code,{children:"QueryGrammar"})," is obtained from ",(0,i.jsx)(n.code,{children:"Orm::DatabaseConnection"})," and because of that TinyORM needs to know the ",(0,i.jsx)(n.strong,{children:"connection name"})," and that's the crux of this problem. You can define your connection name using the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," in your derived model class, but this derived model ",(0,i.jsx)(n.strong,{children:"is not yet initialized"}),", so the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," is also not initialized."]}),"\n",(0,i.jsxs)(n.p,{children:["So if the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," is not yet initialized, ",(0,i.jsx)(n.code,{children:"TinyORM"})," can't obtain the ",(0,i.jsx)(n.code,{children:"Orm::DatabaseConnection"})," -> ",(0,i.jsx)(n.code,{children:"QueryGrammar"})," -> ",(0,i.jsx)(n.code,{children:"dateFormat"}),"."]}),"\n",(0,i.jsx)(n.h2,{id:"retrieving-models",children:"Retrieving Models"}),"\n",(0,i.jsxs)(n.p,{children:["Once you have created a model and its associated database table, you are ready to start retrieving data from your database. You can think of each TinyORM model as a powerful ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," allowing you to fluently query the database table associated with the model. The model's ",(0,i.jsx)(n.code,{children:"all"})," method will retrieve all of the records from the model's associated database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/flight.hpp"\n\nfor (const auto &flight : Flight::all())\n qDebug() << flight["name"].toString();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"building-queries",children:"Building Queries"}),"\n",(0,i.jsxs)(n.p,{children:["The TinyORM ",(0,i.jsx)(n.code,{children:"all"})," method will return all of the results in the model's table. However, since each TinyORM model serves as a ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),", you may add additional constraints to queries and then invoke the ",(0,i.jsx)(n.code,{children:"get"})," method to retrieve the results:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::whereEq("active", 1)\n ->orderBy("name")\n .take(10)\n .get();\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Since TinyORM models are query builders, you should review all of the methods provided by TinyORM's ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),". You may use any of these methods when writing your TinyORM queries."]})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["All the static methods defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class, which start building queries like ",(0,i.jsx)(n.code,{children:"where"}),", ",(0,i.jsx)(n.code,{children:"latest"}),", ",(0,i.jsx)(n.code,{children:"oldest"}),", ",(0,i.jsx)(n.code,{children:"with"}),", ... return ",(0,i.jsx)(n.code,{children:"std::unique_ptr>"}),", ",(0,i.jsx)(n.code,{children:"TinyBuilder = Orm::Tiny::Builder"})," and ",(0,i.jsx)(n.code,{children:"Model"})," template argument is queried model class."]})}),"\n",(0,i.jsx)(n.h4,{id:"refreshing-models",children:"Refreshing Models"}),"\n",(0,i.jsxs)(n.p,{children:['If you already have an instance of the TinyORM model that was retrieved from the database, you can "refresh" the model using the ',(0,i.jsx)(n.code,{children:"fresh"})," and ",(0,i.jsx)(n.code,{children:"refresh"})," methods. The ",(0,i.jsx)(n.code,{children:"fresh"})," method will re-retrieve the model from the database. The existing model instance will not be affected:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::whereEq("number", "FR 900")->first();\n\nauto freshFlight = flight->fresh();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"refresh"})," method will re-hydrate the existing model using fresh data from the database. In addition, all of its loaded relationships will be refreshed as well:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::whereEq("number", "FR 900")->first();\n\nflight->setAttribute("number", "FR 456");\n\nflight->refresh();\n\nflight->getAttribute("number"); // "FR 900"\n'})}),"\n",(0,i.jsx)(n.h3,{id:"containers",children:"Containers"}),"\n",(0,i.jsxs)(n.p,{children:["As we have seen, TinyORM methods like ",(0,i.jsx)(n.code,{children:"all"})," and ",(0,i.jsx)(n.code,{children:"get"})," retrieve multiple records from the database. Since these methods return a ",(0,i.jsx)(n.code,{children:"QList"}),", you can iterate it like any other container with the ",(0,i.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/language/range-for",children:"Range-based for loop"}),", ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/containers.html#stl-style-iterators",children:"STL-Style Iterators"}),", ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/containers.html#java-style-iterators",children:"Java-Style Iterators"})," or ",(0,i.jsx)(n.a,{href:"https://www.walletfox.com/course/quickref_range_v3.php",children:"Ranges"}),"."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/flight.hpp"\n\nfor (const auto &flight : Flight::all())\n qDebug() << flight["name"].toString();\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["An ",(0,i.jsx)(n.code,{children:"all"})," method is defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class and ",(0,i.jsx)(n.code,{children:"get"})," method is defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Builder"}),", may be also referred as ",(0,i.jsx)(n.code,{children:"TinyBuilder"}),", and on the ",(0,i.jsx)(n.code,{children:"Orm::Query::Builder"})," alias ",(0,i.jsx)(n.code,{children:"QueryBuilder"}),"."]})}),"\n",(0,i.jsx)(n.h3,{id:"chunking-results",children:"Chunking Results"}),"\n",(0,i.jsxs)(n.p,{children:["Your application may run out of memory if you attempt to load tens of thousands of TinyORM records via the ",(0,i.jsx)(n.code,{children:"all"})," or ",(0,i.jsx)(n.code,{children:"get"})," methods. Instead of using these methods, the ",(0,i.jsx)(n.code,{children:"chunk"})," method may be used to process large numbers of models more efficiently."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"chunk"})," method will retrieve a subset of TinyORM models, passing them to a lambda expression for processing. Since only the current chunk of TinyORM models is retrieved at a time, the ",(0,i.jsx)(n.code,{children:"chunk"})," method will provide significantly reduced memory usage when working with a large number of models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::chunk(200, [](QList &&flights, const int /*unused*/)\n{\n for (auto &&flight : flights) {\n //\n }\n\n return true;\n});\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The first argument passed to the ",(0,i.jsx)(n.code,{children:"chunk"}),' method is the number of records you wish to receive per "chunk". The lambda expression passed as the second argument will be invoked for each chunk that is retrieved from the database. A database query will be executed to retrieve each chunk of records passed to the lambda expression.']}),"\n",(0,i.jsxs)(n.p,{children:["If you are filtering the results of the ",(0,i.jsx)(n.code,{children:"chunk"})," method based on a column that you will also be updating while iterating over the results, you should use the ",(0,i.jsx)(n.code,{children:"chunkById"})," method. Using the ",(0,i.jsx)(n.code,{children:"chunk"})," method in these scenarios could lead to unexpected and inconsistent results. Internally, the ",(0,i.jsx)(n.code,{children:"chunkById"})," method will always retrieve models with an ",(0,i.jsx)(n.code,{children:"id"})," column greater than the last model in the previous chunk:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::whereEq("departed", true)\n ->chunkById(200, [](QList &&flights, const int /*unused*/)\n {\n for (auto &&flight : flights)\n flight.update({{"departed", false}});\n\n return true;\n });\n'})}),"\n",(0,i.jsx)(n.h3,{id:"advanced-subqueries",children:"Advanced Subqueries"}),"\n",(0,i.jsx)(n.h4,{id:"subquery-selects",children:"Subquery Selects"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM also offers advanced subquery support, which allows you to pull information from related tables in a single query. For example, let's imagine that we have a table of flight ",(0,i.jsx)(n.code,{children:"destinations"})," and a table of ",(0,i.jsx)(n.code,{children:"flights"})," to destinations. The ",(0,i.jsx)(n.code,{children:"flights"})," table contains an ",(0,i.jsx)(n.code,{children:"arrived_at"})," column which indicates when the flight arrived at the destination."]}),"\n",(0,i.jsxs)(n.p,{children:["Using the subquery functionality available to the query builder's ",(0,i.jsx)(n.code,{children:"select"})," and ",(0,i.jsx)(n.code,{children:"addSelect"})," methods, we can select all of the ",(0,i.jsx)(n.code,{children:"destinations"})," and the name of the flight that most recently arrived at that destination using a single query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/destination.hpp"\n#include "models/flight.hpp"\n\nreturn Destination::addSelect(\n Flight::select("name")\n ->whereColumnEq("destination_id", "destinations.id")\n .orderByDesc("arrived_at")\n .limit(1)\n .toBase(),\n "last_flight")\n ->get();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"subquery-ordering",children:"Subquery Ordering"}),"\n",(0,i.jsxs)(n.p,{children:["In addition, the query builder's ",(0,i.jsx)(n.code,{children:"orderBy"})," function supports subqueries. Continuing to use our flight example, we may use this functionality to sort all destinations based on when the last flight arrived at that destination. Again, this may be done while executing a single database query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'return Destination::orderByDesc(\n Flight::select("arrived_at")\n ->whereColumnEq("destination_id", "destinations.id")\n .orderByDesc("arrived_at")\n .limit(1)\n .toBase())\n ->get();\n'})}),"\n",(0,i.jsx)(n.h2,{id:"retrieving-single-models-and-aggregates",children:"Retrieving Single Models / Aggregates"}),"\n",(0,i.jsxs)(n.p,{children:["In addition to retrieving all of the records matching a given query, you may also retrieve single records using the ",(0,i.jsx)(n.code,{children:"find"}),", ",(0,i.jsx)(n.code,{children:"first"}),", ",(0,i.jsx)(n.code,{children:"firstWhere"}),", or ",(0,i.jsx)(n.code,{children:"firstWhereEq"})," methods. Instead of returning a vector of models, these methods return a single model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Retrieve a model by its primary key...\nauto flight = Flight::find(1);\n\n// Retrieve the first model matching the query constraints...\nauto flight = Flight::whereEq("active", 1)->first();\n\n// Alternative to retrieving the first model matching the query constraints...\nauto flight = Flight::firstWhere("active", "=", 1);\n\n// Alternative firstWhere method syntax\nauto flight = Flight::firstWhereEq("active", 1);\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may wish to perform some other action if no results are found. The ",(0,i.jsx)(n.code,{children:"findOr"})," methods will return a single model instance or, if no results are found, execute the given lambda expression. The value returned by the lambda will be considered the result of the method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto flight = Flight::findOr(1, [] {\n // ...\n});\n\nauto flight = Flight::findOr(1, [] {\n // ...\n return 10;\n});\n\nauto flight = Flight::findOr>(1, [] {\n // ...\n return Flight::find(10);\n});\n"})}),"\n",(0,i.jsxs)(n.p,{children:["To obtain only a subset of the model's attributes you may use the ",(0,i.jsx)(n.code,{children:"Model::only"})," method, it returns the ",(0,i.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nusing Orm::Constants::ID;\nusing Orm::Constants::NAME;\n\nauto flight = Flight::find(1);\n\nauto attributes = flight->only({ID, NAME});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"not-found-exceptions",children:"Not Found Exceptions"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may wish to throw an exception if a model is not found. The ",(0,i.jsx)(n.code,{children:"findOrFail"})," and ",(0,i.jsx)(n.code,{children:"firstOrFail"})," methods will retrieve the first result of the query; however, if no result is found, an ",(0,i.jsx)(n.code,{children:"Orm::Tiny::ModelNotFoundError"})," will be thrown:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::findOrFail(1);\n\nauto flight = Flight::where("legs", ">", 3)->firstOrFail();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"retrieving-or-creating-models",children:"Retrieving Or Creating Models"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrCreate"})," method will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first ",(0,i.jsx)(n.code,{children:"QList"})," argument with the optional second ",(0,i.jsx)(n.code,{children:"QList"})," argument:"]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrNew"})," method, like ",(0,i.jsx)(n.code,{children:"firstOrCreate"}),", will attempt to locate a record in the database matching the given attributes. However, if a model is not found, a new model instance will be returned. Note that the model returned by ",(0,i.jsx)(n.code,{children:"firstOrNew"})," has not yet been persisted to the database. You will need to manually call the ",(0,i.jsx)(n.code,{children:"save"})," method to persist it:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Retrieve flight by name or create it if it doesn\'t exist...\nauto flight = Flight::firstOrCreate({\n {"name", "London to Paris"}\n});\n\n// Retrieve flight by name or create it with the name, delayed, and arrival_time attributes...\nauto flight = Flight::firstOrCreate(\n {{"name", "London to Paris"}},\n {{"delayed", 1}, {"arrival_time", "11:30"}}\n);\n\n// Retrieve flight by name or instantiate a new Flight instance...\nauto flight = Flight::firstOrNew({\n {"name", "London to Paris"}\n});\n\n// Retrieve flight by name or instantiate with the name, delayed, and arrival_time attributes...\nauto flight = Flight::firstOrNew(\n {{"name", "Tokyo to Sydney"}},\n {{"delayed", 1}, {"arrival_time", "11:30"}}\n);\n'})}),"\n",(0,i.jsx)(n.h3,{id:"retrieving-aggregates",children:"Retrieving Aggregates"}),"\n",(0,i.jsxs)(n.p,{children:["When interacting with TinyORM models, you may also use the ",(0,i.jsx)(n.code,{children:"count"}),", ",(0,i.jsx)(n.code,{children:"sum"}),", ",(0,i.jsx)(n.code,{children:"max"}),", and other ",(0,i.jsx)(n.a,{href:"/database/query-builder#aggregates",children:"aggregate methods"})," provided by the ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),". As you might expect, these methods return a scalar value instead of a TinyORM model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto count = Flight::whereEq("active", 1)->count();\n\nauto max = Flight::whereEq("active", 1)->max("price");\n'})}),"\n",(0,i.jsx)(n.h2,{id:"inserting-and-updating-models",children:"Inserting & Updating Models"}),"\n",(0,i.jsx)(n.h3,{id:"inserts",children:"Inserts"}),"\n",(0,i.jsxs)(n.p,{children:["Of course, when using TinyORM, we don't only need to retrieve models from the database. We also need to insert new records. Thankfully, TinyORM makes it simple. To insert a new record into the database, you should instantiate a new model instance and set attributes on the model. Then, call the ",(0,i.jsx)(n.code,{children:"save"})," method on the model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Store a new flight in the database\nFlight flight;\nflight.setAttribute("name", "Slovakia to Czech");\nflight.save();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In this example, we assign the ",(0,i.jsx)(n.code,{children:"name"})," attribute of the ",(0,i.jsx)(n.code,{children:"Flight"})," model instance. When we call the ",(0,i.jsx)(n.code,{children:"save"})," method, a record will be inserted into the database. The model's ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamps will automatically be set when the ",(0,i.jsx)(n.code,{children:"save"})," method is called, so there is no need to set them manually."]}),"\n",(0,i.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,i.jsx)(n.code,{children:"create"}),' method to "save" a new model using a single C++ statement. The inserted model instance will be returned to you by the ',(0,i.jsx)(n.code,{children:"create"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::create({\n {"name", "London to Paris"},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["However, before using the ",(0,i.jsx)(n.code,{children:"create"})," method, you will need to specify either a ",(0,i.jsx)(n.code,{children:"u_fillable"})," or ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member on your model class. These static data members are required because all TinyORM models are protected against mass assignment vulnerabilities by default. To learn more about mass assignment, please consult the ",(0,i.jsx)(n.a,{href:"#mass-assignment",children:"mass assignment documentation"}),"."]}),"\n",(0,i.jsx)(n.h3,{id:"updates",children:"Updates"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"save"})," method may also be used to update models that already exist in the database. To update a model, you should retrieve it and set any attributes you wish to update. Then, you should call the model's ",(0,i.jsx)(n.code,{children:"save"})," method. Again, the ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamp will automatically be updated, so there is no need to manually set its value:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::find(1);\n\nflight->setAttribute("name", "Paris to London");\n\nflight->save();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"mass-updates",children:"Mass Updates"}),"\n",(0,i.jsxs)(n.p,{children:["Updates can also be performed against models that match a given query. In this example, all flights that are ",(0,i.jsx)(n.code,{children:"active"})," and have a ",(0,i.jsx)(n.code,{children:"destination"})," of ",(0,i.jsx)(n.code,{children:"San Diego"})," will be marked as delayed:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::whereEq("active", 1)\n ->whereEq("destination", "San Diego")\n .update({{"delayed", 1}});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"update"})," method expects the ",(0,i.jsx)(n.code,{children:"QList"})," of column and value pairs representing the columns that should be updated."]}),"\n",(0,i.jsx)(n.h4,{id:"examining-attribute-changes",children:"Examining Attribute Changes"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM provides the ",(0,i.jsx)(n.code,{children:"isDirty"}),", ",(0,i.jsx)(n.code,{children:"isClean"}),", and ",(0,i.jsx)(n.code,{children:"wasChanged"})," methods to examine the internal state of your model and determine how its attributes have changed from when the model was originally retrieved."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"isDirty"})," method determines if any of the model's attributes have been changed since the model was retrieved. You may pass a specific attribute name to the ",(0,i.jsx)(n.code,{children:"isDirty"})," method to determine if a particular attribute is dirty. The ",(0,i.jsx)(n.code,{children:"isClean"})," will determine if an attribute has remained unchanged since the model was retrieved. This method also accepts an optional attribute argument:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::create({\n {"first_name", "Silver"},\n {"last_name", "Zachara"},\n {"title", "Developer"},\n});\n\nuser.setAttribute("title", "Painter");\n\nuser.isDirty(); // true\nuser.isDirty("title"); // true\nuser.isDirty("first_name"); // false\n\nuser.isClean(); // false\nuser.isClean("title"); // false\nuser.isClean("first_name"); // true\n\nuser.save();\n\nuser.isDirty(); // false\nuser.isClean(); // true\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"wasChanged"})," method determines if any attributes were changed after the model was last saved into the database. If needed, you may pass an attribute name to see if a particular attribute was changed:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto user = User::create({\n {"first_name", "Silver"},\n {"last_name", "Zachara"},\n {"title", "Developer"},\n});\n\nuser.setAttribute("title", "Painter");\n\nuser.wasChanged(); // false\n\nuser.save();\n\nuser.wasChanged(); // true\nuser.wasChanged("title"); // true\nuser.wasChanged("first_name"); // false\n'})}),"\n",(0,i.jsx)(n.h3,{id:"mass-assignment",children:"Mass Assignment"}),"\n",(0,i.jsxs)(n.p,{children:["You may use the ",(0,i.jsx)(n.code,{children:"create"}),' method to "save" a new model using a single C++ statement. The inserted model instance will be returned to you by the method:']}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::create({\n {"name", "London to Paris"},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["However, before using the ",(0,i.jsx)(n.code,{children:"create"})," method, you will need to specify either a ",(0,i.jsx)(n.code,{children:"u_fillable"})," or ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member on your model class. These data members are required because all TinyORM models are protected against mass assignment vulnerabilities by default."]}),"\n",(0,i.jsxs)(n.p,{children:["A mass assignment vulnerability occurs when a user passes an unexpected HTTP request field and that field changes a column in your database that you did not expect. For example, a malicious user might send an ",(0,i.jsx)(n.code,{children:"is_admin"})," parameter through an HTTP request, which is then passed to your model's ",(0,i.jsx)(n.code,{children:"create"})," method, allowing the user to escalate themselves to an administrator."]}),"\n",(0,i.jsxs)(n.p,{children:["So, to get started, you should define which model attributes you want to make mass assignable. You may do this using the ",(0,i.jsx)(n.code,{children:"u_fillable"})," static data member on the model. For example, let's make the ",(0,i.jsx)(n.code,{children:"name"})," attribute of our ",(0,i.jsx)(n.code,{children:"Flight"})," model mass assignable:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n\n /*! The attributes that are mass assignable. */\n inline static QStringList u_fillable {\n "name",\n };\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Once you have specified which attributes are mass assignable, you may use the ",(0,i.jsx)(n.code,{children:"create"})," method to insert a new record in the database. The ",(0,i.jsx)(n.code,{children:"create"})," method returns the newly created model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::create({{"name", "London to Paris"}});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you already have a model instance, you may use the ",(0,i.jsx)(n.code,{children:"fill"})," method to populate it with the vector of attributes:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'flight.fill({{"name", "Amsterdam to Frankfurt"}});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"allowing-mass-assignment",children:"Allowing Mass Assignment"}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to make all of your attributes mass assignable, you may define your model's ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member as an empty vector. If you choose to unguard your model, you should take special care to always hand-craft the vectors passed to TinyORM's ",(0,i.jsx)(n.code,{children:"fill"}),", ",(0,i.jsx)(n.code,{children:"create"}),", and ",(0,i.jsx)(n.code,{children:"update"})," methods:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n\n /*! The attributes that aren't mass assignable. */\n inline static QStringList u_guarded {};\n};\n"})}),"\n",(0,i.jsx)(n.h3,{id:"upserts",children:"Upserts"}),"\n",(0,i.jsx)(n.p,{children:"Occasionally, you may need to update an existing model or create a new model if no matching model exists."}),"\n",(0,i.jsxs)(n.p,{children:["In the example below, if a flight exists with a ",(0,i.jsx)(n.code,{children:"departure"})," location of ",(0,i.jsx)(n.code,{children:"Oakland"})," and a ",(0,i.jsx)(n.code,{children:"destination"})," location of ",(0,i.jsx)(n.code,{children:"San Diego"}),", its ",(0,i.jsx)(n.code,{children:"price"})," and ",(0,i.jsx)(n.code,{children:"discounted"})," columns will be updated. If no such flight exists, a new flight will be created which has the attributes resulting from merging the first argument vector with the second argument vector:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::updateOrCreate(\n {{"departure", "Oakland"}, {"destination", "San Diego"}},\n {{"price", 99}, {"discounted", 1}}\n);\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrCreate"})," and ",(0,i.jsx)(n.code,{children:"updateOrCreate"})," methods persist the model, so there's no need to manually call the ",(0,i.jsx)(n.code,{children:"save"})," method."]})}),"\n",(0,i.jsxs)(n.p,{children:['If you would like to perform multiple "upserts" in a single query, then you should use the ',(0,i.jsx)(n.code,{children:"upsert"})," method instead. The method's first argument consists of the values to insert or update, while the second argument lists the column(s) that uniquely identify records within the associated table. The method's third and final argument is the vector of the columns that should be updated if a matching record already exists in the database. The ",(0,i.jsx)(n.code,{children:"upsert"})," method will automatically set the ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamps if timestamps are enabled on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::upsert(\n {{{"departure", "Oakland"}, {"destination", "San Diego"}, {"price", 99}},\n {{"departure", "Chicago"}, {"destination", "New York"}, {"price", 150}}},\n {"departure", "destination"},\n {"price"}\n);\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["All databases except SQL Server require the columns in the second argument of the ",(0,i.jsx)(n.code,{children:"upsert"}),' method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the ',(0,i.jsx)(n.code,{children:"upsert"}),' method and always uses the "primary" and "unique" indexes of the table to detect existing records.']})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html",children:"documentation"}),". The MySQL server version is auto-detected and can be overridden in the ",(0,i.jsx)(n.a,{href:"/database/getting-started#configuration",children:"configuration"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"deleting-models",children:"Deleting Models"}),"\n",(0,i.jsxs)(n.p,{children:["To delete a model, you may call the ",(0,i.jsx)(n.code,{children:"remove"}),", or an alias ",(0,i.jsx)(n.code,{children:"deleteRow"})," method on the model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::find(1);\n\nflight->remove();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"deleting-an-existing-model-by-its-primary-key",children:"Deleting An Existing Model By Its Primary Key"}),"\n",(0,i.jsxs)(n.p,{children:["In the example above, we are retrieving the model from the database before calling the ",(0,i.jsx)(n.code,{children:"remove"})," method. However, if you know the primary key of the model, you may delete the model without explicitly retrieving it by calling the ",(0,i.jsx)(n.code,{children:"destroy"})," method. In addition to accepting the single primary key, the ",(0,i.jsx)(n.code,{children:"destroy"})," method can accept multiple primary keys:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::destroy(1);\n\nFlight::destroy({1, 2, 3});\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"destroy"})," method loads models from the database and calls the ",(0,i.jsx)(n.code,{children:"remove"})," method on each model individually, the reason for this is future compatibility with events."]})}),"\n",(0,i.jsx)(n.h4,{id:"deleting-models-using-queries",children:"Deleting Models Using Queries"}),"\n",(0,i.jsx)(n.p,{children:"Of course, you may build the query to delete all models matching your query's criteria. In this example, we will delete all flights that are marked as inactive:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto deletedRows = Flight::whereEq("active", 0)->remove();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"soft-deleting",children:"Soft Deleting"}),"\n",(0,i.jsxs)(n.p,{children:['In addition to actually removing records from your database, TinyORM can also "soft delete" models. When models are soft deleted, they are not actually removed from your database. Instead, a ',(0,i.jsx)(n.code,{children:"deleted_at"}),' attribute is set on the model indicating the date and time at which the model was "deleted". To enable soft deletes for a model, add the ',(0,i.jsx)(n.code,{children:"Orm::Tiny::SoftDeletes"})," base class to the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::SoftDeletes;\n\nclass Flight final : public Model,\n public SoftDeletes\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The table associated with the model. */\n QString u_table {"flights"};\n};\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"SoftDeletes"})," base class will automatically cast the ",(0,i.jsx)(n.code,{children:"deleted_at"})," attribute to the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance for you (it adds the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to the model's ",(0,i.jsx)(n.a,{href:"#timestamps-u_dates",children:(0,i.jsx)(n.code,{children:"u_dates"})})," list)."]})}),"\n",(0,i.jsxs)(n.p,{children:["You should also add the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to your database table. The TinyORM ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"schema builder"})," contains a helper method to create this column:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Schema::table("flights", [](Blueprint &table)\n{\n table.softDeletes();\n});\n\nSchema::table("flights", [](Blueprint &table)\n{\n table.dropSoftDeletes();\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Now, when you call the ",(0,i.jsx)(n.code,{children:"remove"})," or ",(0,i.jsx)(n.code,{children:"deleteModel"})," method on the model, the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column will be set to the current date and time. However, the model's database record will be left in the table. When querying a model that uses soft deletes, the soft deleted models will automatically be excluded from all query results."]}),"\n",(0,i.jsxs)(n.p,{children:["To determine if a given model instance has been soft deleted, you may use the ",(0,i.jsx)(n.code,{children:"trashed"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (flight->trashed()) {\n //\n}\n"})}),"\n",(0,i.jsx)(n.h4,{id:"restoring-soft-deleted-models",children:"Restoring Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:['Sometimes you may wish to "un-delete" a soft deleted model. To restore a soft deleted model, you may call the ',(0,i.jsx)(n.code,{children:"restore"})," method on a model instance. The ",(0,i.jsx)(n.code,{children:"restore"})," method will set the model's ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to ",(0,i.jsx)(n.code,{children:"null"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->restore();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"restore"})," method in a query to restore multiple models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::withTrashed()\n ->whereEq("airline_id", 1)\n .restore();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"restore"})," method may also be used when building ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," queries:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->restore();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"permanently-deleting-models",children:"Permanently Deleting Models"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may need to truly remove a model from your database. You may use the ",(0,i.jsx)(n.code,{children:"forceDelete"})," method (or it's alias ",(0,i.jsx)(n.code,{children:"forceRemove"}),") to permanently remove a soft deleted model from the database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->forceDelete();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"forceDelete"})," method when building TinyORM relationship queries:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->forceDelete();\n"})}),"\n",(0,i.jsx)(n.h3,{id:"querying-soft-deleted-models",children:"Querying Soft Deleted Models"}),"\n",(0,i.jsx)(n.h4,{id:"including-soft-deleted-models",children:"Including Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["As noted above, soft deleted models will automatically be excluded from query results. However, you may force soft deleted models to be included in a query's results by calling the ",(0,i.jsx)(n.code,{children:"withTrashed"})," method on the query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::withTrashed()\n ->whereEq("account_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"withTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->withTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"retrieving-only-soft-deleted-models",children:"Retrieving Only Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"onlyTrashed"})," method will retrieve ",(0,i.jsx)(n.strong,{children:"only"})," soft deleted models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::onlyTrashed()\n ->whereEq("airline_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"onlyTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->onlyTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"excluding-soft-deleted-models",children:"Excluding Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["As noted above, soft deleted models will automatically be excluded from query results. However, you may force soft deleted models to be ",(0,i.jsx)(n.strong,{children:"excluded"})," in a query's results by calling the ",(0,i.jsx)(n.code,{children:"withoutTrashed"})," method on the query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::withoutTrashed()\n ->whereEq("account_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"withoutTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->withoutTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h3,{id:"truncate-table",children:"Truncate Table"}),"\n",(0,i.jsxs)(n.p,{children:["You may call the ",(0,i.jsx)(n.code,{children:"truncate"})," method to delete all of the model's associated database records. The ",(0,i.jsx)(n.code,{children:"truncate"})," operation will also reset any auto-incrementing IDs on the model's associated table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::truncate();\n"})}),"\n",(0,i.jsx)(n.h2,{id:"replicating-models",children:"Replicating Models"}),"\n",(0,i.jsxs)(n.p,{children:["You may create an unsaved copy of an existing model instance using the ",(0,i.jsx)(n.code,{children:"replicate"})," method. This method is particularly useful when you have model instances that share many of the same attributes:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto shipping = Address::create({\n {"type", "shipping"},\n {"line_1", "123 Example Street"},\n {"city", "Victorville"},\n {"state", "CA"},\n {"postcode", "90001"},\n});\n\nauto billing = shipping.replicate();\n\nbilling.fill({\n {"type", "billing"},\n});\n\nbilling.save();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["To exclude one or more attributes from being replicated to the new model, you may pass an unordered_set to the ",(0,i.jsx)(n.code,{children:"replicate"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::create({\n {"destination", "LAX"},\n {"origin", "LHR"},\n {"last_flown", "2020-03-04 11:00:00"},\n {"last_pilot_id", 747},\n});\n\nflight = flight.replicate({\n "last_flown",\n "last_pilot_id",\n});\n'})}),"\n",(0,i.jsx)(n.h2,{id:"comparing-models",children:"Comparing Models"}),"\n",(0,i.jsxs)(n.p,{children:['Sometimes you may need to determine if two models are the "same" or not. The ',(0,i.jsx)(n.code,{children:"is"})," and ",(0,i.jsx)(n.code,{children:"isNot"})," methods may be used to quickly verify two models have the same primary key, table, and database connection or not:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (post->is(anotherPost)) {\n //\n}\n\nif (post->isNot(anotherPost)) {\n //\n}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"is"})," and ",(0,i.jsx)(n.code,{children:"isNot"})," methods are also available when using the ",(0,i.jsx)(n.code,{children:"belongsTo"})," and ",(0,i.jsx)(n.code,{children:"hasOne"})," ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationships"}),". This method is particularly helpful when you would like to compare a related model without issuing a query to retrieve that model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (post->author()->is(user)) {\n //\n}\n"})}),"\n",(0,i.jsx)(n.h5,{id:"equality-comparison",children:"Equality comparison"}),"\n",(0,i.jsxs)(n.p,{children:["The base ",(0,i.jsx)(n.code,{children:"Model"})," class also defines the ",(0,i.jsx)(n.code,{children:"operator=="})," that allows precisely comparing two models. It compares the content of all the model's data members, from all base classes to the most derived model class. The ",(0,i.jsx)(n.code,{children:"model1 == model2"})," expression guarantees that these two models are exactly the same."]}),"\n",(0,i.jsxs)(n.p,{children:["It would be appropriate to mention that this comparison also includes relations, which means it will also compare ",(0,i.jsx)(n.strong,{children:"all"})," models (including their data members) these relations contain."]})]})}function m(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var i=t(6540);const s={},a=i.createContext(s);function l(e){const n=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),i.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/5b254f70.e884e04f.js b/assets/js/5b254f70.e884e04f.js new file mode 100644 index 000000000..5afb3903f --- /dev/null +++ b/assets/js/5b254f70.e884e04f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[82],{560:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>c});var i=t(4848),s=t(8453),a=t(8774);const l={sidebar_position:0,sidebar_label:"Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',keywords:["c++ orm","orm","getting started","tinyorm"]},d="TinyORM: Getting Started",r={id:"tinyorm/getting-started",title:"TinyORM: Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',source:"@site/docs/tinyorm/getting-started.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/getting-started",permalink:"/tinyorm/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.',keywords:["c++ orm","orm","getting started","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Seeding",permalink:"/database/seeding"},next:{title:"Relationships",permalink:"/tinyorm/relationships"}},o={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Generating Model Classes",id:"generating-model-classes",level:2},{value:"TinyORM Model Conventions",id:"tinyorm-model-conventions",level:2},{value:"Table Names",id:"table-names",level:3},{value:"Primary Keys",id:"primary-keys",level:3},{value:""Composite" Primary Keys",id:"composite-primary-keys",level:4},{value:"Timestamps",id:"timestamps",level:3},{value:"Unix timestamps",id:"unix-timestamps",level:5},{value:"Custom timestamp column names",id:"custom-timestamp-column-names",level:5},{value:"Touching timestamps",id:"touching-timestamps",level:4},{value:"Database Connections",id:"database-connections",level:3},{value:"Default Attribute Values",id:"default-attribute-values",level:2},{value:"QDateTime and connection name problem",id:"qdatetime-and-connection-name-problem",level:5},{value:"Retrieving Models",id:"retrieving-models",level:2},{value:"Building Queries",id:"building-queries",level:4},{value:"Refreshing Models",id:"refreshing-models",level:4},{value:"Containers",id:"containers",level:3},{value:"Chunking Results",id:"chunking-results",level:3},{value:"Advanced Subqueries",id:"advanced-subqueries",level:3},{value:"Subquery Selects",id:"subquery-selects",level:4},{value:"Subquery Ordering",id:"subquery-ordering",level:4},{value:"Retrieving Single Models / Aggregates",id:"retrieving-single-models-and-aggregates",level:2},{value:"Not Found Exceptions",id:"not-found-exceptions",level:4},{value:"Retrieving Or Creating Models",id:"retrieving-or-creating-models",level:3},{value:"Retrieving Aggregates",id:"retrieving-aggregates",level:3},{value:"Inserting & Updating Models",id:"inserting-and-updating-models",level:2},{value:"Inserts",id:"inserts",level:3},{value:"Updates",id:"updates",level:3},{value:"Mass Updates",id:"mass-updates",level:4},{value:"Examining Attribute Changes",id:"examining-attribute-changes",level:4},{value:"Mass Assignment",id:"mass-assignment",level:3},{value:"Allowing Mass Assignment",id:"allowing-mass-assignment",level:4},{value:"Upserts",id:"upserts",level:3},{value:"Deleting Models",id:"deleting-models",level:2},{value:"Deleting An Existing Model By Its Primary Key",id:"deleting-an-existing-model-by-its-primary-key",level:4},{value:"Deleting Models Using Queries",id:"deleting-models-using-queries",level:4},{value:"Soft Deleting",id:"soft-deleting",level:3},{value:"Restoring Soft Deleted Models",id:"restoring-soft-deleted-models",level:4},{value:"Permanently Deleting Models",id:"permanently-deleting-models",level:4},{value:"Querying Soft Deleted Models",id:"querying-soft-deleted-models",level:3},{value:"Including Soft Deleted Models",id:"including-soft-deleted-models",level:4},{value:"Retrieving Only Soft Deleted Models",id:"retrieving-only-soft-deleted-models",level:4},{value:"Excluding Soft Deleted Models",id:"excluding-soft-deleted-models",level:4},{value:"Truncate Table",id:"truncate-table",level:3},{value:"Replicating Models",id:"replicating-models",level:2},{value:"Comparing Models",id:"comparing-models",level:2},{value:"Equality comparison",id:"equality-comparison",level:5}];function h(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"tinyorm-getting-started",children:"TinyORM: Getting Started"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#generating-model-classes",children:"Generating Model Classes"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#tinyorm-model-conventions",children:"TinyORM Model Conventions"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#table-names",children:"Table Names"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#primary-keys",children:"Primary Keys"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#timestamps",children:"Timestamps"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#database-connections",children:"Database Connections"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#default-attribute-values",children:"Default Attribute Values"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#retrieving-models",children:"Retrieving Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#containers",children:"Containers"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#chunking-results",children:"Chunking Results"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#advanced-subqueries",children:"Advanced Subqueries"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#retrieving-single-models-and-aggregates",children:"Retrieving Single Models / Aggregates"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#retrieving-or-creating-models",children:"Retrieving Or Creating Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#retrieving-aggregates",children:"Retrieving Aggregates"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#inserting-and-updating-models",children:"Inserting & Updating Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#inserts",children:"Inserts"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#updates",children:"Updates"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#mass-assignment",children:"Mass Assignment"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#upserts",children:"Upserts"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#deleting-models",children:"Deleting Models"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#soft-deleting",children:"Soft Deleting"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#querying-soft-deleted-models",children:"Querying Soft Deleted Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#truncate-table",children:"Truncate Table"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#replicating-models",children:"Replicating Models"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#comparing-models",children:"Comparing Models"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{className:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsx)(n.p,{children:'TinyORM is an object-relational mapper (ORM) that makes it enjoyable to interact with your database. When using TinyORM, each database table has a corresponding "Model" that is used to interact with that table. In addition to retrieving records from the database table, TinyORM models allow you to insert, update, and delete records from the table as well.'}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["Before getting started, be sure to configure a database connection in your application. For more information on configuring your database, check out the ",(0,i.jsx)(n.a,{href:"/database/getting-started#configuration",children:"database configuration documentation"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["If you want to see a model in which are used all possible TinyORM features you can look at the ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/models/models/torrent.hpp",children:(0,i.jsx)(n.code,{children:"torrent.hpp"})})," in the TinyORM's tests, this ",(0,i.jsx)(n.code,{children:"Models::Torrent"})," class serves also as a showcase, so all possible features are defined in it."]})}),"\n",(0,i.jsx)(n.h2,{id:"generating-model-classes",children:"Generating Model Classes"}),"\n",(0,i.jsxs)(n.p,{children:["To get started, let's create the simplest TinyORM model. Models typically live in the ",(0,i.jsx)(n.code,{children:"database\\models"})," directory and extend the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class. You may use the ",(0,i.jsx)(n.code,{children:"make:model"})," command to generate a new model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User\n"})}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to generate a database ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"migration"})," or ",(0,i.jsx)(n.a,{href:"/database/seeding",children:"seeder"})," when you generate the model, you may use the ",(0,i.jsx)(n.code,{children:"--migration"}),"/",(0,i.jsx)(n.code,{children:"-m"})," or ",(0,i.jsx)(n.code,{children:"--seeder"}),"/",(0,i.jsx)(n.code,{children:"-s"})," options:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User --migration --seeder\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"--force"})," option forces overwriting of existing files:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model User --migration --seeder --force\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"make:model"})," is king \ud83d\udc51 among scaffolding commands that you can use to generate complete TinyORM model classes, it supports all features that TinyORM models offer. All advanced features are described in the ",(0,i.jsx)(n.code,{children:"make:model"})," help command:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"tom make:model --help\n"})}),"\n",(0,i.jsx)(n.p,{children:"Few examples:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-powershell",children:"# Setting some model attributes\ntom make:model User --table=users --fillable=name,email,banned_at `\n --guarded=password --dates=banned_at\n\n# Generate relationship methods\ntom make:model User --one-to-one=Passport `\n --one-to-many=Post --foreign-key=post_id `\n --one-to-many=Car\n\n# Generate a basic many-to-many relationship\ntom make:model User --belongs-to-many=Tag --with-timestamps\n\n# Generate a many-to-many relationship\ntom make:model User --belongs-to-many=Tag --foreign-key=tag_id `\n --pivot-table=user_tag --as=tagged `\n --with-pivot=active,soft --with-timestamps `\n --pivot=Tagged\n\n# Generate a pivot model\ntom make:model Tagged --pivot-model\ntom make:model Tagged --pivot-model --incrementing\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Writing a ",(0,i.jsx)(n.code,{children:"make:model"})," commands is superb with the ",(0,i.jsx)(n.a,{href:"/database/migrations#tab-completion",children:"tab completion"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"--path"})," and ",(0,i.jsx)(n.code,{children:"--realpath"})," options work the same as for the ",(0,i.jsx)(n.a,{href:"/database/migrations#generating-migrations",children:(0,i.jsx)(n.code,{children:"make:migration"})})," command."]})}),"\n",(0,i.jsx)(n.h2,{id:"tinyorm-model-conventions",children:"TinyORM Model Conventions"}),"\n",(0,i.jsx)(n.p,{children:"Let's examine a basic model class and discuss some of TinyORM's key conventions:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#pragma once\n#ifndef FLIGHT_HPP\n#define FLIGHT_HPP\n\n#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n};\n\n#endif // FLIGHT_HPP\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/models/models/torrent.hpp#L45",children:(0,i.jsx)(n.code,{children:"Torrent"})})," example model that also acts as the full-fledged example model. It has defined and also nicely commented all possible features that model classes can use or define."]})}),"\n",(0,i.jsx)(n.h3,{id:"table-names",children:"Table Names"}),"\n",(0,i.jsxs)(n.p,{children:["After glancing at the example above, you may have noticed that we did not tell TinyORM which database table corresponds to our ",(0,i.jsx)(n.code,{children:"Flight"}),' model. By convention, the "snake_case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, TinyORM will assume the ',(0,i.jsx)(n.code,{children:"Flight"})," model stores records in the ",(0,i.jsx)(n.code,{children:"flights"})," table, while an ",(0,i.jsx)(n.code,{children:"AirTrafficController"})," model would store records in an ",(0,i.jsx)(n.code,{children:"air_traffic_controllers"})," table."]}),"\n",(0,i.jsxs)(n.p,{children:["If your model's corresponding database table does not fit this convention, you may manually specify the model's table name by defining the private ",(0,i.jsx)(n.code,{children:"u_table"})," data member on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The table associated with the model. */\n QString u_table {"flights"};\n};\n'})}),"\n",(0,i.jsx)(n.h3,{id:"primary-keys",children:"Primary Keys"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM will also assume that each model's corresponding database table has a primary key column named ",(0,i.jsx)(n.code,{children:"id"}),". If necessary, you may define a private ",(0,i.jsx)(n.code,{children:"u_primaryKey"})," data member on your model to specify a different column that serves as your model's primary key:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The primary key associated with the table. */\n QString u_primaryKey {"id"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In addition, TinyORM assumes that the primary key is an incrementing integer value. If you wish to use a non-incrementing or a non-numeric primary key you must define a private ",(0,i.jsx)(n.code,{children:"u_incrementing"})," data member on your model that is set to ",(0,i.jsx)(n.code,{children:"false"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! Indicates if the model's ID is auto-incrementing. */\n bool u_incrementing = false;\n};\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["Non-numeric primary keys are not currently implemented, ",(0,i.jsx)(n.code,{children:"u_incrementing"})," code logic is fully implemented, but it is only one part to make it fully work."]})}),"\n",(0,i.jsx)(n.h4,{id:"composite-primary-keys",children:'"Composite" Primary Keys'}),"\n",(0,i.jsx)(n.p,{children:'TinyORM requires each model to have at least one uniquely identifying "ID" that can serve as its primary key. "Composite" primary keys are not supported by TinyORM models. However, you are free to add additional multi-column unique indexes to your database tables, in addition to the table\'s uniquely identifying primary key.'}),"\n",(0,i.jsx)(n.h3,{id:"timestamps",children:"Timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["By default, TinyORM expects ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," columns to exist on your model's corresponding database table. TinyORM will automatically set these column's values when models are created or updated. If you do not want these columns to be automatically managed by TinyORM, you should define a private ",(0,i.jsx)(n.code,{children:"u_timestamps"})," data member on your model with a value of ",(0,i.jsx)(n.code,{children:"false"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! Indicates if the model should be timestamped. */\n bool u_timestamps = false;\n};\n"})}),"\n",(0,i.jsx)(a.A,{id:"timestamps-u_dates"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"u_dates"})," static data member controls the casting of timestamp attributes. The ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," columns are automatically added to the ",(0,i.jsx)(n.code,{children:"u_dates"})," string list when the ",(0,i.jsx)(n.code,{children:"u_timestamps"})," is ",(0,i.jsx)(n.code,{children:"true"}),". Also, the ",(0,i.jsx)(n.a,{href:"#soft-deleting",children:(0,i.jsx)(n.code,{children:"Soft Deleting"})})," feature adds the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to the ",(0,i.jsx)(n.code,{children:"u_dates"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You may add additional columns to the ",(0,i.jsx)(n.code,{children:"u_dates"})," list. After that, these columns will be automatically formatted using the format in the ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," data member during the ",(0,i.jsx)(n.code,{children:"setAttribute"})," method call:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'class Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The attributes that should be mutated to dates. */\n inline static const QStringList u_dates {"departure_at"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the format of your model's timestamps, set the private ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," data member on your model. This data member determines how date attributes are stored in the database, supported formats are described in the ",(0,i.jsx)(n.code,{children:"QDateTime"})," documentation:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The storage format of the model\'s date columns. */\n QString u_dateFormat {"yyyy-MM-dd HH:mm:ss"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the format of your model's time columns, set the private ",(0,i.jsx)(n.code,{children:"u_timeFormat"})," data member on your model. This data member determines how time attributes are stored in the database, supported formats are described in the ",(0,i.jsx)(n.code,{children:"QTime"})," documentation. The default value for ",(0,i.jsx)(n.code,{children:"u_timeFormat"})," is ",(0,i.jsx)(n.code,{children:"HH:mm:ss"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'/*! The storage format of the model\'s time columns. */\nQString u_timeFormat {"HH:mm:ss.zzz"};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The default value for datetime or timestamp columns is ",(0,i.jsx)(n.code,{children:"yyyy-MM-dd HH:mm:ss"})," and for time columns is ",(0,i.jsx)(n.code,{children:"HH:mm:ss"}),"."]}),"\n",(0,i.jsx)(n.h5,{id:"unix-timestamps",children:"Unix timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["You can set the ",(0,i.jsx)(n.code,{children:"u_dateFormat"})," to ",(0,i.jsx)(n.code,{children:"U"})," if you want to store dates in the database as Unix timestamps:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"QString u_dateFormat {QLatin1Char('U')};\n"})}),"\n",(0,i.jsxs)(n.p,{children:["In this case ",(0,i.jsx)(n.strong,{children:"all"})," date attributes set in the ",(0,i.jsx)(n.code,{children:"u_dates"})," will be handled as Unix timestamps, so also the ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamp attributes."]}),"\n",(0,i.jsxs)(n.p,{children:["To create Unix timestamp columns using the ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"tom migrations"})," you should use ",(0,i.jsx)(n.code,{children:"integer"})," types:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Schema::table("flights", [](Blueprint &table)\n{\n table.bigInteger("created_at").nullable();\n table.bigInteger("updated_at").nullable();\n});\n'})}),"\n",(0,i.jsx)(n.h5,{id:"custom-timestamp-column-names",children:"Custom timestamp column names"}),"\n",(0,i.jsxs)(n.p,{children:["If you need to customize the names of the columns used to store the timestamps, you may define ",(0,i.jsx)(n.code,{children:"CREATED_AT"})," and ",(0,i.jsx)(n.code,{children:"UPDATED_AT"})," private static getter methods on your model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The name of the "created at" column. */\n static QString CREATED_AT() { return QStringLiteral("creation_date"); }\n /*! The name of the "updated at" column. */\n static QString UPDATED_AT() { return QStringLiteral("updated_date"); }\n};\n'})}),"\n",(0,i.jsx)(n.h4,{id:"touching-timestamps",children:"Touching timestamps"}),"\n",(0,i.jsxs)(n.p,{children:["You can explicitly touch timestamps using the ",(0,i.jsx)(n.code,{children:"touch"})," method defined on the Model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::find(1);\n\nflight->touch();\nflight->touch("added_on"); // Custom column name\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You can also touch multiple rows at once using the ",(0,i.jsx)(n.code,{children:"touch"})," method defined on the TinyBuilder:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto [affected, query] = Flight::whereEq("status", "new")->touch();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"touch"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'flight->history()->touch();\nflight->history()->whereEq("status", "new").touch();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"database-connections",children:"Database Connections"}),"\n",(0,i.jsxs)(n.p,{children:["By default, all TinyORM models will use the default database connection that is configured for your application. If you would like to specify a different connection that should be used when interacting with a particular model, you should define a ",(0,i.jsx)(n.code,{children:"u_connection"})," private data member on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The database connection that should be used by the model. */\n QString u_connection {"sqlite"};\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In special cases, when you want to query the database through a different connection, you can use ",(0,i.jsx)(n.code,{children:"Model::on"})," method, which takes the connection name as the first argument:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto user = User::on("sqlite")->find(1);\n'})}),"\n",(0,i.jsx)(n.h2,{id:"default-attribute-values",children:"Default Attribute Values"}),"\n",(0,i.jsxs)(n.p,{children:["By default, a newly instantiated model instance will not contain any attribute values. If you would like to define the default values for some of your model's attributes, you may define an ",(0,i.jsx)(n.code,{children:"u_attributes"})," data member on your model, it has to be ",(0,i.jsx)(n.strong,{children:"static"})," and can be ",(0,i.jsx)(n.strong,{children:"const"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The model\'s default values for attributes. */\n inline static const QList u_attributes {\n {"delayed", false},\n {"progress", 0},\n {"added_on", QDateTime::currentDateTimeUtc()},\n };\n};\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["Use the ",(0,i.jsx)(n.code,{children:"Model::instance"})," or ",(0,i.jsx)(n.code,{children:"Model::instanceHeap"})," related methods to instantiate a model that contains a ",(0,i.jsx)(n.code,{children:"QDateTime"})," in Default Attribute Values, or if attributes you want to pass to the model's constructor contain a ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance ",(0,i.jsx)("small",{children:"(problem is described below)"}),"."]})}),"\n",(0,i.jsx)(n.h5,{id:"qdatetime-and-connection-name-problem",children:"QDateTime and connection name problem"}),"\n",(0,i.jsxs)(n.p,{children:["If your Default Attribute Values or attributes that you can pass to the ",(0,i.jsx)(n.code,{children:"Model"})," constructor contain the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance, then ",(0,i.jsx)(n.code,{children:"TinyORM"})," throws an exception. You have to use the ",(0,i.jsx)(n.code,{children:"Model::instance"})," related methods to create such a Model."]}),"\n",(0,i.jsxs)(n.p,{children:["Virtually everything important is covered in the thrown exception, but let me summarize it. The problem is that the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance is converted to a string based on the ",(0,i.jsx)(n.code,{children:"Model::u_dateFormat"}),", or if not defined, the date format from ",(0,i.jsx)(n.code,{children:"Orm::Query::Grammars::Grammar"})," will be used. This ",(0,i.jsx)(n.code,{children:"QueryGrammar"})," is obtained from ",(0,i.jsx)(n.code,{children:"Orm::DatabaseConnection"})," and because of that TinyORM needs to know the ",(0,i.jsx)(n.strong,{children:"connection name"})," and that's the crux of this problem. You can define your connection name using the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," in your derived model class, but this derived model ",(0,i.jsx)(n.strong,{children:"is not yet initialized"}),", so the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," is also not initialized."]}),"\n",(0,i.jsxs)(n.p,{children:["So if the ",(0,i.jsx)(n.code,{children:"Model::u_connection"})," is not yet initialized, ",(0,i.jsx)(n.code,{children:"TinyORM"})," can't obtain the ",(0,i.jsx)(n.code,{children:"Orm::DatabaseConnection"})," -> ",(0,i.jsx)(n.code,{children:"QueryGrammar"})," -> ",(0,i.jsx)(n.code,{children:"dateFormat"}),"."]}),"\n",(0,i.jsx)(n.h2,{id:"retrieving-models",children:"Retrieving Models"}),"\n",(0,i.jsxs)(n.p,{children:["Once you have created a model and its associated database table, you are ready to start retrieving data from your database. You can think of each TinyORM model as a powerful ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," allowing you to fluently query the database table associated with the model. The model's ",(0,i.jsx)(n.code,{children:"all"})," method will retrieve all of the records from the model's associated database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/flight.hpp"\n\nfor (const auto &flight : Flight::all())\n qDebug() << flight["name"].toString();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"building-queries",children:"Building Queries"}),"\n",(0,i.jsxs)(n.p,{children:["The TinyORM ",(0,i.jsx)(n.code,{children:"all"})," method will return all of the results in the model's table. However, since each TinyORM model serves as a ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),", you may add additional constraints to queries and then invoke the ",(0,i.jsx)(n.code,{children:"get"})," method to retrieve the results:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::whereEq("active", 1)\n ->orderBy("name")\n .take(10)\n .get();\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Since TinyORM models are query builders, you should review all of the methods provided by TinyORM's ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),". You may use any of these methods when writing your TinyORM queries."]})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["All the static methods defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class, which start building queries like ",(0,i.jsx)(n.code,{children:"where"}),", ",(0,i.jsx)(n.code,{children:"latest"}),", ",(0,i.jsx)(n.code,{children:"oldest"}),", ",(0,i.jsx)(n.code,{children:"with"}),", ... return ",(0,i.jsx)(n.code,{children:"std::unique_ptr>"}),", ",(0,i.jsx)(n.code,{children:"TinyBuilder = Orm::Tiny::Builder"})," and ",(0,i.jsx)(n.code,{children:"Model"})," template argument is queried model class."]})}),"\n",(0,i.jsx)(n.h4,{id:"refreshing-models",children:"Refreshing Models"}),"\n",(0,i.jsxs)(n.p,{children:['If you already have an instance of the TinyORM model that was retrieved from the database, you can "refresh" the model using the ',(0,i.jsx)(n.code,{children:"fresh"})," and ",(0,i.jsx)(n.code,{children:"refresh"})," methods. The ",(0,i.jsx)(n.code,{children:"fresh"})," method will re-retrieve the model from the database. The existing model instance will not be affected:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::whereEq("number", "FR 900")->first();\n\nauto freshFlight = flight->fresh();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"refresh"})," method will re-hydrate the existing model using fresh data from the database. In addition, all of its loaded relationships will be refreshed as well:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::whereEq("number", "FR 900")->first();\n\nflight->setAttribute("number", "FR 456");\n\nflight->refresh();\n\nflight->getAttribute("number"); // "FR 900"\n'})}),"\n",(0,i.jsx)(n.h3,{id:"containers",children:"Containers"}),"\n",(0,i.jsxs)(n.p,{children:["As we have seen, TinyORM methods like ",(0,i.jsx)(n.code,{children:"all"})," and ",(0,i.jsx)(n.code,{children:"get"})," retrieve multiple records from the database. Since these methods return a ",(0,i.jsx)(n.code,{children:"QList"}),", you can iterate it like any other container with the ",(0,i.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/language/range-for",children:"Range-based for loop"}),", ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/containers.html#stl-style-iterators",children:"STL-Style Iterators"}),", ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/containers.html#java-style-iterators",children:"Java-Style Iterators"})," or ",(0,i.jsx)(n.a,{href:"https://www.walletfox.com/course/quickref_range_v3.php",children:"Ranges"}),"."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/flight.hpp"\n\nfor (const auto &flight : Flight::all())\n qDebug() << flight["name"].toString();\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["An ",(0,i.jsx)(n.code,{children:"all"})," method is defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Model"})," class and ",(0,i.jsx)(n.code,{children:"get"})," method is defined on the ",(0,i.jsx)(n.code,{children:"Orm::Tiny::Builder"}),", may be also referred as ",(0,i.jsx)(n.code,{children:"TinyBuilder"}),", and on the ",(0,i.jsx)(n.code,{children:"Orm::Query::Builder"})," alias ",(0,i.jsx)(n.code,{children:"QueryBuilder"}),"."]})}),"\n",(0,i.jsx)(n.h3,{id:"chunking-results",children:"Chunking Results"}),"\n",(0,i.jsxs)(n.p,{children:["Your application may run out of memory if you attempt to load tens of thousands of TinyORM records via the ",(0,i.jsx)(n.code,{children:"all"})," or ",(0,i.jsx)(n.code,{children:"get"})," methods. Instead of using these methods, the ",(0,i.jsx)(n.code,{children:"chunk"})," method may be used to process large numbers of models more efficiently."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"chunk"})," method will retrieve a subset of TinyORM models, passing them to a lambda expression for processing. Since only the current chunk of TinyORM models is retrieved at a time, the ",(0,i.jsx)(n.code,{children:"chunk"})," method will provide significantly reduced memory usage when working with a large number of models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::chunk(200, [](QList &&flights, const int /*unused*/)\n{\n for (auto &&flight : flights) {\n //\n }\n\n return true;\n});\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The first argument passed to the ",(0,i.jsx)(n.code,{children:"chunk"}),' method is the number of records you wish to receive per "chunk". The lambda expression passed as the second argument will be invoked for each chunk that is retrieved from the database. A database query will be executed to retrieve each chunk of records passed to the lambda expression.']}),"\n",(0,i.jsxs)(n.p,{children:["If you are filtering the results of the ",(0,i.jsx)(n.code,{children:"chunk"})," method based on a column that you will also be updating while iterating over the results, you should use the ",(0,i.jsx)(n.code,{children:"chunkById"})," method. Using the ",(0,i.jsx)(n.code,{children:"chunk"})," method in these scenarios could lead to unexpected and inconsistent results. Internally, the ",(0,i.jsx)(n.code,{children:"chunkById"})," method will always retrieve models with an ",(0,i.jsx)(n.code,{children:"id"})," column greater than the last model in the previous chunk:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::whereEq("departed", true)\n ->chunkById(200, [](QList &&flights, const int /*unused*/)\n {\n for (auto &&flight : flights)\n flight.update({{"departed", false}});\n\n return true;\n });\n'})}),"\n",(0,i.jsx)(n.h3,{id:"advanced-subqueries",children:"Advanced Subqueries"}),"\n",(0,i.jsx)(n.h4,{id:"subquery-selects",children:"Subquery Selects"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM also offers advanced subquery support, which allows you to pull information from related tables in a single query. For example, let's imagine that we have a table of flight ",(0,i.jsx)(n.code,{children:"destinations"})," and a table of ",(0,i.jsx)(n.code,{children:"flights"})," to destinations. The ",(0,i.jsx)(n.code,{children:"flights"})," table contains an ",(0,i.jsx)(n.code,{children:"arrived_at"})," column which indicates when the flight arrived at the destination."]}),"\n",(0,i.jsxs)(n.p,{children:["Using the subquery functionality available to the query builder's ",(0,i.jsx)(n.code,{children:"select"})," and ",(0,i.jsx)(n.code,{children:"addSelect"})," methods, we can select all of the ",(0,i.jsx)(n.code,{children:"destinations"})," and the name of the flight that most recently arrived at that destination using a single query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/destination.hpp"\n#include "models/flight.hpp"\n\nreturn Destination::addSelect(\n Flight::select("name")\n ->whereColumnEq("destination_id", "destinations.id")\n .orderByDesc("arrived_at")\n .limit(1)\n .toBase(),\n "last_flight")\n ->get();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"subquery-ordering",children:"Subquery Ordering"}),"\n",(0,i.jsxs)(n.p,{children:["In addition, the query builder's ",(0,i.jsx)(n.code,{children:"orderBy"})," function supports subqueries. Continuing to use our flight example, we may use this functionality to sort all destinations based on when the last flight arrived at that destination. Again, this may be done while executing a single database query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'return Destination::orderByDesc(\n Flight::select("arrived_at")\n ->whereColumnEq("destination_id", "destinations.id")\n .orderByDesc("arrived_at")\n .limit(1)\n .toBase())\n ->get();\n'})}),"\n",(0,i.jsx)(n.h2,{id:"retrieving-single-models-and-aggregates",children:"Retrieving Single Models / Aggregates"}),"\n",(0,i.jsxs)(n.p,{children:["In addition to retrieving all of the records matching a given query, you may also retrieve single records using the ",(0,i.jsx)(n.code,{children:"find"}),", ",(0,i.jsx)(n.code,{children:"first"}),", ",(0,i.jsx)(n.code,{children:"firstWhere"}),", or ",(0,i.jsx)(n.code,{children:"firstWhereEq"})," methods. Instead of returning a vector of models, these methods return a single model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Retrieve a model by its primary key...\nauto flight = Flight::find(1);\n\n// Retrieve the first model matching the query constraints...\nauto flight = Flight::whereEq("active", 1)->first();\n\n// Alternative to retrieving the first model matching the query constraints...\nauto flight = Flight::firstWhere("active", "=", 1);\n\n// Alternative firstWhere method syntax\nauto flight = Flight::firstWhereEq("active", 1);\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may wish to perform some other action if no results are found. The ",(0,i.jsx)(n.code,{children:"findOr"})," methods will return a single model instance or, if no results are found, execute the given lambda expression. The value returned by the lambda will be considered the result of the method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto flight = Flight::findOr(1, [] {\n // ...\n});\n\nauto flight = Flight::findOr(1, [] {\n // ...\n return 10;\n});\n\nauto flight = Flight::findOr>(1, [] {\n // ...\n return Flight::find(10);\n});\n"})}),"\n",(0,i.jsxs)(n.p,{children:["To obtain only a subset of the model's attributes you may use the ",(0,i.jsx)(n.code,{children:"Model::only"})," method, it returns the ",(0,i.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nusing Orm::Constants::ID;\nusing Orm::Constants::NAME;\n\nauto flight = Flight::find(1);\n\nauto attributes = flight->only({ID, NAME});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"not-found-exceptions",children:"Not Found Exceptions"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may wish to throw an exception if a model is not found. The ",(0,i.jsx)(n.code,{children:"findOrFail"})," and ",(0,i.jsx)(n.code,{children:"firstOrFail"})," methods will retrieve the first result of the query; however, if no result is found, an ",(0,i.jsx)(n.code,{children:"Orm::Tiny::ModelNotFoundError"})," will be thrown:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::findOrFail(1);\n\nauto flight = Flight::where("legs", ">", 3)->firstOrFail();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"retrieving-or-creating-models",children:"Retrieving Or Creating Models"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrCreate"})," method will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first ",(0,i.jsx)(n.code,{children:"QList"})," argument with the optional second ",(0,i.jsx)(n.code,{children:"QList"})," argument:"]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrNew"})," method, like ",(0,i.jsx)(n.code,{children:"firstOrCreate"}),", will attempt to locate a record in the database matching the given attributes. However, if a model is not found, a new model instance will be returned. Note that the model returned by ",(0,i.jsx)(n.code,{children:"firstOrNew"})," has not yet been persisted to the database. You will need to manually call the ",(0,i.jsx)(n.code,{children:"save"})," method to persist it:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Retrieve flight by name or create it if it doesn\'t exist...\nauto flight = Flight::firstOrCreate({\n {"name", "London to Paris"}\n});\n\n// Retrieve flight by name or create it with the name, delayed, and arrival_time attributes...\nauto flight = Flight::firstOrCreate(\n {{"name", "London to Paris"}},\n {{"delayed", 1}, {"arrival_time", "11:30"}}\n);\n\n// Retrieve flight by name or instantiate a new Flight instance...\nauto flight = Flight::firstOrNew({\n {"name", "London to Paris"}\n});\n\n// Retrieve flight by name or instantiate with the name, delayed, and arrival_time attributes...\nauto flight = Flight::firstOrNew(\n {{"name", "Tokyo to Sydney"}},\n {{"delayed", 1}, {"arrival_time", "11:30"}}\n);\n'})}),"\n",(0,i.jsx)(n.h3,{id:"retrieving-aggregates",children:"Retrieving Aggregates"}),"\n",(0,i.jsxs)(n.p,{children:["When interacting with TinyORM models, you may also use the ",(0,i.jsx)(n.code,{children:"count"}),", ",(0,i.jsx)(n.code,{children:"sum"}),", ",(0,i.jsx)(n.code,{children:"max"}),", and other ",(0,i.jsx)(n.a,{href:"/database/query-builder#aggregates",children:"aggregate methods"})," provided by the ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"}),". As you might expect, these methods return a scalar value instead of a TinyORM model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto count = Flight::whereEq("active", 1)->count();\n\nauto max = Flight::whereEq("active", 1)->max("price");\n'})}),"\n",(0,i.jsx)(n.h2,{id:"inserting-and-updating-models",children:"Inserting & Updating Models"}),"\n",(0,i.jsx)(n.h3,{id:"inserts",children:"Inserts"}),"\n",(0,i.jsxs)(n.p,{children:["Of course, when using TinyORM, we don't only need to retrieve models from the database. We also need to insert new records. Thankfully, TinyORM makes it simple. To insert a new record into the database, you should instantiate a new model instance and set attributes on the model. Then, call the ",(0,i.jsx)(n.code,{children:"save"})," method on the model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\n// Store a new flight in the database\nFlight flight;\nflight.setAttribute("name", "Slovakia to Czech");\nflight.save();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["In this example, we assign the ",(0,i.jsx)(n.code,{children:"name"})," attribute of the ",(0,i.jsx)(n.code,{children:"Flight"})," model instance. When we call the ",(0,i.jsx)(n.code,{children:"save"})," method, a record will be inserted into the database. The model's ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamps will automatically be set when the ",(0,i.jsx)(n.code,{children:"save"})," method is called, so there is no need to set them manually."]}),"\n",(0,i.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,i.jsx)(n.code,{children:"create"}),' method to "save" a new model using a single C++ statement. The inserted model instance will be returned to you by the ',(0,i.jsx)(n.code,{children:"create"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::create({\n {"name", "London to Paris"},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["However, before using the ",(0,i.jsx)(n.code,{children:"create"})," method, you will need to specify either a ",(0,i.jsx)(n.code,{children:"u_fillable"})," or ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member on your model class. These static data members are required because all TinyORM models are protected against mass assignment vulnerabilities by default. To learn more about mass assignment, please consult the ",(0,i.jsx)(n.a,{href:"#mass-assignment",children:"mass assignment documentation"}),"."]}),"\n",(0,i.jsx)(n.h3,{id:"updates",children:"Updates"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"save"})," method may also be used to update models that already exist in the database. To update a model, you should retrieve it and set any attributes you wish to update. Then, you should call the model's ",(0,i.jsx)(n.code,{children:"save"})," method. Again, the ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamp will automatically be updated, so there is no need to manually set its value:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::find(1);\n\nflight->setAttribute("name", "Paris to London");\n\nflight->save();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"mass-updates",children:"Mass Updates"}),"\n",(0,i.jsxs)(n.p,{children:["Updates can also be performed against models that match a given query. In this example, all flights that are ",(0,i.jsx)(n.code,{children:"active"})," and have a ",(0,i.jsx)(n.code,{children:"destination"})," of ",(0,i.jsx)(n.code,{children:"San Diego"})," will be marked as delayed:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::whereEq("active", 1)\n ->whereEq("destination", "San Diego")\n .update({{"delayed", 1}});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"update"})," method expects the ",(0,i.jsx)(n.code,{children:"QList"})," of column and value pairs representing the columns that should be updated."]}),"\n",(0,i.jsx)(n.h4,{id:"examining-attribute-changes",children:"Examining Attribute Changes"}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM provides the ",(0,i.jsx)(n.code,{children:"isDirty"}),", ",(0,i.jsx)(n.code,{children:"isClean"}),", and ",(0,i.jsx)(n.code,{children:"wasChanged"})," methods to examine the internal state of your model and determine how its attributes have changed from when the model was originally retrieved."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"isDirty"})," method determines if any of the model's attributes have been changed since the model was retrieved. You may pass a specific attribute name to the ",(0,i.jsx)(n.code,{children:"isDirty"})," method to determine if a particular attribute is dirty. The ",(0,i.jsx)(n.code,{children:"isClean"})," will determine if an attribute has remained unchanged since the model was retrieved. This method also accepts an optional attribute argument:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::create({\n {"first_name", "Silver"},\n {"last_name", "Zachara"},\n {"title", "Developer"},\n});\n\nuser.setAttribute("title", "Painter");\n\nuser.isDirty(); // true\nuser.isDirty("title"); // true\nuser.isDirty("first_name"); // false\n\nuser.isClean(); // false\nuser.isClean("title"); // false\nuser.isClean("first_name"); // true\n\nuser.save();\n\nuser.isDirty(); // false\nuser.isClean(); // true\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"wasChanged"})," method determines if any attributes were changed after the model was last saved into the database. If needed, you may pass an attribute name to see if a particular attribute was changed:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto user = User::create({\n {"first_name", "Silver"},\n {"last_name", "Zachara"},\n {"title", "Developer"},\n});\n\nuser.setAttribute("title", "Painter");\n\nuser.wasChanged(); // false\n\nuser.save();\n\nuser.wasChanged(); // true\nuser.wasChanged("title"); // true\nuser.wasChanged("first_name"); // false\n'})}),"\n",(0,i.jsx)(n.h3,{id:"mass-assignment",children:"Mass Assignment"}),"\n",(0,i.jsxs)(n.p,{children:["You may use the ",(0,i.jsx)(n.code,{children:"create"}),' method to "save" a new model using a single C++ statement. The inserted model instance will be returned to you by the method:']}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::create({\n {"name", "London to Paris"},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["However, before using the ",(0,i.jsx)(n.code,{children:"create"})," method, you will need to specify either a ",(0,i.jsx)(n.code,{children:"u_fillable"})," or ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member on your model class. These data members are required because all TinyORM models are protected against mass assignment vulnerabilities by default."]}),"\n",(0,i.jsxs)(n.p,{children:["A mass assignment vulnerability occurs when a user passes an unexpected HTTP request field and that field changes a column in your database that you did not expect. For example, a malicious user might send an ",(0,i.jsx)(n.code,{children:"is_admin"})," parameter through an HTTP request, which is then passed to your model's ",(0,i.jsx)(n.code,{children:"create"})," method, allowing the user to escalate themselves to an administrator."]}),"\n",(0,i.jsxs)(n.p,{children:["So, to get started, you should define which model attributes you want to make mass assignable. You may do this using the ",(0,i.jsx)(n.code,{children:"u_fillable"})," static data member on the model. For example, let's make the ",(0,i.jsx)(n.code,{children:"name"})," attribute of our ",(0,i.jsx)(n.code,{children:"Flight"})," model mass assignable:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n\n /*! The attributes that are mass assignable. */\n inline static QStringList u_fillable {\n "name",\n };\n};\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Once you have specified which attributes are mass assignable, you may use the ",(0,i.jsx)(n.code,{children:"create"})," method to insert a new record in the database. The ",(0,i.jsx)(n.code,{children:"create"})," method returns the newly created model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::create({{"name", "London to Paris"}});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If you already have a model instance, you may use the ",(0,i.jsx)(n.code,{children:"fill"})," method to populate it with the vector of attributes:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'flight.fill({{"name", "Amsterdam to Frankfurt"}});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"allowing-mass-assignment",children:"Allowing Mass Assignment"}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to make all of your attributes mass assignable, you may define your model's ",(0,i.jsx)(n.code,{children:"u_guarded"})," static data member as an empty vector. If you choose to unguard your model, you should take special care to always hand-craft the vectors passed to TinyORM's ",(0,i.jsx)(n.code,{children:"fill"}),", ",(0,i.jsx)(n.code,{children:"create"}),", and ",(0,i.jsx)(n.code,{children:"update"})," methods:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nusing Orm::Tiny::Model;\n\nclass Flight final : public Model\n{\n friend Model;\n\n using Model::Model;\n\n /*! The attributes that aren't mass assignable. */\n inline static QStringList u_guarded {};\n};\n"})}),"\n",(0,i.jsx)(n.h3,{id:"upserts",children:"Upserts"}),"\n",(0,i.jsx)(n.p,{children:"Occasionally, you may need to update an existing model or create a new model if no matching model exists."}),"\n",(0,i.jsxs)(n.p,{children:["In the example below, if a flight exists with a ",(0,i.jsx)(n.code,{children:"departure"})," location of ",(0,i.jsx)(n.code,{children:"Oakland"})," and a ",(0,i.jsx)(n.code,{children:"destination"})," location of ",(0,i.jsx)(n.code,{children:"San Diego"}),", its ",(0,i.jsx)(n.code,{children:"price"})," and ",(0,i.jsx)(n.code,{children:"discounted"})," columns will be updated. If no such flight exists, a new flight will be created which has the attributes resulting from merging the first argument vector with the second argument vector:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::updateOrCreate(\n {{"departure", "Oakland"}, {"destination", "San Diego"}},\n {{"price", 99}, {"discounted", 1}}\n);\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"firstOrCreate"})," and ",(0,i.jsx)(n.code,{children:"updateOrCreate"})," methods persist the model, so there's no need to manually call the ",(0,i.jsx)(n.code,{children:"save"})," method."]})}),"\n",(0,i.jsxs)(n.p,{children:['If you would like to perform multiple "upserts" in a single query, then you should use the ',(0,i.jsx)(n.code,{children:"upsert"})," method instead. The method's first argument consists of the values to insert or update, while the second argument lists the column(s) that uniquely identify records within the associated table. The method's third and final argument is the vector of the columns that should be updated if a matching record already exists in the database. The ",(0,i.jsx)(n.code,{children:"upsert"})," method will automatically set the ",(0,i.jsx)(n.code,{children:"created_at"})," and ",(0,i.jsx)(n.code,{children:"updated_at"})," timestamps if timestamps are enabled on the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::upsert(\n {{{"departure", "Oakland"}, {"destination", "San Diego"}, {"price", 99}},\n {{"departure", "Chicago"}, {"destination", "New York"}, {"price", 150}}},\n {"departure", "destination"},\n {"price"}\n);\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"caution",children:(0,i.jsxs)(n.p,{children:["All databases except SQL Server require the columns in the second argument of the ",(0,i.jsx)(n.code,{children:"upsert"}),' method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the ',(0,i.jsx)(n.code,{children:"upsert"}),' method and always uses the "primary" and "unique" indexes of the table to detect existing records.']})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html",children:"documentation"}),". The MySQL server version is auto-detected and can be overridden in the ",(0,i.jsx)(n.a,{href:"/database/getting-started#configuration",children:"configuration"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"deleting-models",children:"Deleting Models"}),"\n",(0,i.jsxs)(n.p,{children:["To delete a model, you may call the ",(0,i.jsx)(n.code,{children:"remove"}),", or an alias ",(0,i.jsx)(n.code,{children:"deleteRow"})," method on the model instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include "models/flight.hpp"\n\nauto flight = Flight::find(1);\n\nflight->remove();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"deleting-an-existing-model-by-its-primary-key",children:"Deleting An Existing Model By Its Primary Key"}),"\n",(0,i.jsxs)(n.p,{children:["In the example above, we are retrieving the model from the database before calling the ",(0,i.jsx)(n.code,{children:"remove"})," method. However, if you know the primary key of the model, you may delete the model without explicitly retrieving it by calling the ",(0,i.jsx)(n.code,{children:"destroy"})," method. In addition to accepting the single primary key, the ",(0,i.jsx)(n.code,{children:"destroy"})," method can accept multiple primary keys:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::destroy(1);\n\nFlight::destroy({1, 2, 3});\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"destroy"})," method loads models from the database and calls the ",(0,i.jsx)(n.code,{children:"remove"})," method on each model individually, the reason for this is future compatibility with events."]})}),"\n",(0,i.jsx)(n.h4,{id:"deleting-models-using-queries",children:"Deleting Models Using Queries"}),"\n",(0,i.jsx)(n.p,{children:"Of course, you may build the query to delete all models matching your query's criteria. In this example, we will delete all flights that are marked as inactive:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto deletedRows = Flight::whereEq("active", 0)->remove();\n'})}),"\n",(0,i.jsx)(n.h3,{id:"soft-deleting",children:"Soft Deleting"}),"\n",(0,i.jsxs)(n.p,{children:['In addition to actually removing records from your database, TinyORM can also "soft delete" models. When models are soft deleted, they are not actually removed from your database. Instead, a ',(0,i.jsx)(n.code,{children:"deleted_at"}),' attribute is set on the model indicating the date and time at which the model was "deleted". To enable soft deletes for a model, add the ',(0,i.jsx)(n.code,{children:"Orm::Tiny::SoftDeletes"})," base class to the model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::SoftDeletes;\n\nclass Flight final : public Model,\n public SoftDeletes\n{\n friend Model;\n using Model::Model;\n\nprivate:\n /*! The table associated with the model. */\n QString u_table {"flights"};\n};\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"SoftDeletes"})," base class will automatically cast the ",(0,i.jsx)(n.code,{children:"deleted_at"})," attribute to the ",(0,i.jsx)(n.code,{children:"QDateTime"})," instance for you (it adds the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to the model's ",(0,i.jsx)(n.a,{href:"#timestamps-u_dates",children:(0,i.jsx)(n.code,{children:"u_dates"})})," list)."]})}),"\n",(0,i.jsxs)(n.p,{children:["You should also add the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to your database table. The TinyORM ",(0,i.jsx)(n.a,{href:"/database/migrations",children:"schema builder"})," contains a helper method to create this column:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Schema::table("flights", [](Blueprint &table)\n{\n table.softDeletes();\n});\n\nSchema::table("flights", [](Blueprint &table)\n{\n table.dropSoftDeletes();\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Now, when you call the ",(0,i.jsx)(n.code,{children:"remove"})," or ",(0,i.jsx)(n.code,{children:"deleteModel"})," method on the model, the ",(0,i.jsx)(n.code,{children:"deleted_at"})," column will be set to the current date and time. However, the model's database record will be left in the table. When querying a model that uses soft deletes, the soft deleted models will automatically be excluded from all query results."]}),"\n",(0,i.jsxs)(n.p,{children:["To determine if a given model instance has been soft deleted, you may use the ",(0,i.jsx)(n.code,{children:"trashed"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (flight->trashed()) {\n //\n}\n"})}),"\n",(0,i.jsx)(n.h4,{id:"restoring-soft-deleted-models",children:"Restoring Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:['Sometimes you may wish to "un-delete" a soft deleted model. To restore a soft deleted model, you may call the ',(0,i.jsx)(n.code,{children:"restore"})," method on a model instance. The ",(0,i.jsx)(n.code,{children:"restore"})," method will set the model's ",(0,i.jsx)(n.code,{children:"deleted_at"})," column to ",(0,i.jsx)(n.code,{children:"null"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->restore();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"restore"})," method in a query to restore multiple models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'Flight::withTrashed()\n ->whereEq("airline_id", 1)\n .restore();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"restore"})," method may also be used when building ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," queries:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->restore();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"permanently-deleting-models",children:"Permanently Deleting Models"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may need to truly remove a model from your database. You may use the ",(0,i.jsx)(n.code,{children:"forceDelete"})," method (or it's alias ",(0,i.jsx)(n.code,{children:"forceRemove"}),") to permanently remove a soft deleted model from the database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->forceDelete();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"forceDelete"})," method when building TinyORM relationship queries:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->forceDelete();\n"})}),"\n",(0,i.jsx)(n.h3,{id:"querying-soft-deleted-models",children:"Querying Soft Deleted Models"}),"\n",(0,i.jsx)(n.h4,{id:"including-soft-deleted-models",children:"Including Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["As noted above, soft deleted models will automatically be excluded from query results. However, you may force soft deleted models to be included in a query's results by calling the ",(0,i.jsx)(n.code,{children:"withTrashed"})," method on the query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::withTrashed()\n ->whereEq("account_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"withTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->withTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"retrieving-only-soft-deleted-models",children:"Retrieving Only Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"onlyTrashed"})," method will retrieve ",(0,i.jsx)(n.strong,{children:"only"})," soft deleted models:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::onlyTrashed()\n ->whereEq("airline_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"onlyTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->onlyTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h4,{id:"excluding-soft-deleted-models",children:"Excluding Soft Deleted Models"}),"\n",(0,i.jsxs)(n.p,{children:["As noted above, soft deleted models will automatically be excluded from query results. However, you may force soft deleted models to be ",(0,i.jsx)(n.strong,{children:"excluded"})," in a query's results by calling the ",(0,i.jsx)(n.code,{children:"withoutTrashed"})," method on the query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flights = Flight::withoutTrashed()\n ->whereEq("account_id", 1)\n .get();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"withoutTrashed"})," method may also be called when building a ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationship"})," query:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"flight->history()->withoutTrashed().get();\n"})}),"\n",(0,i.jsx)(n.h3,{id:"truncate-table",children:"Truncate Table"}),"\n",(0,i.jsxs)(n.p,{children:["You may call the ",(0,i.jsx)(n.code,{children:"truncate"})," method to delete all of the model's associated database records. The ",(0,i.jsx)(n.code,{children:"truncate"})," operation will also reset any auto-incrementing IDs on the model's associated table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"Flight::truncate();\n"})}),"\n",(0,i.jsx)(n.h2,{id:"replicating-models",children:"Replicating Models"}),"\n",(0,i.jsxs)(n.p,{children:["You may create an unsaved copy of an existing model instance using the ",(0,i.jsx)(n.code,{children:"replicate"})," method. This method is particularly useful when you have model instances that share many of the same attributes:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto shipping = Address::create({\n {"type", "shipping"},\n {"line_1", "123 Example Street"},\n {"city", "Victorville"},\n {"state", "CA"},\n {"postcode", "90001"},\n});\n\nauto billing = shipping.replicate();\n\nbilling.fill({\n {"type", "billing"},\n});\n\nbilling.save();\n'})}),"\n",(0,i.jsxs)(n.p,{children:["To exclude one or more attributes from being replicated to the new model, you may pass an unordered_set to the ",(0,i.jsx)(n.code,{children:"replicate"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'auto flight = Flight::create({\n {"destination", "LAX"},\n {"origin", "LHR"},\n {"last_flown", "2020-03-04 11:00:00"},\n {"last_pilot_id", 747},\n});\n\nflight = flight.replicate({\n "last_flown",\n "last_pilot_id",\n});\n'})}),"\n",(0,i.jsx)(n.h2,{id:"comparing-models",children:"Comparing Models"}),"\n",(0,i.jsxs)(n.p,{children:['Sometimes you may need to determine if two models are the "same" or not. The ',(0,i.jsx)(n.code,{children:"is"})," and ",(0,i.jsx)(n.code,{children:"isNot"})," methods may be used to quickly verify two models have the same primary key, table, and database connection or not:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (post->is(anotherPost)) {\n //\n}\n\nif (post->isNot(anotherPost)) {\n //\n}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"is"})," and ",(0,i.jsx)(n.code,{children:"isNot"})," methods are also available when using the ",(0,i.jsx)(n.code,{children:"belongsTo"})," and ",(0,i.jsx)(n.code,{children:"hasOne"})," ",(0,i.jsx)(n.a,{href:"/tinyorm/relationships",children:"relationships"}),". This method is particularly helpful when you would like to compare a related model without issuing a query to retrieve that model:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"if (post->author()->is(user)) {\n //\n}\n"})}),"\n",(0,i.jsx)(n.h5,{id:"equality-comparison",children:"Equality comparison"}),"\n",(0,i.jsxs)(n.p,{children:["The base ",(0,i.jsx)(n.code,{children:"Model"})," class also defines the ",(0,i.jsx)(n.code,{children:"operator=="})," that allows precisely comparing two models. It compares the content of all the model's data members, from all base classes to the most derived model class. The ",(0,i.jsx)(n.code,{children:"model1 == model2"})," expression guarantees that these two models are exactly the same."]}),"\n",(0,i.jsxs)(n.p,{children:["It would be appropriate to mention that this comparison also includes relations, which means it will also compare ",(0,i.jsx)(n.strong,{children:"all"})," models (including their data members) these relations contain."]})]})}function m(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var i=t(6540);const s={},a=i.createContext(s);function l(e){const n=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),i.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/5e95c892.7024aad0.js b/assets/js/5e95c892.f92788a2.js similarity index 63% rename from assets/js/5e95c892.7024aad0.js rename to assets/js/5e95c892.f92788a2.js index 2f6bf0d45..dc173869f 100644 --- a/assets/js/5e95c892.7024aad0.js +++ b/assets/js/5e95c892.f92788a2.js @@ -1 +1 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[647],{7121:(e,r,s)=>{s.r(r),s.d(r,{default:()=>i});s(6540);var n=s(4164),t=s(9024),u=s(7559),a=s(2831),c=s(9201),o=s(4848);function i(e){return(0,o.jsx)(t.e3,{className:(0,n.A)(u.G.wrapper.docsPages),children:(0,o.jsx)(c.A,{children:(0,a.v)(e.route.routes)})})}}}]); \ No newline at end of file +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[647],{7121:(e,r,s)=>{s.r(r),s.d(r,{default:()=>i});s(6540);var n=s(4164),t=s(9024),u=s(7559),a=s(2831),c=s(1957),o=s(4848);function i(e){return(0,o.jsx)(t.e3,{className:(0,n.A)(u.G.wrapper.docsPages),children:(0,o.jsx)(c.A,{children:(0,a.v)(e.route.routes)})})}}}]); \ No newline at end of file diff --git a/assets/js/62a1276f.052e6f7b.js b/assets/js/62a1276f.052e6f7b.js new file mode 100644 index 000000000..590614f1e --- /dev/null +++ b/assets/js/62a1276f.052e6f7b.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[304],{2403:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>o,default:()=>u,frontMatter:()=>r,metadata:()=>d,toc:()=>l});var i=n(4848),s=n(8453),a=n(8774);const r={sidebar_position:3,sidebar_label:"Casts",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",keywords:["c++ orm","orm","casts","casting","attributes","tinyorm"]},o="TinyORM: Casting",d={id:"tinyorm/casts",title:"TinyORM: Casting",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",source:"@site/docs/tinyorm/casts.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/casts",permalink:"/tinyorm/casts",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Casts",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",keywords:["c++ orm","orm","casts","casting","attributes","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Collections",permalink:"/tinyorm/collections"},next:{title:"Serialization",permalink:"/tinyorm/serialization"}},c={},l=[{value:"Introduction",id:"introduction",level:2},{value:"Accessors",id:"accessors",level:2},{value:"Defining An Accessor",id:"defining-an-accessor",level:3},{value:"Building Value From Multiple Attributes",id:"building-value-from-multiple-attributes",level:4},{value:"Accessor Caching",id:"accessor-caching",level:4},{value:"Attribute Casting",id:"attribute-casting",level:2},{value:"Date Casting",id:"date-casting",level:3},{value:"Date Casting, Serialization & Timezones",id:"date-casting-serialization-and-timezones",level:4},{value:"Query Time Casting",id:"query-time-casting",level:3}];function h(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"tinyorm-casting",children:"TinyORM: Casting"})}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"#accessors",children:"Accessors"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#defining-an-accessor",children:"Defining An Accessor"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"#attribute-casting",children:"Attribute Casting"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#date-casting",children:"Date Casting"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#query-time-casting",children:"Query Time Casting"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{className:"api-stability alert alert--success",children:(0,i.jsxs)(t.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(t.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(t.p,{children:["Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a ",(0,i.jsx)(t.code,{children:"datetime"})," string that is stored in your database to the ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance when it is accessed via your TinyORM model. Or, you may want to convert a ",(0,i.jsx)(t.code,{children:"tinyint"})," number that is stored in the database to the ",(0,i.jsx)(t.code,{children:"bool"})," when you access it on the TinyORM model."]}),"\n",(0,i.jsx)(t.h2,{id:"accessors",children:"Accessors"}),"\n",(0,i.jsx)(t.admonition,{type:"warning",children:(0,i.jsxs)(t.p,{children:["Accessors are currently only used during the serialization by the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"Appending Values"})," feature. They are not used during the ",(0,i.jsx)(t.code,{children:"getAttribute"})," or ",(0,i.jsx)(t.code,{children:"getAttributeValue"})," methods calls."]})}),"\n",(0,i.jsx)(t.h3,{id:"defining-an-accessor",children:"Defining An Accessor"}),"\n",(0,i.jsxs)(t.p,{children:["An accessor transforms a TinyORM attribute value when it is accessed (currently during serialization only by the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"Appending Values"}),' feature). To define an accessor, create a protected method on your model to represent the accessible attribute. This method name should correspond to the "camelCase" representation of the true underlying model attribute / database column when applicable.']}),"\n",(0,i.jsxs)(t.p,{children:["In this example, we'll define an accessor for the ",(0,i.jsx)(t.code,{children:"first_name"})," attribute. The accessor will automatically be called by TinyORM during serialization if the ",(0,i.jsx)(t.code,{children:"first_name"})," attribute is defined in the ",(0,i.jsx)(t.code,{children:"u_appends"})," data member set. All attribute accessor methods must return the ",(0,i.jsx)(t.code,{children:"Orm::Tiny::Casts::Attribute"}),":"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\nprotected:\n /*! Get the user\'s first name (accessor). */\n Attribute firstName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n auto firstName = getAttribute("first_name");\n\n if (!firstName.isEmpty())\n firstName[0] = firstName.at(0).toUpper();\n\n return firstName;\n });\n }\n\nprivate:\n /*! Map of mutator names to methods. */\n inline static const QHash u_mutators {\n {"first_name", &User::firstName},\n };\n};\n'})}),"\n",(0,i.jsxs)(t.p,{children:["All accessor methods return an ",(0,i.jsx)(t.code,{children:"Attribute"})," instance which defines how the attribute will be accessed. To do so, we supply the ",(0,i.jsx)(t.code,{children:"get"})," argument to the ",(0,i.jsx)(t.code,{children:"Attribute"})," class constructor or ",(0,i.jsx)(t.code,{children:"Attribute::make"})," factory method."]}),"\n",(0,i.jsxs)(t.p,{children:["As you can see, the current model is captured by-reference using the ",(0,i.jsx)(t.code,{children:"[this]"})," capture, allowing you to obtain a value by the ",(0,i.jsx)(t.code,{children:"getAttribute"})," method inside the lambda expression, manipulate it and return a new value."]}),"\n",(0,i.jsxs)(t.p,{children:["You can also use the second overload that allows you to pass the ",(0,i.jsx)(t.code,{children:"ModelAttributes"})," unordered map to the lambda expression:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'protected:\n /*! Get the user\'s first name (accessor). */\n Attribute firstName() const noexcept\n {\n return Attribute::make(\n /* get */ [](const ModelAttributes &attributes) -> QVariant\n {\n auto firstName = attributes.at("first_name");\n\n if (!firstName.isEmpty())\n firstName[0] = firstName.at(0).toUpper();\n\n return firstName;\n });\n }\n'})}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.a,{href:"https://github.com/silverqx/TinyORM/blob/main/include/orm/tiny/types/modelattributes.hpp",children:(0,i.jsx)(t.code,{children:"ModelAttributes"})})," container extends the ",(0,i.jsx)(t.code,{children:"std::unordered_map"})," and adds the ",(0,i.jsx)(t.code,{children:"at"})," method that allows you to cast the underlying QVariant value."]}),"\n",(0,i.jsxs)(t.p,{children:["Special note should be given to the ",(0,i.jsx)(t.code,{children:"u_mutators"})," static data member map, which maps accessors' attribute names to its methods. This data member is ",(0,i.jsx)(t.strong,{children:"required"})," because C++ does not currently support reflection."]}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["If you would like these computed values to be added to the vector, map, or JSON representations of your model, ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"you will need to append them"}),"."]})}),"\n",(0,i.jsx)(t.admonition,{type:"danger",children:(0,i.jsx)(t.p,{children:"You must guarantee that the current model will live long enough to avoid the dangling reference and crash if the current model is captured by-reference. Of course, you can capture it by-copy in edge cases or if you can't guarantee this."})}),"\n",(0,i.jsx)(t.h4,{id:"building-value-from-multiple-attributes",children:"Building Value From Multiple Attributes"}),"\n",(0,i.jsx)(t.p,{children:"Sometimes your accessor may need to transform multiple model attributes into a single value. You can use both methods described above to accomplish this:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Constants::SPACE_IN;\n\nprotected:\n /*! Get the user\'s full name (accessor). */\n Attribute fullName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n return SPACE_IN.arg(getAttribute("first_name"),\n getAttribute("last_name"));\n });\n }\n'})}),"\n",(0,i.jsxs)(t.p,{children:["Or you can use the ",(0,i.jsx)(t.code,{children:"ModelAttributes"})," overload:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! Get the user\'s full name (accessor). */\nAttribute fullName() const noexcept\n{\n return Attribute::make(\n /* get */ [](const ModelAttributes &attributes) -> QVariant\n {\n return SPACE_IN.arg(attributes.at("first_name"),\n attributes.at("last_name"));\n });\n}\n'})}),"\n",(0,i.jsx)(t.h4,{id:"accessor-caching",children:"Accessor Caching"}),"\n",(0,i.jsxs)(t.p,{children:["Sometimes computing an attribute value can be intensive, in this case, you can enable caching for this attribute value. To accomplish this, you have to invoke the ",(0,i.jsx)(t.code,{children:"shouldCache"})," method when defining your accessor:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Constants::SPACE_IN;\n\nprotected:\n /*! Get the user\'s full name (accessor). */\n Attribute fullName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n return SPACE_IN.arg(getAttribute("first_name"),\n getAttribute("last_name"));\n }).shouldCache();\n }\n'})}),"\n",(0,i.jsx)(t.h2,{id:"attribute-casting",children:"Attribute Casting"}),"\n",(0,i.jsxs)(t.p,{children:["Attribute casting provides functionality that allows converting model attributes to the appropriate ",(0,i.jsx)(t.code,{children:"QVariant"})," ",(0,i.jsx)(t.strong,{children:"metatype"})," when it is accessed via your TinyORM model. The core of this functionality is a model's ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member that provides a convenient method of converting attributes' ",(0,i.jsx)(t.code,{children:"QVariant"})," ",(0,i.jsx)(t.strong,{children:"internal types"})," to the defined cast types."]}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member should be the ",(0,i.jsx)(t.code,{children:"std::unordered_map"})," where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are:"]}),"\n",(0,i.jsx)("div",{id:"casts-types-list",children:(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QString"})}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::Boolean"})," / ",(0,i.jsx)(t.code,{children:"CastType::Bool"})]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::Integer"})," / ",(0,i.jsx)(t.code,{children:"CastType::Int"})]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::UInteger"})," / ",(0,i.jsx)(t.code,{children:"CastType::UInt"})]}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::LongLong"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::ULongLong"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Short"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::UShort"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QDate"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QDateTime"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Timestamp"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Real"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Float"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Double"})}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)("code",{children:"CastType::Decimal:"}),"\n"]}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QByteArray"})}),"\n"]})}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["The primary key name defined by the ",(0,i.jsx)(t.code,{children:"u_primaryKey"})," model's data member is automatically cast to the ",(0,i.jsx)(t.code,{children:"CastType::ULongLong"})," for all database drivers if the ",(0,i.jsx)(t.code,{children:"u_incrementing"})," is set to true (its default value)."]})}),"\n",(0,i.jsxs)(t.p,{children:["To demonstrate attribute casting, let's cast the ",(0,i.jsx)(t.code,{children:"is_admin"})," attribute, which is stored in our database as an integer (",(0,i.jsx)(t.code,{children:"0"})," or ",(0,i.jsx)(t.code,{children:"1"}),") to a ",(0,i.jsx)(t.code,{children:"QVariant(bool)"})," value:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be cast. */\n inline static std::unordered_map u_casts {\n {"is_admin", CastType::Boolean},\n };\n};\n'})}),"\n",(0,i.jsxs)(t.p,{children:["After defining the cast, the ",(0,i.jsx)(t.code,{children:"is_admin"})," attribute will always be cast to a ",(0,i.jsx)(t.code,{children:"QVariant(bool)"})," when you access it, even if the underlying value is stored in the database as an integer:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Utils::Helpers;\n\nauto isAdmin = User::find(1)->getAttribute("is_admin");\n\n// Proof of the QVariant type\nQ_ASSERT(Helpers::qVariantTypeId(isAdmin) == QMetaType::Bool);\n\nif (isAdmin.value()) {\n //\n}\n'})}),"\n",(0,i.jsxs)(t.p,{children:["If you need to add a new, ",(0,i.jsx)(t.strong,{children:"temporary"})," cast at runtime, you may use the ",(0,i.jsx)(t.code,{children:"mergeCasts"})," method. These cast definitions will be added to any of the casts already defined on the model:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'user->mergeCasts({\n {"is_paid", CastType::Boolean},\n {"income", {CastType::Decimal, 2}},\n});\n'})}),"\n",(0,i.jsx)(t.admonition,{type:"warning",children:(0,i.jsx)(t.p,{children:"You should never define a cast (or an attribute) that has the same name as a relationship."})}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["Attributes that are ",(0,i.jsx)(t.code,{children:"null"})," ",(0,i.jsx)(t.strong,{children:"will also be"})," cast so that the ",(0,i.jsx)(t.code,{children:"QVariant"}),"'s internal type will have the correct type."]})}),"\n",(0,i.jsx)(t.h3,{id:"date-casting",children:"Date Casting"}),"\n",(0,i.jsxs)(t.p,{children:["By default, TinyORM will cast the ",(0,i.jsx)(t.code,{children:"created_at"})," and ",(0,i.jsx)(t.code,{children:"updated_at"})," columns to instances of ",(0,i.jsx)(t.code,{children:"QDateTime"}),". You may cast additional date attributes by defining additional date casts within your model's ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member unordered map. Typically, dates should be cast using the ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"}),", ",(0,i.jsx)(t.code,{children:"CastType::QDate"}),", or ",(0,i.jsx)(t.code,{children:"CastType::Timestamp"})," cast types."]}),"\n",(0,i.jsxs)(t.p,{children:["When a database column is of the date type, you may set the corresponding model attribute value to a Unix timestamp, date string (",(0,i.jsx)(t.code,{children:"Y-m-d"}),"), date-time string, ",(0,i.jsx)(t.code,{children:"QDate"}),", or ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance. The date's value will be correctly converted and stored in your database.",(0,i.jsx)("br",{}),"\nThe same is true for the datetime or timestamp database column types, you can set the corresponding model attribute value to a Unix timestamp, date-time string, or a ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance."]}),"\n",(0,i.jsxs)(t.p,{children:["When defining the ",(0,i.jsx)(t.code,{children:"CastType::QDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast, you may also specify the date's format. In this case you must use the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types. This format will be used when the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization",children:"model is serialized to a vector, map, or JSON"}),":"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! The attributes that should be cast. */\ninline static std::unordered_map u_casts {\n {"created_at", {CastType::CustomQDateTime, "yyyy-MM-dd"}},\n};\n'})}),"\n",(0,i.jsx)(t.admonition,{type:"note",children:(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types behave exactly like the ",(0,i.jsx)(t.code,{children:"CastType::QDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast types with the additional ",(0,i.jsx)(t.strong,{children:"date's format"})," functionality during ",(0,i.jsx)("u",{children:(0,i.jsx)(t.strong,{children:"serialization"})}),"."]})}),"\n",(0,i.jsxs)(t.p,{children:["You may customize the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#customizing-the-default-date-format",children:"default serialization format"})," for all of your model's dates or datetimes by defining a ",(0,i.jsx)(t.code,{children:"serializeDate"})," or ",(0,i.jsx)(t.code,{children:"serializeDateTime"})," methods on your model. These methods do not affect how your dates are formatted for storage in the database:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! Prepare a date for vector, map, or JSON serialization. */\nQString serializeDate(const QDate date)\n{\n return date.toString("yyyy-MM-dd");\n}\n\n/*! Prepare a datetime for vector, map, or JSON serialization. */\nQString serializeDateTime(const QDateTime &datetime)\n{\n return datetime.toUTC().toString("yyyy-MM-ddTHH:mm:ssZ");\n}\n'})}),"\n",(0,i.jsxs)(t.p,{children:["To specify the format that should be used when actually storing a model's dates within your database, you should define a ",(0,i.jsx)(t.code,{children:"u_dateFormat"})," data member on your model:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:"/*! The storage format of the model's date columns. */\ninline static QString u_dateFormat {QLatin1Char('U')};\n"})}),"\n",(0,i.jsxs)(t.p,{children:["This format can be any format that the QDateTime's ",(0,i.jsx)(t.code,{children:"fromString"})," or ",(0,i.jsx)(t.code,{children:"toString"})," methods accept or the special ",(0,i.jsx)(t.code,{children:"U"})," format that represents the Unix timestamp (this ",(0,i.jsx)(t.code,{children:"U"})," format is TinyORM-specific and isn't supported by ",(0,i.jsx)(t.code,{children:"QDateTime"}),")."]}),"\n",(0,i.jsxs)(t.p,{children:["Define a ",(0,i.jsx)(t.code,{children:"u_timeFormat"})," data member on your model to specify the format that should be used when storing a model's times within your database:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! The storage format of the model\'s time columns. */\ninline static QString u_timeFormat {"HH:mm:ss.zzz"};\n'})}),"\n",(0,i.jsx)(t.h4,{id:"date-casting-serialization-and-timezones",children:"Date Casting, Serialization & Timezones"}),"\n",(0,i.jsxs)(t.p,{children:["By default, the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," casts will serialize dates to a UTC ISO-8601 date string (",(0,i.jsx)(t.code,{children:"yyyy-MM-ddTHH:mm:ss.zzzZ"}),"), regardless of the timezone specified in your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option. You are strongly encouraged to always use this serialization format, as well as to store your application's dates in the UTC timezone by not changing your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option from its default ",(0,i.jsx)(t.code,{children:"QTimeZone::UTC"})," value. Consistently using the UTC timezone throughout your application will provide the maximum level of interoperability with other date manipulation libraries or services written in any programming language."]}),"\n",(0,i.jsxs)(t.p,{children:["If a custom format is applied to the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types, such as ",(0,i.jsx)(t.code,{children:'{CastType::CustomQDateTime, "yyyy-MM-dd HH:mm:ss"}'}),", the inner timezone of the QDateTime instance will be used during date serialization. Typically, this will be the timezone specified in your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option."]}),"\n",(0,i.jsxs)(t.admonition,{type:"info",children:[(0,i.jsxs)(t.p,{children:["Passing the ",(0,i.jsx)(t.code,{children:"Qt::TimeSpec"})," (eg. ",(0,i.jsx)(t.code,{children:"Qt::UTC"})," or ",(0,i.jsx)(t.code,{children:"Qt::LocalTime"}),") to ",(0,i.jsx)(t.code,{children:"QDateTime"})," methods was deprecated in ",(0,i.jsx)(t.a,{href:"https://github.com/qt/qtbase/commit/8c8d6ff7b6e2e6b1b673051685f1499ae4d65e05?diff=unified&w=0",children:(0,i.jsx)(t.code,{children:"Qt >=6.5"})}),", it was replaced by the ",(0,i.jsx)(t.code,{children:"enum QTimeZone::Initialization"})," (",(0,i.jsx)(t.code,{children:"QTimeZone::UTC"})," and ",(0,i.jsx)(t.code,{children:"QTimeZone::LocalTime"}),")."]}),(0,i.jsxs)(t.p,{children:["If you need to support older and newer versions of Qt at the same time, you can use the ",(0,i.jsx)(t.code,{children:"Orm::QtTimeZoneConfig::utc()"})," or ",(0,i.jsx)(t.code,{children:"QtTimeZoneConfig::localTime()"})," factory methods to create the ",(0,i.jsx)(t.code,{children:"QtTimeZoneConfig"})," instance."]})]}),"\n",(0,i.jsx)(t.h3,{id:"query-time-casting",children:"Query Time Casting"}),"\n",(0,i.jsx)(t.p,{children:"Sometimes you may need to apply casts while executing a query, such as when selecting a raw value from a table. For example, consider the following query:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Models::Post;\nusing Models::User;\n\nauto users = User::select("users.*")\n ->addSelect(\n Post::selectRaw("MAX(created_at)")\n ->whereColumnEq("user_id", "users.id")\n .toBase(),\n "last_posted_at"\n ).get();\n'})}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"last_posted_at"})," attribute on the results of this query will be a simple string. It would be wonderful if we could apply a ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast to this attribute when executing the query. Thankfully, we may accomplish this using the ",(0,i.jsx)(t.code,{children:"withCasts"})," or ",(0,i.jsx)(t.code,{children:"withCast"})," methods:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'auto users = User::select("users.*")\n ->addSelect(Post::selectRaw("MAX(created_at)")\n ->whereColumnEq("user_id", "users.id")\n .toBase(),\n "last_posted_at")\n .withCast({"last_posted_at", CastType::QDateTime})\n .get();\n'})})]})}function u(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>o});var i=n(6540);const s={},a=i.createContext(s);function r(e){const t=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/62a1276f.2590df53.js b/assets/js/62a1276f.2590df53.js deleted file mode 100644 index 33a9ad055..000000000 --- a/assets/js/62a1276f.2590df53.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[304],{2403:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>o,default:()=>u,frontMatter:()=>r,metadata:()=>c,toc:()=>l});var i=n(4848),s=n(8453),a=n(8774);const r={sidebar_position:3,sidebar_label:"Casts",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",keywords:["c++ orm","orm","casts","casting","attributes","tinyorm"]},o="TinyORM: Casting",c={id:"tinyorm/casts",title:"TinyORM: Casting",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",source:"@site/docs/tinyorm/casts.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/casts",permalink:"/tinyorm/casts",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Casts",description:"Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a `datetime` string that is stored in your database to the `QDateTime` instance when it is accessed via your TinyORM model.",keywords:["c++ orm","orm","casts","casting","attributes","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Collections",permalink:"/tinyorm/collections"},next:{title:"Serialization",permalink:"/tinyorm/serialization"}},d={},l=[{value:"Introduction",id:"introduction",level:2},{value:"Accessors",id:"accessors",level:2},{value:"Defining An Accessor",id:"defining-an-accessor",level:3},{value:"Building Value From Multiple Attributes",id:"building-value-from-multiple-attributes",level:4},{value:"Accessor Caching",id:"accessor-caching",level:4},{value:"Attribute Casting",id:"attribute-casting",level:2},{value:"Date Casting",id:"date-casting",level:3},{value:"Date Casting, Serialization & Timezones",id:"date-casting-serialization-and-timezones",level:4},{value:"Query Time Casting",id:"query-time-casting",level:3}];function h(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.h1,{id:"tinyorm-casting",children:"TinyORM: Casting"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"#accessors",children:"Accessors"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#defining-an-accessor",children:"Defining An Accessor"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.a,{href:"#attribute-casting",children:"Attribute Casting"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#date-casting",children:"Date Casting"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.a,{href:"#query-time-casting",children:"Query Time Casting"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{class:"api-stability alert alert--success",children:(0,i.jsxs)(t.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(t.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(t.p,{children:["Attribute casting allows you to transform TinyORM attribute values when you retrieve them on model instances. For example, you may want to convert a ",(0,i.jsx)(t.code,{children:"datetime"})," string that is stored in your database to the ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance when it is accessed via your TinyORM model. Or, you may want to convert a ",(0,i.jsx)(t.code,{children:"tinyint"})," number that is stored in the database to the ",(0,i.jsx)(t.code,{children:"bool"})," when you access it on the TinyORM model."]}),"\n",(0,i.jsx)(t.h2,{id:"accessors",children:"Accessors"}),"\n",(0,i.jsx)(t.admonition,{type:"warning",children:(0,i.jsxs)(t.p,{children:["Accessors are currently only used during the serialization by the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"Appending Values"})," feature. They are not used during the ",(0,i.jsx)(t.code,{children:"getAttribute"})," or ",(0,i.jsx)(t.code,{children:"getAttributeValue"})," methods calls."]})}),"\n",(0,i.jsx)(t.h3,{id:"defining-an-accessor",children:"Defining An Accessor"}),"\n",(0,i.jsxs)(t.p,{children:["An accessor transforms a TinyORM attribute value when it is accessed (currently during serialization only by the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"Appending Values"}),' feature). To define an accessor, create a protected method on your model to represent the accessible attribute. This method name should correspond to the "camelCase" representation of the true underlying model attribute / database column when applicable.']}),"\n",(0,i.jsxs)(t.p,{children:["In this example, we'll define an accessor for the ",(0,i.jsx)(t.code,{children:"first_name"})," attribute. The accessor will automatically be called by TinyORM during serialization if the ",(0,i.jsx)(t.code,{children:"first_name"})," attribute is defined in the ",(0,i.jsx)(t.code,{children:"u_appends"})," data member set. All attribute accessor methods must return the ",(0,i.jsx)(t.code,{children:"Orm::Tiny::Casts::Attribute"}),":"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\nprotected:\n /*! Get the user\'s first name (accessor). */\n Attribute firstName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n auto firstName = getAttribute("first_name");\n\n if (!firstName.isEmpty())\n firstName[0] = firstName.at(0).toUpper();\n\n return firstName;\n });\n }\n\nprivate:\n /*! Map of mutator names to methods. */\n inline static const QHash u_mutators {\n {"first_name", &User::firstName},\n };\n};\n'})}),"\n",(0,i.jsxs)(t.p,{children:["All accessor methods return an ",(0,i.jsx)(t.code,{children:"Attribute"})," instance which defines how the attribute will be accessed. To do so, we supply the ",(0,i.jsx)(t.code,{children:"get"})," argument to the ",(0,i.jsx)(t.code,{children:"Attribute"})," class constructor or ",(0,i.jsx)(t.code,{children:"Attribute::make"})," factory method."]}),"\n",(0,i.jsxs)(t.p,{children:["As you can see, the current model is captured by-reference using the ",(0,i.jsx)(t.code,{children:"[this]"})," capture, allowing you to obtain a value by the ",(0,i.jsx)(t.code,{children:"getAttribute"})," method inside the lambda expression, manipulate it and return a new value."]}),"\n",(0,i.jsxs)(t.p,{children:["You can also use the second overload that allows you to pass the ",(0,i.jsx)(t.code,{children:"ModelAttributes"})," unordered map to the lambda expression:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'protected:\n /*! Get the user\'s first name (accessor). */\n Attribute firstName() const noexcept\n {\n return Attribute::make(\n /* get */ [](const ModelAttributes &attributes) -> QVariant\n {\n auto firstName = attributes.at("first_name");\n\n if (!firstName.isEmpty())\n firstName[0] = firstName.at(0).toUpper();\n\n return firstName;\n });\n }\n'})}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.a,{href:"https://github.com/silverqx/TinyORM/blob/main/include/orm/tiny/types/modelattributes.hpp",children:(0,i.jsx)(t.code,{children:"ModelAttributes"})})," container extends the ",(0,i.jsx)(t.code,{children:"std::unordered_map"})," and adds the ",(0,i.jsx)(t.code,{children:"at"})," method that allows you to cast the underlying QVariant value."]}),"\n",(0,i.jsxs)(t.p,{children:["Special note should be given to the ",(0,i.jsx)(t.code,{children:"u_mutators"})," static data member map, which maps accessors' attribute names to its methods. This data member is ",(0,i.jsx)(t.strong,{children:"required"})," because C++ does not currently support reflection."]}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["If you would like these computed values to be added to the vector, map, or JSON representations of your model, ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#appending-values-to-json",children:"you will need to append them"}),"."]})}),"\n",(0,i.jsx)(t.admonition,{type:"danger",children:(0,i.jsx)(t.p,{children:"You must guarantee that the current model will live long enough to avoid the dangling reference and crash if the current model is captured by-reference. Of course, you can capture it by-copy in edge cases or if you can't guarantee this."})}),"\n",(0,i.jsx)(t.h4,{id:"building-value-from-multiple-attributes",children:"Building Value From Multiple Attributes"}),"\n",(0,i.jsx)(t.p,{children:"Sometimes your accessor may need to transform multiple model attributes into a single value. You can use both methods described above to accomplish this:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Constants::SPACE_IN;\n\nprotected:\n /*! Get the user\'s full name (accessor). */\n Attribute fullName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n return SPACE_IN.arg(getAttribute("first_name"),\n getAttribute("last_name"));\n });\n }\n'})}),"\n",(0,i.jsxs)(t.p,{children:["Or you can use the ",(0,i.jsx)(t.code,{children:"ModelAttributes"})," overload:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! Get the user\'s full name (accessor). */\nAttribute fullName() const noexcept\n{\n return Attribute::make(\n /* get */ [](const ModelAttributes &attributes) -> QVariant\n {\n return SPACE_IN.arg(attributes.at("first_name"),\n attributes.at("last_name"));\n });\n}\n'})}),"\n",(0,i.jsx)(t.h4,{id:"accessor-caching",children:"Accessor Caching"}),"\n",(0,i.jsxs)(t.p,{children:["Sometimes computing an attribute value can be intensive, in this case, you can enable caching for this attribute value. To accomplish this, you have to invoke the ",(0,i.jsx)(t.code,{children:"shouldCache"})," method when defining your accessor:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Constants::SPACE_IN;\n\nprotected:\n /*! Get the user\'s full name (accessor). */\n Attribute fullName() const noexcept\n {\n return Attribute::make(/* get */ [this]() -> QVariant\n {\n return SPACE_IN.arg(getAttribute("first_name"),\n getAttribute("last_name"));\n }).shouldCache();\n }\n'})}),"\n",(0,i.jsx)(t.h2,{id:"attribute-casting",children:"Attribute Casting"}),"\n",(0,i.jsxs)(t.p,{children:["Attribute casting provides functionality that allows converting model attributes to the appropriate ",(0,i.jsx)(t.code,{children:"QVariant"})," ",(0,i.jsx)(t.strong,{children:"metatype"})," when it is accessed via your TinyORM model. The core of this functionality is a model's ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member that provides a convenient method of converting attributes' ",(0,i.jsx)(t.code,{children:"QVariant"})," ",(0,i.jsx)(t.strong,{children:"internal types"})," to the defined cast types."]}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member should be the ",(0,i.jsx)(t.code,{children:"std::unordered_map"})," where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are:"]}),"\n",(0,i.jsx)("div",{id:"casts-types-list",children:(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QString"})}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::Boolean"})," / ",(0,i.jsx)(t.code,{children:"CastType::Bool"})]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::Integer"})," / ",(0,i.jsx)(t.code,{children:"CastType::Int"})]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"CastType::UInteger"})," / ",(0,i.jsx)(t.code,{children:"CastType::UInt"})]}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::LongLong"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::ULongLong"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Short"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::UShort"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QDate"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QDateTime"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Timestamp"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Real"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Float"})}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::Double"})}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)("code",{children:"CastType::Decimal:"}),"\n"]}),"\n",(0,i.jsx)(t.li,{children:(0,i.jsx)(t.code,{children:"CastType::QByteArray"})}),"\n"]})}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["The primary key name defined by the ",(0,i.jsx)(t.code,{children:"u_primaryKey"})," model's data member is automatically cast to the ",(0,i.jsx)(t.code,{children:"CastType::ULongLong"})," for all database drivers if the ",(0,i.jsx)(t.code,{children:"u_incrementing"})," is set to true (its default value)."]})}),"\n",(0,i.jsxs)(t.p,{children:["To demonstrate attribute casting, let's cast the ",(0,i.jsx)(t.code,{children:"is_admin"})," attribute, which is stored in our database as an integer (",(0,i.jsx)(t.code,{children:"0"})," or ",(0,i.jsx)(t.code,{children:"1"}),") to a ",(0,i.jsx)(t.code,{children:"QVariant(bool)"})," value:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\n /*! The attributes that should be cast. */\n inline static std::unordered_map u_casts {\n {"is_admin", CastType::Boolean},\n };\n};\n'})}),"\n",(0,i.jsxs)(t.p,{children:["After defining the cast, the ",(0,i.jsx)(t.code,{children:"is_admin"})," attribute will always be cast to a ",(0,i.jsx)(t.code,{children:"QVariant(bool)"})," when you access it, even if the underlying value is stored in the database as an integer:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Orm::Utils::Helpers;\n\nauto isAdmin = User::find(1)->getAttribute("is_admin");\n\n// Proof of the QVariant type\nQ_ASSERT(Helpers::qVariantTypeId(isAdmin) == QMetaType::Bool);\n\nif (isAdmin.value()) {\n //\n}\n'})}),"\n",(0,i.jsxs)(t.p,{children:["If you need to add a new, ",(0,i.jsx)(t.strong,{children:"temporary"})," cast at runtime, you may use the ",(0,i.jsx)(t.code,{children:"mergeCasts"})," method. These cast definitions will be added to any of the casts already defined on the model:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'user->mergeCasts({\n {"is_paid", CastType::Boolean},\n {"income", {CastType::Decimal, 2}},\n});\n'})}),"\n",(0,i.jsx)(t.admonition,{type:"warning",children:(0,i.jsx)(t.p,{children:"You should never define a cast (or an attribute) that has the same name as a relationship."})}),"\n",(0,i.jsx)(t.admonition,{type:"info",children:(0,i.jsxs)(t.p,{children:["Attributes that are ",(0,i.jsx)(t.code,{children:"null"})," ",(0,i.jsx)(t.strong,{children:"will also be"})," cast so that the ",(0,i.jsx)(t.code,{children:"QVariant"}),"'s internal type will have the correct type."]})}),"\n",(0,i.jsx)(t.h3,{id:"date-casting",children:"Date Casting"}),"\n",(0,i.jsxs)(t.p,{children:["By default, TinyORM will cast the ",(0,i.jsx)(t.code,{children:"created_at"})," and ",(0,i.jsx)(t.code,{children:"updated_at"})," columns to instances of ",(0,i.jsx)(t.code,{children:"QDateTime"}),". You may cast additional date attributes by defining additional date casts within your model's ",(0,i.jsx)(t.code,{children:"u_casts"})," static data member unordered map. Typically, dates should be cast using the ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"}),", ",(0,i.jsx)(t.code,{children:"CastType::QDate"}),", or ",(0,i.jsx)(t.code,{children:"CastType::Timestamp"})," cast types."]}),"\n",(0,i.jsxs)(t.p,{children:["When a database column is of the date type, you may set the corresponding model attribute value to a Unix timestamp, date string (",(0,i.jsx)(t.code,{children:"Y-m-d"}),"), date-time string, ",(0,i.jsx)(t.code,{children:"QDate"}),", or ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance. The date's value will be correctly converted and stored in your database.",(0,i.jsx)("br",{}),"\nThe same is true for the datetime or timestamp database column types, you can set the corresponding model attribute value to a Unix timestamp, date-time string, or a ",(0,i.jsx)(t.code,{children:"QDateTime"})," instance."]}),"\n",(0,i.jsxs)(t.p,{children:["When defining the ",(0,i.jsx)(t.code,{children:"CastType::QDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast, you may also specify the date's format. In this case you must use the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types. This format will be used when the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization",children:"model is serialized to a vector, map, or JSON"}),":"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! The attributes that should be cast. */\ninline static std::unordered_map u_casts {\n {"created_at", {CastType::CustomQDateTime, "yyyy-MM-dd"}},\n};\n'})}),"\n",(0,i.jsx)(t.admonition,{type:"note",children:(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types behave exactly like the ",(0,i.jsx)(t.code,{children:"CastType::QDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast types with the additional ",(0,i.jsx)(t.strong,{children:"date's format"})," functionality during ",(0,i.jsx)("u",{children:(0,i.jsx)(t.strong,{children:"serialization"})}),"."]})}),"\n",(0,i.jsxs)(t.p,{children:["You may customize the ",(0,i.jsx)(t.a,{href:"/tinyorm/serialization#customizing-the-default-date-format",children:"default serialization format"})," for all of your model's dates or datetimes by defining a ",(0,i.jsx)(t.code,{children:"serializeDate"})," or ",(0,i.jsx)(t.code,{children:"serializeDateTime"})," methods on your model. These methods do not affect how your dates are formatted for storage in the database:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! Prepare a date for vector, map, or JSON serialization. */\nQString serializeDate(const QDate date)\n{\n return date.toString("yyyy-MM-dd");\n}\n\n/*! Prepare a datetime for vector, map, or JSON serialization. */\nQString serializeDateTime(const QDateTime &datetime)\n{\n return datetime.toUTC().toString("yyyy-MM-ddTHH:mm:ssZ");\n}\n'})}),"\n",(0,i.jsxs)(t.p,{children:["To specify the format that should be used when actually storing a model's dates within your database, you should define a ",(0,i.jsx)(t.code,{children:"u_dateFormat"})," data member on your model:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:"/*! The storage format of the model's date columns. */\ninline static QString u_dateFormat {QLatin1Char('U')};\n"})}),"\n",(0,i.jsxs)(t.p,{children:["This format can be any format that the QDateTime's ",(0,i.jsx)(t.code,{children:"fromString"})," or ",(0,i.jsx)(t.code,{children:"toString"})," methods accept or the special ",(0,i.jsx)(t.code,{children:"U"})," format that represents the Unix timestamp (this ",(0,i.jsx)(t.code,{children:"U"})," format is TinyORM-specific and isn't supported by ",(0,i.jsx)(t.code,{children:"QDateTime"}),")."]}),"\n",(0,i.jsxs)(t.p,{children:["Define a ",(0,i.jsx)(t.code,{children:"u_timeFormat"})," data member on your model to specify the format that should be used when storing a model's times within your database:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'/*! The storage format of the model\'s time columns. */\ninline static QString u_timeFormat {"HH:mm:ss.zzz"};\n'})}),"\n",(0,i.jsx)(t.h4,{id:"date-casting-serialization-and-timezones",children:"Date Casting, Serialization & Timezones"}),"\n",(0,i.jsxs)(t.p,{children:["By default, the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," and ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," casts will serialize dates to a UTC ISO-8601 date string (",(0,i.jsx)(t.code,{children:"yyyy-MM-ddTHH:mm:ss.zzzZ"}),"), regardless of the timezone specified in your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option. You are strongly encouraged to always use this serialization format, as well as to store your application's dates in the UTC timezone by not changing your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option from its default ",(0,i.jsx)(t.code,{children:"QTimeZone::UTC"})," value. Consistently using the UTC timezone throughout your application will provide the maximum level of interoperability with other date manipulation libraries or services written in any programming language."]}),"\n",(0,i.jsxs)(t.p,{children:["If a custom format is applied to the ",(0,i.jsx)(t.code,{children:"CastType::CustomQDate"})," or ",(0,i.jsx)(t.code,{children:"CastType::CustomQDateTime"})," cast types, such as ",(0,i.jsx)(t.code,{children:'{CastType::CustomQDateTime, "yyyy-MM-dd HH:mm:ss"}'}),", the inner timezone of the QDateTime instance will be used during date serialization. Typically, this will be the timezone specified in your database connection's ",(0,i.jsx)(t.code,{children:"qt_timezone"})," configuration option."]}),"\n",(0,i.jsxs)(t.admonition,{type:"info",children:[(0,i.jsxs)(t.p,{children:["Passing the ",(0,i.jsx)(t.code,{children:"Qt::TimeSpec"})," (eg. ",(0,i.jsx)(t.code,{children:"Qt::UTC"})," or ",(0,i.jsx)(t.code,{children:"Qt::LocalTime"}),") to ",(0,i.jsx)(t.code,{children:"QDateTime"})," methods was deprecated in ",(0,i.jsx)(t.a,{href:"https://github.com/qt/qtbase/commit/8c8d6ff7b6e2e6b1b673051685f1499ae4d65e05?diff=unified&w=0",children:(0,i.jsx)(t.code,{children:"Qt >=6.5"})}),", it was replaced by the ",(0,i.jsx)(t.code,{children:"enum QTimeZone::Initialization"})," (",(0,i.jsx)(t.code,{children:"QTimeZone::UTC"})," and ",(0,i.jsx)(t.code,{children:"QTimeZone::LocalTime"}),")."]}),(0,i.jsxs)(t.p,{children:["If you need to support older and newer versions of Qt at the same time, you can use the ",(0,i.jsx)(t.code,{children:"Orm::QtTimeZoneConfig::utc()"})," or ",(0,i.jsx)(t.code,{children:"QtTimeZoneConfig::localTime()"})," factory methods to create the ",(0,i.jsx)(t.code,{children:"QtTimeZoneConfig"})," instance."]})]}),"\n",(0,i.jsx)(t.h3,{id:"query-time-casting",children:"Query Time Casting"}),"\n",(0,i.jsx)(t.p,{children:"Sometimes you may need to apply casts while executing a query, such as when selecting a raw value from a table. For example, consider the following query:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'using Models::Post;\nusing Models::User;\n\nauto users = User::select("users.*")\n ->addSelect(\n Post::selectRaw("MAX(created_at)")\n ->whereColumnEq("user_id", "users.id")\n .toBase(),\n "last_posted_at"\n ).get();\n'})}),"\n",(0,i.jsxs)(t.p,{children:["The ",(0,i.jsx)(t.code,{children:"last_posted_at"})," attribute on the results of this query will be a simple string. It would be wonderful if we could apply a ",(0,i.jsx)(t.code,{children:"CastType::QDateTime"})," cast to this attribute when executing the query. Thankfully, we may accomplish this using the ",(0,i.jsx)(t.code,{children:"withCasts"})," or ",(0,i.jsx)(t.code,{children:"withCast"})," methods:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-cpp",children:'auto users = User::select("users.*")\n ->addSelect(Post::selectRaw("MAX(created_at)")\n ->whereColumnEq("user_id", "users.id")\n .toBase(),\n "last_posted_at")\n .withCast({"last_posted_at", CastType::QDateTime})\n .get();\n'})})]})}function u(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>o});var i=n(6540);const s={},a=i.createContext(s);function r(e){const t=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/7333c691.1ebcbeee.js b/assets/js/7333c691.1ebcbeee.js deleted file mode 100644 index 577860637..000000000 --- a/assets/js/7333c691.1ebcbeee.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[638],{6577:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>d,contentTitle:()=>r,default:()=>m,frontMatter:()=>a,metadata:()=>l,toc:()=>h});var s=o(4848),t=o(8453),i=o(8774);const a={sidebar_position:1,sidebar_label:"Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",keywords:["c++ orm","relationships","relations","tinyorm"]},r="TinyORM: Relationships",l={id:"tinyorm/relationships",title:"TinyORM: Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",source:"@site/docs/tinyorm/relationships.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/relationships",permalink:"/tinyorm/relationships",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",keywords:["c++ orm","relationships","relations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/tinyorm/getting-started"},next:{title:"Collections",permalink:"/tinyorm/collections"}},d={},h=[{value:"Introduction",id:"introduction",level:2},{value:"Defining Relationships",id:"defining-relationships",level:2},{value:"Common Rules",id:"common-rules",level:3},{value:"One To One",id:"one-to-one",level:3},{value:"Defining The Inverse Of The Relationship",id:"defining-the-inverse-of-the-relationship",level:4},{value:"One To Many",id:"one-to-many",level:3},{value:"One To Many (Inverse) / Belongs To",id:"one-to-many-inverse",level:3},{value:"Default Models",id:"default-models",level:4},{value:"Many To Many Relationships",id:"many-to-many",level:2},{value:"Table Structure",id:"table-structure",level:4},{value:"Model Structure",id:"model-structure",level:4},{value:"Defining The Inverse Of The Relationship",id:"defining-the-inverse-of-the-relationship-1",level:4},{value:"Retrieving Intermediate Table Columns",id:"retrieving-intermediate-table-columns",level:3},{value:"Customizing The pivot Relation Name",id:"customizing-the-pivot-relation-name",level:4},{value:"Defining Custom Intermediate Table Models",id:"defining-custom-intermediate-table-models",level:3},{value:"Custom Pivot Models And Incrementing IDs",id:"custom-pivot-models-and-incrementing-ids",level:4},{value:"Closer Look At Defining Custom Intermediate Table Models",id:"closer-look-at-defining-custom-intermediate-table-models",level:4},{value:"User Data Members on Custom Intermediate Table Models",id:"user-data-members-on-custom-intermediate-table-models",level:5},{value:"Querying Relations",id:"querying-relations",level:2},{value:"Chaining orWhere Clauses After Relationships",id:"chaining-orwhere-clauses-after-relationships",level:4},{value:"Relationship Methods",id:"relationship-methods",level:3},{value:"Querying Relationship Existence",id:"querying-relationship-existence",level:3},{value:"Related template parameter",id:"related-template-parameter",level:4},{value:"Querying Relationship Absence",id:"querying-relationship-absence",level:3},{value:"Eager Loading",id:"eager-loading",level:2},{value:"Eager Loading Multiple Relationships",id:"eager-loading-multiple-relationships",level:4},{value:"Nested Eager Loading",id:"nested-eager-loading",level:4},{value:"Eager Loading Specific Columns",id:"eager-loading-specific-columns",level:4},{value:"Eager Loading By Default",id:"eager-loading-by-default",level:4},{value:"Constraining Eager Loads",id:"constraining-eager-loads",level:3},{value:"Lazy Eager Loading",id:"lazy-eager-loading",level:3},{value:"Inserting & Updating Related Models",id:"inserting-and-updating-related-models",level:2},{value:"The save Method",id:"the-save-method",level:3},{value:"Recursively Saving Models & Relationships",id:"recursively-saving-models--relationships",level:4},{value:"The create Method",id:"the-create-method",level:3},{value:"Belongs To Relationships",id:"updating-belongs-to-relationships",level:3},{value:"Many To Many Relationships",id:"updating-many-to-many-relationships",level:3},{value:"Attaching / Detaching",id:"attaching--detaching",level:4},{value:"Syncing Associations",id:"syncing-associations",level:4},{value:"Updating A Record On The Intermediate Table",id:"updating-a-record-on-the-intermediate-table",level:4},{value:"Touching Parent Timestamps",id:"touching-parent-timestamps",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"tinyorm-relationships",children:"TinyORM: Relationships"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#defining-relationships",children:"Defining Relationships"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#common-rules",children:"Common Rules"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-one",children:"One To One"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many",children:"One To Many"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many-inverse",children:"One To Many (Inverse) / Belongs To"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#many-to-many",children:"Many To Many Relationships"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#retrieving-intermediate-table-columns",children:"Retrieving Intermediate Table Columns"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#defining-custom-intermediate-table-models",children:"Defining Custom Intermediate Table Models"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#querying-relations",children:"Querying Relations"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#relationship-methods",children:"Relationship Methods"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#querying-relationship-existence",children:"Querying Relationship Existence"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#querying-relationship-absence",children:"Querying Relationship Absence"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#eager-loading",children:"Eager Loading"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#constraining-eager-loads",children:"Constraining Eager Loads"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#lazy-eager-loading",children:"Lazy Eager Loading"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#inserting-and-updating-related-models",children:"Inserting & Updating Related Models"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsxs)(n.a,{href:"#the-save-method",children:["The ",(0,s.jsx)(n.code,{children:"save"})," Method"]})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsxs)(n.a,{href:"#the-create-method",children:["The ",(0,s.jsx)(n.code,{children:"create"})," Method"]})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#updating-belongs-to-relationships",children:"Belongs To Relationships"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#updating-many-to-many-relationships",children:"Many To Many Relationships"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#touching-parent-timestamps",children:"Touching Parent Timestamps"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(i.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 1"})})," - Preview",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["High memory consumption during compilation using the ",(0,s.jsx)(n.code,{children:"GCC"})," compiler if the number of TinyORM model instantiations with deep ",(0,s.jsx)(n.strong,{children:"Relationships"})," is counting in hundreds or thousands (eg. like TinyORM functional tests). Generated executables are fine and are small. This is not a problem if only a few hundred instantiations are being done. Other compilers like ",(0,s.jsx)(n.code,{children:"MSVC"})," or ",(0,s.jsx)(n.code,{children:"Clang"})," are fine."]})]})}),"\n",(0,s.jsx)(n.p,{children:"Database tables are often related to one another. For example, a blog post may have many comments or an order could be related to the user who placed it. TinyORM makes managing and working with these relationships easy, and supports basic relationships:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-one",children:"One To One"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many",children:"One To Many"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#many-to-many",children:"Many To Many"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"defining-relationships",children:"Defining Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", defining relationships as methods provides powerful method chaining and querying capabilities. For example, we may chain additional query constraints on this ",(0,s.jsx)(n.code,{children:"posts"})," relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()->whereEq("active", 1).get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"But, before diving too deep into using relationships, let's learn how to define each type of relationship supported by TinyORM."}),"\n",(0,s.jsx)(n.h3,{id:"common-rules",children:"Common Rules"}),"\n",(0,s.jsx)(n.p,{children:'Before you start defining relationship methods, you have to declare a model class, let\'s examine following model class with a "one" type relation:'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/phone.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the phone associated with the user. */\n std::unique_ptr>\n phone()\n {\n return hasOne();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"phone", &User::phone); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["First, you have to extend the ",(0,s.jsx)(n.code,{children:"Model"}),", it is a common class for all models, the first template parameter is the type-id of the defined model itself, this pattern is called a ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern",children:"Curiously recurring template pattern"})," pattern."]}),"\n",(0,s.jsx)(n.p,{children:"However, the second parameter is more interesting, here you have to provide a type-id of all related models. The TinyORM needs these types to store relationships in the hash."}),"\n",(0,s.jsxs)(n.p,{children:["Next, you have to define the ",(0,s.jsx)(n.code,{children:"u_relations"})," hash, which maps relation names to relationship methods. \ud83d\udd25\ud83d\ude80\ud83d\ude4c"]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You may omit the ",(0,s.jsx)(n.code,{children:"friend Model"})," declaration and define all the private data and function members as public."]})}),"\n",(0,s.jsx)(n.h3,{id:"one-to-one",children:"One To One"}),"\n",(0,s.jsxs)(n.p,{children:["A one-to-one relationship is a very basic type of database relationship. For example, a ",(0,s.jsx)(n.code,{children:"User"})," model might be associated with one ",(0,s.jsx)(n.code,{children:"Phone"})," model. To define this relationship, we will place a ",(0,s.jsx)(n.code,{children:"phone"})," method on the ",(0,s.jsx)(n.code,{children:"User"})," model. The ",(0,s.jsx)(n.code,{children:"phone"})," method should call the ",(0,s.jsx)(n.code,{children:"hasOne"})," method and return its result. The ",(0,s.jsx)(n.code,{children:"hasOne"})," method is available to your model via the model's ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"})," base class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/phone.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the phone associated with the user. */\n std::unique_ptr>\n phone()\n {\n return hasOne();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"phone", [](auto &v) { v(&User::phone); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Related"})," template argument provided to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method is the type-id of the related model class. Once the relationship is defined, we may retrieve the related record using Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto phone = User::find(1)->getRelationValue("phone");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key of the relationship based on the parent model name. In this case, the ",(0,s.jsx)(n.code,{children:"Phone"})," model is automatically assumed to have a ",(0,s.jsx)(n.code,{children:"user_id"})," foreign key. If you wish to override this convention, you may pass a first argument to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasOne("foreign_key");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Additionally, TinyORM assumes that the foreign key should have a value matching the primary key column of the parent. In other words, TinyORM will look for the value of the user's ",(0,s.jsx)(n.code,{children:"id"})," column in the ",(0,s.jsx)(n.code,{children:"user_id"})," column of the ",(0,s.jsx)(n.code,{children:"Phone"})," record. If you would like the relationship to use a primary key value other than ",(0,s.jsx)(n.code,{children:"id"})," or your model's ",(0,s.jsx)(n.code,{children:"u_primaryKey"})," data member, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasOne("foreign_key", "local_key");\n'})}),"\n",(0,s.jsx)(n.h4,{id:"defining-the-inverse-of-the-relationship",children:"Defining The Inverse Of The Relationship"}),"\n",(0,s.jsxs)(n.p,{children:["So, we can access the ",(0,s.jsx)(n.code,{children:"Phone"})," model from our ",(0,s.jsx)(n.code,{children:"User"})," model. Next, let's define a relationship on the ",(0,s.jsx)(n.code,{children:"Phone"})," model that will let us access the user that owns the phone. We can define the inverse of a ",(0,s.jsx)(n.code,{children:"hasOne"})," relationship using the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef PHONE_HPP\n#define PHONE_HPP\n\n#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Phone final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the user that owns the phone. */\n std::unique_ptr>\n user()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"user", [](auto &v) { v(&Phone::user); }},\n };\n};\n\n#endif // PHONE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["When invoking the ",(0,s.jsx)(n.code,{children:"user"})," method, TinyORM will attempt to find a ",(0,s.jsx)(n.code,{children:"User"})," model that has an ",(0,s.jsx)(n.code,{children:"id"})," which matches the ",(0,s.jsx)(n.code,{children:"user_id"})," column on the ",(0,s.jsx)(n.code,{children:"Phone"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key name by examining the type-name of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter and suffixing the type-name with ",(0,s.jsx)(n.code,{children:"_id"}),". So, in this case, TinyORM assumes that the ",(0,s.jsx)(n.code,{children:"Phone"})," model has a ",(0,s.jsx)(n.code,{children:"user_id"})," column."]}),"\n",(0,s.jsxs)(n.p,{children:["However, if the foreign key on the ",(0,s.jsx)(n.code,{children:"Phone"})," model is not ",(0,s.jsx)(n.code,{children:"user_id"}),", you may pass a custom key name as the first argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the user that owns the phone. */\nstd::unique_ptr>\nuser()\n{\n return belongsTo("foreign_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If the parent model does not use ",(0,s.jsx)(n.code,{children:"id"})," as its primary key, or you wish to find the associated model using a different column, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method specifying the parent table's custom key:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the user that owns the phone. */\nstd::unique_ptr>\nuser()\n{\n return belongsTo("foreign_key", "owner_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The third ",(0,s.jsx)(n.code,{children:"belongsTo"}),' parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a ',(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column to generate foreign key, the ",(0,s.jsx)(n.code,{children:"__func__"})," predefined identifier is ideal for this. The relation name is also used in BelongsTo's ",(0,s.jsx)(n.code,{children:"associate"})," and ",(0,s.jsx)(n.code,{children:"disassociate"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the user that owns the phone. */\nstd::unique_ptr>\nsomeUser()\n{\n return belongsTo({}, {}, QString::fromUtf8(__func__)); // the foreign key will be some_user_id\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The relation name will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name and changes the first character to lower case, so in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"user"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"one-to-many",children:"One To Many"}),"\n",(0,s.jsxs)(n.p,{children:["A one-to-many relationship is used to define relationships where a single model is the parent to one or more child models. For example, a blog post may have an infinite number of comments. Like all other TinyORM relationships, one-to-many relationships are defined by defining a ",(0,s.jsx)(n.code,{children:"hasMany"})," method on your TinyORM model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef POST_HPP\n#define POST_HPP\n\n#include \n\n#include "models/comment.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Post final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the comments for the blog post. */\n std::unique_ptr>\n comments()\n {\n return hasMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"comments", [](auto &v) { v(&Post::comments); }},\n };\n};\n\n#endif // POST_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Remember, TinyORM will automatically determine the proper foreign key column for the ",(0,s.jsx)(n.code,{children:"Comment"}),' model. By convention, TinyORM will take the "snake_case" name of the parent model and suffix it with ',(0,s.jsx)(n.code,{children:"_id"}),". So, in this example, TinyORM will assume the foreign key column on the ",(0,s.jsx)(n.code,{children:"Comment"})," model is ",(0,s.jsx)(n.code,{children:"post_id"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship method has been defined, we can access the ",(0,s.jsx)(n.code,{children:"QList"})," of related comments by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto comments = Post::find(1)->getRelationValue("comments");\n\nfor (auto *comment : comments) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Since all relationships also serve as ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", you may add further constraints to the relationship query by calling the ",(0,s.jsx)(n.code,{children:"comments"})," method and continuing to chain conditions onto the query, all the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," methods which are related to building queries are proxied:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto comment = Post::find(1)->comments()\n ->whereEq("title", "foo")\n .first();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Like the ",(0,s.jsx)(n.code,{children:"hasOne"})," method, you may also override the foreign and local keys by passing additional arguments to the ",(0,s.jsx)(n.code,{children:"hasMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasMany("foreign_key");\n\nreturn hasMany("foreign_key", "local_key");\n'})}),"\n",(0,s.jsx)(n.h3,{id:"one-to-many-inverse",children:"One To Many (Inverse) / Belongs To"}),"\n",(0,s.jsxs)(n.p,{children:["Now that we can access all of a post's comments, let's define a relationship to allow a comment to access its parent post. To define the inverse of a ",(0,s.jsx)(n.code,{children:"hasMany"})," relationship, define a relationship method on the child model which calls the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef COMMENT_HPP\n#define COMMENT_HPP\n\n#include \n\n#include "models/post.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Comment final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the post that owns the comment. */\n std::unique_ptr>\n post()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"post", [](auto &v) { v(&Comment::post); }},\n };\n};\n\n#endif // COMMENT_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship has been defined, we can retrieve a comment's parent post by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/comment.hpp"\n\nauto comment = Comment::find(1);\n\nreturn comment->getRelationValue("post")->getAttribute("title");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In the example above, TinyORM will attempt to find a ",(0,s.jsx)(n.code,{children:"Post"})," model that has an ",(0,s.jsx)(n.code,{children:"id"})," which matches the ",(0,s.jsx)(n.code,{children:"post_id"})," column on the ",(0,s.jsx)(n.code,{children:"Comment"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key name by examining the type-name of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter and suffixing the type-name with a ",(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column. So, in this case, TinyORM assumes that the ",(0,s.jsx)(n.code,{children:"Post"})," model's foreign key on the ",(0,s.jsx)(n.code,{children:"comments"})," table is ",(0,s.jsx)(n.code,{children:"post_id"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["However, if the foreign key for your relationship does not follow these conventions, you may pass a custom foreign key name as the first argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the post that owns the comment. */\nstd::unique_ptr>\npost()\n{\n return belongsTo("foreign_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If your parent model does not use ",(0,s.jsx)(n.code,{children:"id"})," as its primary key, or you wish to find the associated model using a different column, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method specifying your parent table's custom key:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the post that owns the comment. */\nstd::unique_ptr>\npost()\n{\n return belongsTo("foreign_key", "owner_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The third ",(0,s.jsx)(n.code,{children:"belongsTo"}),' parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a ',(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column to generate foreign key, the ",(0,s.jsx)(n.code,{children:"__func__"})," predefined identifier is ideal for this. The relation name is also used in BelongsTo's ",(0,s.jsx)(n.code,{children:"associate"})," and ",(0,s.jsx)(n.code,{children:"disassociate"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the post that owns the comment. */\nstd::unique_ptr>\nsomePost()\n{\n return belongsTo({}, {}, QString::fromUtf8(__func__)); // the foreign key will be some_post_id\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The relation name will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name and changes the first character to lower case, so in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"user"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"default-models",children:"Default Models"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"belongsTo"}),", and ",(0,s.jsx)(n.code,{children:"hasOne"})," relationships allow you to define a default model that will be returned if the given relationship is ",(0,s.jsx)(n.code,{children:"null"}),". This pattern is often referred to as the ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Null_Object_pattern",children:"Null Object pattern"})," and can help remove conditional checks in your code. In the following example, the ",(0,s.jsx)(n.code,{children:"user"})," relation will return an empty ",(0,s.jsx)(n.code,{children:"User"})," model if no user is attached to the ",(0,s.jsx)(n.code,{children:"Post"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the author of the post. */\nstd::unique_ptr>\nuser()\n{\n // Ownership of a unique_ptr()\n auto relation = belongsTo();\n\n relation->withDefault();\n\n return relation;\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["To populate the default model with attributes, you may pass the vector of attributes to the ",(0,s.jsx)(n.code,{children:"withDefault"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the author of the post. */\nstd::unique_ptr>\nuser()\n{\n // Ownership of a unique_ptr()\n auto relation = belongsTo();\n\n relation->withDefault({{"name", "Guest Author"},\n {"is_active", false}});\n\n return relation;\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"many-to-many",children:"Many To Many Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["Many-to-many relations are slightly more complicated than ",(0,s.jsx)(n.code,{children:"hasOne"})," and ",(0,s.jsx)(n.code,{children:"hasMany"}),' relationships. An example of a many-to-many relationship is a user that has many roles and those roles are also shared by other users in the application. For example, a user may be assigned the role of "Author" and "Editor"; however, those roles may also be assigned to other users as well. So, a user has many roles and a role has many users.']}),"\n",(0,s.jsx)(n.h4,{id:"table-structure",children:"Table Structure"}),"\n",(0,s.jsxs)(n.p,{children:["To define this relationship, three database tables are needed: ",(0,s.jsx)(n.code,{children:"users"}),", ",(0,s.jsx)(n.code,{children:"roles"}),", and ",(0,s.jsx)(n.code,{children:"role_user"}),". The ",(0,s.jsx)(n.code,{children:"role_user"})," table is derived from the alphabetical order of the related model names and contains ",(0,s.jsx)(n.code,{children:"user_id"})," and ",(0,s.jsx)(n.code,{children:"role_id"})," columns. This table is used as an intermediate table linking the users and roles."]}),"\n",(0,s.jsxs)(n.p,{children:["Remember, since a role can belong to many users, we cannot simply place a ",(0,s.jsx)(n.code,{children:"user_id"})," column on the ",(0,s.jsx)(n.code,{children:"roles"})," table. This would mean that a role could only belong to a single user. In order to provide support for roles being assigned to multiple users, the ",(0,s.jsx)(n.code,{children:"role_user"})," table is needed. We can summarize the relationship's table structure like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"users\n id - integer\n name - string\n\nroles\n id - integer\n name - string\n\nrole_user\n user_id - integer\n role_id - integer\n"})}),"\n",(0,s.jsx)(n.h4,{id:"model-structure",children:"Model Structure"}),"\n",(0,s.jsxs)(n.p,{children:["Many-to-many relationships are defined by writing a method that returns the result of the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method. The ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method is provided by the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"})," base class that is used by all of your application's TinyORM models. For example, let's define a ",(0,s.jsx)(n.code,{children:"roles"})," method on our ",(0,s.jsx)(n.code,{children:"User"})," model. The first argument passed to this method is the name of the related model class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/role.hpp"\n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The roles that belong to the user. */\n std::unique_ptr>\n roles()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"roles", [](auto &v) { v(&User::roles); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship is defined, you may access the user's roles as the ",(0,s.jsx)(n.code,{children:"QList"})," by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nauto user = User::find(1);\n\nfor (auto *role : user->getRelationValue("roles"))\n qDebug() << role->getAttribute("id");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Since all relationships also serve as query builders, you may add further constraints to the relationship query by calling the ",(0,s.jsx)(n.code,{children:"roles"})," method and continuing to chain conditions onto the query:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto roles = User::find(1)->roles()->orderBy("name").get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["To determine the table name of the relationship's intermediate table, TinyORM will join the two related model names in alphabetical order. However, you are free to override this convention. You may do so by passing a first argument to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return belongsToMany("role_user");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In addition to customizing the name of the intermediate table, you may also customize the column names of the keys on the table by passing additional arguments to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method. The second argument is the foreign key name of the model on which you are defining the relationship, while the third argument is the foreign key name of the model that you are joining to:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return belongsToMany("role_user", "user_id", "role_id");\n'})}),"\n",(0,s.jsx)(n.p,{children:"The fourth and fifth arguments are primary key names on models in the many-to-many relation and the sixth argument is the relation name."}),"\n",(0,s.jsxs)(n.p,{children:["The relation name is used during ",(0,s.jsx)(n.a,{href:"#touching-parent-timestamps",children:"Touching Parent Timestamps"})," and will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name, changes the first character to lower case, and appends ",(0,s.jsx)(n.code,{children:"s"})," character. So in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"roles"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"defining-the-inverse-of-the-relationship-1",children:"Defining The Inverse Of The Relationship"}),"\n",(0,s.jsxs)(n.p,{children:['To define the "inverse" of a many-to-many relationship, you should define a method on the related model which also returns the result of the ',(0,s.jsx)(n.code,{children:"belongsToMany"})," method. To complete our user / role example, let's define the ",(0,s.jsx)(n.code,{children:"users"})," method on the ",(0,s.jsx)(n.code,{children:"Role"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef ROLE_HPP\n#define ROLE_HPP\n\n#include \n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User; // Forward declaration to avoid cyclic dependency\n\nclass Role final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The users that belong to the role. */\n std::unique_ptr>\n users()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"users", [](auto &v) { v(&Role::users); }},\n };\n};\n\n#endif // ROLE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As you can see, the relationship is defined exactly the same as its ",(0,s.jsx)(n.code,{children:"User"})," model counterpart with the exception of referencing the ",(0,s.jsx)(n.code,{children:"User"})," model. Since we're reusing the ",(0,s.jsx)(n.code,{children:"belongsToMany"}),' method, all of the usual table and key customization options are available when defining the "inverse" of many-to-many relationships.']}),"\n",(0,s.jsx)(n.h3,{id:"retrieving-intermediate-table-columns",children:"Retrieving Intermediate Table Columns"}),"\n",(0,s.jsxs)(n.p,{children:["As you have already learned, working with many-to-many relations requires the presence of an intermediate table. TinyORM provides some very helpful ways of interacting with this table. For example, let's assume our ",(0,s.jsx)(n.code,{children:"User"})," model has many ",(0,s.jsx)(n.code,{children:"Role"})," models that it is related to. After accessing this relationship, we may access the intermediate table using the ",(0,s.jsx)(n.code,{children:"pivot"})," attribute on the models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Relations::Pivot;\n\nauto user = User::find(1);\n\nfor (auto *role : user->getRelationValue("roles"))\n qDebug() << role->getRelation("pivot")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Notice that each ",(0,s.jsx)(n.code,{children:"Role"})," model we retrieve has automatically assigned a ",(0,s.jsx)(n.code,{children:"pivot"})," relationship. This relation contains a model representing the intermediate table and it is an instance of the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::Pivot"})," model class."]}),"\n",(0,s.jsxs)(n.p,{children:["By default, only the model keys will be present on the ",(0,s.jsx)(n.code,{children:"pivot"})," model. If your intermediate table contains extra attributes, you must specify them when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->withPivot({"active", "created_by"});\n\nreturn relation;\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like your intermediate table to have ",(0,s.jsx)(n.code,{children:"created_at"})," and ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamps that are automatically maintained by TinyORM, call the ",(0,s.jsx)(n.code,{children:"withTimestamps"})," method when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->withTimestamps();\n\nreturn relation;\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["Intermediate tables that utilize TinyORM's automatically maintained timestamps are required to have both ",(0,s.jsx)(n.code,{children:"created_at"})," and ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamp columns."]})}),"\n",(0,s.jsxs)(n.h4,{id:"customizing-the-pivot-relation-name",children:["Customizing The ",(0,s.jsx)(n.code,{children:"pivot"})," Relation Name"]}),"\n",(0,s.jsxs)(n.p,{children:["As noted previously, attributes from the intermediate table may be accessed on models via the ",(0,s.jsx)(n.code,{children:"pivot"})," relation name. However, you are free to customize the name of this relation to better reflect its purpose within your application."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, if your application contains users that may subscribe to podcasts, you likely have a many-to-many relationship between users and podcasts. If this is the case, you may wish to rename your intermediate table relation name to ",(0,s.jsx)(n.code,{children:"subscription"})," instead of ",(0,s.jsx)(n.code,{children:"pivot"}),". This can be done using the ",(0,s.jsx)(n.code,{children:"as"})," method when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->as("subscription")\n .withTimestamps();\n\nreturn relation;\n'})}),"\n",(0,s.jsx)(n.p,{children:"Once the custom intermediate table relation name has been specified, you may access the intermediate table data using the customized name:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Relations::Pivot;\n\nauto users = User::with("podcasts")->get();\n\nfor (auto &user : users)\n for (auto *podcast : user.getRelation("podcasts"))\n qDebug() << podcast->getRelation("subscription")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsx)(n.h3,{id:"defining-custom-intermediate-table-models",children:"Defining Custom Intermediate Table Models"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to define a custom model to represent the intermediate table of your many-to-many relationship, you may pass the custom pivot type as a second template argument to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method when defining the relationship. Custom pivot models give you the opportunity to define additional methods on the pivot model."]}),"\n",(0,s.jsxs)(n.p,{children:["Custom many-to-many pivot models should extend the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::BasePivot"})," class. For example, we may define a ",(0,s.jsx)(n.code,{children:"User"})," model which uses a custom ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/role.hpp"\n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The roles that belong to the user. */\n std::unique_ptr>\n roles()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"roles", [](auto &v) { v(&User::roles); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["When defining the ",(0,s.jsx)(n.code,{children:"RoleUser"})," model, you should extend the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::BasePivot"})," class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"#pragma once\n#ifndef ROLEUSER_HPP\n#define ROLEUSER_HPP\n\n#include \n\nusing Orm::Tiny::Relations::BasePivot;\n\nclass RoleUser final : public BasePivot\n{\n friend Model;\n friend BasePivot;\n\n using BasePivot::BasePivot;\n};\n\n#endif // ROLEUSER_HPP\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You have to pass a custom pivot type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on ",(0,s.jsx)(n.code,{children:"Model"})," so that the ",(0,s.jsx)(n.code,{children:"Model"})," knows how to generate a ",(0,s.jsx)(n.code,{children:"std::variant"}),", which holds all the relations and also you have to add a new mapping from the relation name to the custom pivot model type-id, this is described in more detail in the ",(0,s.jsx)(n.a,{href:"#common-rules",children:"Common Rules"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef ROLE_HPP\n#define ROLE_HPP\n\n#include \n\n#include "models/roleuser.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User; // Forward declaration to avoid cyclic dependency\n\nclass Role final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The users that belong to the role. */\n std::unique_ptr>\n users()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"users", [](auto &v) { v(&Role::users); }},\n };\n};\n\n#endif // ROLE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the custom pivot model ",(0,s.jsx)(n.code,{children:"RoleUser"})," has been defined, ",(0,s.jsx)(n.code,{children:"getRelation"})," or ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method returns proper pivot type:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nauto users = User::with("roles")->get();\n\nfor (auto &user : users)\n for (auto *role : user.getRelation("roles"))\n qDebug() << role->getRelation("pivot")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["Custom Pivot models may not use the ",(0,s.jsx)(n.code,{children:"SoftDeletes"})," base class. If you need to soft delete pivot records consider converting your pivot model to an actual TinyORM model."]})}),"\n",(0,s.jsx)(n.h4,{id:"custom-pivot-models-and-incrementing-ids",children:"Custom Pivot Models And Incrementing IDs"}),"\n",(0,s.jsxs)(n.p,{children:["If you have defined a many-to-many relationship that uses a custom pivot model, and that pivot model has an auto-incrementing primary key, you should ensure your custom pivot model class defines an ",(0,s.jsx)(n.code,{children:"u_incrementing"})," data member that is set to ",(0,s.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Indicates if the IDs are auto-incrementing. */\nbool u_incrementing = true;\n"})}),"\n",(0,s.jsx)(n.h4,{id:"closer-look-at-defining-custom-intermediate-table-models",children:"Closer Look At Defining Custom Intermediate Table Models"}),"\n",(0,s.jsx)(n.p,{children:"I can tell that defining a custom intermediate table models is the most confusing part of the TinyORM framework, let's look closer at it."}),"\n",(0,s.jsxs)(n.p,{children:["If you are defining a custom ",(0,s.jsx)(n.code,{children:"RoleUser"})," intermediate table for the ",(0,s.jsx)(n.code,{children:"Role"})," model like in the example above then you have to pass the ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot type as the second template argument to the ",(0,s.jsx)(n.code,{children:"User::roles()"})," ",(0,s.jsx)(n.code,{children:"belongsToMany"})," relationship method and you have to pass the ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack ",(0,s.jsxs)(n.strong,{children:["on the ",(0,s.jsx)(n.code,{children:"Role"})," model!"]})]}),"\n",(0,s.jsxs)(n.p,{children:["Do you see the confusing part? In short, if defining the ",(0,s.jsx)(n.code,{children:"User::roles()"})," relation with the custom ",(0,s.jsx)(n.code,{children:"UserRole"})," pivot model then add the ",(0,s.jsx)(n.code,{children:"UserRole"})," type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on the ",(0,s.jsx)(n.code,{children:"Role"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the basic ",(0,s.jsx)(n.code,{children:"Pivot"})," model, if you are using a basic pivot model and not a custom pivot model you still need to add the ",(0,s.jsx)(n.code,{children:"Pivot"})," type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on the ",(0,s.jsx)(n.code,{children:"Model"})," class!"]}),"\n",(0,s.jsxs)(n.p,{children:["The reason for all of this is that the ",(0,s.jsx)(n.code,{children:"Model"})," knows how to generate and work with the ",(0,s.jsx)(n.code,{children:"std::variant"})," that holds the pivot model in the ",(0,s.jsx)(n.code,{children:"Model::m_relations"})," data member map, then you can get the pivot model using the ",(0,s.jsx)(n.code,{children:"Model::getRelationValue"})," or ",(0,s.jsx)(n.code,{children:"Model::getRelation"})," methods."]}),"\n",(0,s.jsx)(n.h5,{id:"user-data-members-on-custom-intermediate-table-models",children:"User Data Members on Custom Intermediate Table Models"}),"\n",(0,s.jsxs)(n.p,{children:["This is another nonstandard part of the custom pivot models. The ",(0,s.jsx)(n.code,{children:"u_connection"})," and ",(0,s.jsx)(n.code,{children:"u_timestamps"})," user data members and the ",(0,s.jsx)(n.code,{children:"CREATED_AT()"})," and ",(0,s.jsx)(n.code,{children:"UPDATED_AT()"})," static getter methods are ignored when obtaining pivot records from the database during the lazy or eager loading."]}),"\n",(0,s.jsx)(n.p,{children:"Let's describe how these data members are resolved:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"u_connection"})," - inferred from the parent model"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"u_timestamps"})," - true if obtained pivot attributes contain both the ",(0,s.jsx)(n.code,{children:"CREATED_AT"})," and ",(0,s.jsx)(n.code,{children:"UPDATED_AT"})," attributes"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"CREATED_AT"}),", ",(0,s.jsx)(n.code,{children:"UPDATED_AT"})," - inferred from the parent model, can be overridden using the ",(0,s.jsx)(n.code,{children:"withTimestamps()"})," method"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["All these data members are taken into account normally when you call the ",(0,s.jsx)(n.code,{children:"create"}),", ",(0,s.jsx)(n.code,{children:"save"}),", ",(0,s.jsx)(n.code,{children:"update"}),", ... on the Custom Pivot models!"]}),"\n",(0,s.jsx)(n.h2,{id:"querying-relations",children:"Querying Relations"}),"\n",(0,s.jsxs)(n.p,{children:["Since all TinyORM relationships are defined via methods, you may call those methods to obtain an instance of the relationship without actually executing a query to load the related models. In addition, all types of TinyORM relationships also serve as ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", allowing you to continue to chain constraints onto the relationship query before finally executing the SQL query against your database."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, imagine a blog application in which a ",(0,s.jsx)(n.code,{children:"User"})," model has many associated ",(0,s.jsx)(n.code,{children:"Post"})," models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get all of the posts for the user. */\n std::unique_ptr>\n posts()\n {\n return hasMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"posts", [](auto &v) { v(&User::posts); }},\n };\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may query the ",(0,s.jsx)(n.code,{children:"posts"})," relationship and add additional constraints to the relationship like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nuser->posts()->whereEq("active", 1).get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You are able to use any of the TinyORM ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builder's"})," methods on the relationship, so be sure to explore the query builder documentation to learn about all of the methods that are available to you."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["All the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," methods which are related to building queries are proxied on the ",(0,s.jsx)(n.code,{children:"Relation"})," base class."]})}),"\n",(0,s.jsxs)(n.h4,{id:"chaining-orwhere-clauses-after-relationships",children:["Chaining ",(0,s.jsx)(n.code,{children:"orWhere"})," Clauses After Relationships"]}),"\n",(0,s.jsxs)(n.p,{children:["As demonstrated in the example above, you are free to add additional constraints to relationships when querying them. However, be careful when chaining ",(0,s.jsx)(n.code,{children:"orWhere"})," clauses onto a relationship, as the ",(0,s.jsx)(n.code,{children:"orWhere"})," clauses will be logically grouped at the same level as the relationship constraint:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()\n ->whereEq("active", 1)\n .orWhere("votes", ">=", 100)\n .get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The example above will generate the following SQL. As you can see, the ",(0,s.jsx)(n.code,{children:"or"})," clause instructs the query to return ",(0,s.jsx)(n.em,{children:"any"})," user with greater than 100 votes. The query is no longer constrained to a specific user:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select *\nfrom posts\nwhere user_id = ? and active = 1 or votes >= 100\n"})}),"\n",(0,s.jsxs)(n.p,{children:["In most situations, you should use ",(0,s.jsx)(n.a,{href:"/database/query-builder#logical-grouping",children:"logical groups"})," to group the conditional checks between parentheses:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()\n ->where([](auto &query)\n {\n query.whereEq("active", 1)\n .orWhere("votes", ">=", 100);\n })\n .get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"The example above will produce the following SQL. Note that the logical grouping has properly grouped the constraints and the query remains constrained to a specific user:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select *\nfrom posts\nwhere user_id = ? and (active = 1 or votes >= 100)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"relationship-methods",children:"Relationship Methods"}),"\n",(0,s.jsxs)(n.p,{children:["If you do not need to add additional constraints to the TinyORM relationship query, you may access the relationship directly. For example, continuing to use our ",(0,s.jsx)(n.code,{children:"User"})," and ",(0,s.jsx)(n.code,{children:"Post"})," example models, we may access all of a user's posts like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nfor (auto *post : user->getRelationValue("posts")) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' method performs "lazy loading", meaning they will only load their relationship data when you actually access them. Because of this, developers often use ',(0,s.jsx)(n.a,{href:"#eager-loading",children:"eager loading"})," to pre-load relationships they know will be accessed after loading the model. Eager loading provides a significant reduction in SQL queries that must be executed to load a model's relations."]}),"\n",(0,s.jsxs)(n.p,{children:["To access eager loaded relationship use Model's ",(0,s.jsx)(n.code,{children:"getRelation"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nfor (auto *post : user->getRelation("posts")) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As described above TinyORM offers two methods to access relationships; ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelation"}),' method is for "eager loaded" relations, when the relationship is not loaded, it throws the exception ',(0,s.jsx)(n.code,{children:"RelationNotLoadedError"}),". The ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' is for "lazy loading", when the relationship is not loaded, it will load it.']}),"\n",(0,s.jsxs)(n.p,{children:["Both methods have two overloads, the ",(0,s.jsx)(n.code,{children:"getRelation"})," overload is for obtaining many type relationships:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = User::find(1)->getRelation("posts");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelation"}),' overload is for obtaining "one" type relationships:']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = Post::find(1)->getRelation("user");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method."]}),"\n",(0,s.jsx)(n.h3,{id:"querying-relationship-existence",children:"Querying Relationship Existence"}),"\n",(0,s.jsxs)(n.p,{children:["When retrieving model records, you may wish to limit your results based on the existence of a relationship. For example, imagine you want to retrieve all blog posts that have at least one comment. To do so, you may pass the name of the relationship to the ",(0,s.jsx)(n.code,{children:"has"})," and ",(0,s.jsx)(n.code,{children:"orHas"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\n// Retrieve all posts that have at least one comment...\nauto posts = Post::has("comments")->get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"You may also specify an operator and count value to further customize the query:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve all posts that have three or more comments...\nauto posts = Post::has("comments", ">=", 3)->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Nested ",(0,s.jsx)(n.code,{children:"has"}),' statements may be constructed using "dot" notation. For example, you may retrieve all posts that have at least one comment that has at least one image:']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve posts that have at least one comment with images...\nauto posts = Post::has("comments.images")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you need even more power, you may use the ",(0,s.jsx)(n.code,{children:"whereHas"})," and ",(0,s.jsx)(n.code,{children:"orWhereHas"})," methods to define additional query constraints on your ",(0,s.jsx)(n.code,{children:"has"})," queries, such as inspecting the content of a comment:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve posts with at least one comment containing words like code%...\nauto posts = Post::whereHas("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n})->get();\n\n// Retrieve posts with at least ten comments containing words like code%...\nauto posts = Post::whereHas("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n}, ">=", 10)->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsx)(n.p,{children:"TinyORM does not currently support querying for relationship existence across databases. The relationships must exist within the same database."})}),"\n",(0,s.jsx)(n.h4,{id:"related-template-parameter",children:"Related template parameter"}),"\n",(0,s.jsxs)(n.p,{children:["All the ",(0,s.jsx)(n.code,{children:"has"}),"-related methods are templated by the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, it looks something like the following ",(0,s.jsx)(n.code,{children:"has(..., const std::function &)> &callback = nullptr)"}),", you can pass a query callback to this methods and on the base of the ",(0,s.jsx)(n.code,{children:"Related"})," template argument will be decided whether the ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," or ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder"})," will be passed to the callback. As you can see this ",(0,s.jsx)(n.code,{children:"Related"})," parameter exists because the ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder"})," needs it."]}),"\n",(0,s.jsx)(n.p,{children:"The rule of thumbs are:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["if you don't pass the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter or you pass ",(0,s.jsx)(n.code,{children:"void"})," then the ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder &"})," will be passed to the callback"]}),"\n",(0,s.jsxs)(n.li,{children:["if you pass it, then the ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder &"})," will be passed to the callback"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Related"})," has to be of the same type as a relation name passed to the ",(0,s.jsx)(n.code,{children:"has"}),"-related method (a real type of the relation eg. type of the ",(0,s.jsx)(n.code,{children:"posts"})," relation name is ",(0,s.jsx)(n.code,{children:"Post"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:["you have to always pass the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter for nested relations, you can not use nested relations with ",(0,s.jsx)(n.code,{children:"Related = void"})]}),"\n",(0,s.jsxs)(n.li,{children:['in nested relations, where you can pass more relation names using "dot" notation, ',(0,s.jsx)(n.code,{children:"Related"})," has to be of the same type as the ",(0,s.jsx)(n.strong,{children:"last"})," relation name passed to the ",(0,s.jsx)(n.code,{children:"has"}),"-related method like you can see in the nested example above or below"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"querying-relationship-absence",children:"Querying Relationship Absence"}),"\n",(0,s.jsxs)(n.p,{children:["When retrieving model records, you may wish to limit your results based on the absence of a relationship. For example, imagine you want to retrieve all blog posts that ",(0,s.jsx)(n.strong,{children:"don't"})," have any comments. To do so, you may pass the name of the relationship to the ",(0,s.jsx)(n.code,{children:"doesntHave"})," and ",(0,s.jsx)(n.code,{children:"orDoesntHave"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto posts = Post::doesntHave("comments")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you need even more power, you may use the ",(0,s.jsx)(n.code,{children:"whereDoesntHave"})," and ",(0,s.jsx)(n.code,{children:"orWhereDoesntHave"})," methods to add additional query constraints to your ",(0,s.jsx)(n.code,{children:"doesntHave"})," queries, such as inspecting the content of a comment:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = Post::whereDoesntHave("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n})->get();\n'})}),"\n",(0,s.jsx)(n.p,{children:'You may use "dot" notation to execute a query against a nested relationship. For example, the following query will retrieve all posts that have comments from authors that are not banned:'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = Post::whereDoesntHave("comments.author",\n [](auto &query)\n{\n query.where("banned", false);\n})->get();\n'})}),"\n",(0,s.jsx)(n.h2,{id:"eager-loading",children:"Eager Loading"}),"\n",(0,s.jsxs)(n.p,{children:["When accessing TinyORM relationships by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' method, the related models are "lazy loaded". This means the relationship data is not actually loaded until you first access them. However, TinyORM can "eager load" relationships at the time you query the parent model. Eager loading alleviates the "N + 1" query problem. To illustrate the N + 1 query problem, consider a ',(0,s.jsx)(n.code,{children:"Book"}),' model that "belongs to" to an ',(0,s.jsx)(n.code,{children:"Author"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Book final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the author that wrote the book. */\n std::unique_ptr>\n author()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"author", [](auto &v) { v(&Book::author); }},\n };\n};\n'})}),"\n",(0,s.jsx)(n.p,{children:"Now, let's retrieve all books and their authors:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/book.hpp"\n\nauto books = Book::all();\n\nfor (auto &book : books)\n qDebug() << book.getRelationValue("author")\n ->getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"This loop will execute one query to retrieve all of the books within the database table, then another query for each book in order to retrieve the book's author. So, if we have 25 books, the code above would run 26 queries: one for the original book, and 25 additional queries to retrieve the author of each book."}),"\n",(0,s.jsxs)(n.p,{children:["Thankfully, we can use eager loading to reduce this operation to just two queries. When building a query, you may specify which relationships should be eager loaded using the ",(0,s.jsx)(n.code,{children:"with"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author")->get();\n\nfor (auto &book : books)\n qDebug() << book.getRelation("author")\n ->getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"For this operation, only two queries will be executed - one query to retrieve all of the books and one query to retrieve all of the authors for all of the books:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select * from books\n\nselect * from authors where id in (1, 2, 3, 4, 5, ...)\n"})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-multiple-relationships",children:"Eager Loading Multiple Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you may need to eager load several different relationships. To do so, just pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"with"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with({"author", "publisher"})->get();\n'})}),"\n",(0,s.jsx)(n.h4,{id:"nested-eager-loading",children:"Nested Eager Loading"}),"\n",(0,s.jsx)(n.p,{children:"To eager a relationship's relationships, you may use \"dot\" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author.contacts")->get();\n'})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-specific-columns",children:"Eager Loading Specific Columns"}),"\n",(0,s.jsx)(n.p,{children:"You may not always need every column from the relationships you are retrieving. For this reason, TinyORM allows you to specify which columns of the relationship you would like to retrieve:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author:id,name,book_id")->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["When using this feature, you should always include the ",(0,s.jsx)(n.code,{children:"id"})," column and any relevant foreign key columns in the list of columns you wish to retrieve, otherwise relations will not be loaded correctly."]})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-by-default",children:"Eager Loading By Default"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you might want to always load some relationships when retrieving a model. To accomplish this, you may define a ",(0,s.jsx)(n.code,{children:"u_with"})," data member on the model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Book final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the author that wrote the book. */\n std::unique_ptr>\n author()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"author", [](auto &v) { v(&Book::author); }},\n };\n\n /*! The relationships that should always be loaded. */\n QList u_with {\n "author",\n };\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to remove an item from the ",(0,s.jsx)(n.code,{children:"u_with"})," data member for a single query, you may use the ",(0,s.jsx)(n.code,{children:"without"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::without("author")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to override all items within the ",(0,s.jsx)(n.code,{children:"u_with"})," data member for a single query, you may use the ",(0,s.jsx)(n.code,{children:"withOnly"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::withOnly("genre")->get();\n'})}),"\n",(0,s.jsx)(n.h3,{id:"constraining-eager-loads",children:"Constraining Eager Loads"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you may wish to eager load a relationship but also specify additional query conditions for the eager loading query. You can accomplish this by passing a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"with"})," method where the ",(0,s.jsx)(n.code,{children:"name"})," data member of ",(0,s.jsx)(n.code,{children:"Orm::WithItem"})," struct is a relationship name and the ",(0,s.jsx)(n.code,{children:"constraints"})," data member expects a lambda expression that adds additional constraints to the eager loading query. The first argument passed to the ",(0,s.jsx)(n.code,{children:"constraints"})," lambda expression is an underlying ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," for a related model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto users = User::with({{"posts", [](auto &query)\n{\n query.where("title", "like", "%code%");\n}}})->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In this example, TinyORM will only eager load posts where the post's ",(0,s.jsx)(n.code,{children:"title"})," column contains the word ",(0,s.jsx)(n.code,{children:"code"}),". You may call other ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," methods to further customize the eager loading operation:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto users = User::with({{"posts", [](auto &query)\n{\n query.orderBy("created_at", "desc");\n}}})->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"limit"})," and ",(0,s.jsx)(n.code,{children:"take"})," query builder methods may not be used when constraining eager loads."]})}),"\n",(0,s.jsx)(n.h3,{id:"lazy-eager-loading",children:"Lazy Eager Loading"}),"\n",(0,s.jsx)(n.p,{children:"Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/book.hpp"\n\nauto book = Book::find(1);\n\nif (someCondition)\n book->load("author");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may load more relationships at once, to do so, just pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"load"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'Book::find(1)->load({"author", "publisher"});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["So far, this only works on models, not on containers returned from Model's ",(0,s.jsx)(n.code,{children:"get"})," or ",(0,s.jsx)(n.code,{children:"all"})," methods."]})}),"\n",(0,s.jsxs)(n.p,{children:["If you need to set additional query constraints on the eager loading query, you may pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"load"})," method where the ",(0,s.jsx)(n.code,{children:"name"})," data member of ",(0,s.jsx)(n.code,{children:"Orm::WithItem"})," struct is a relationship name and the ",(0,s.jsx)(n.code,{children:"constraints"})," data member expects a lambda expression that adds additional constraints to the eager loading query. The first argument passed to the ",(0,s.jsx)(n.code,{children:"constraints"})," lambda expression is an underlying ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," for a related model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'author->load({{"books", [](auto &query)\n{\n query.orderBy("published_date", "asc");\n}}});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can also use eager constraining in the Model's ",(0,s.jsx)(n.code,{children:"fresh"})," method."]})}),"\n",(0,s.jsx)(n.h2,{id:"inserting-and-updating-related-models",children:"Inserting & Updating Related Models"}),"\n",(0,s.jsxs)(n.h3,{id:"the-save-method",children:["The ",(0,s.jsx)(n.code,{children:"save"})," Method"]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM provides convenient methods for adding new models to relationships. For example, perhaps you need to add a new comment to a post. Instead of manually setting the ",(0,s.jsx)(n.code,{children:"post_id"})," attribute on the ",(0,s.jsx)(n.code,{children:"Comment"})," model you may insert the comment using the relationship's ",(0,s.jsx)(n.code,{children:"save"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/comment.hpp"\n#include "models/post.hpp"\n\nComment comment({{"message", "A new comment."}});\n\nauto post = Post::find(1);\n\npost->comments()->save(comment);\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Note that we did not access the ",(0,s.jsx)(n.code,{children:"comments"})," relationship with the ",(0,s.jsx)(n.code,{children:"getRelation"})," or ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method. Instead, we called the ",(0,s.jsx)(n.code,{children:"comments"})," method to obtain an instance of the relationship. The ",(0,s.jsx)(n.code,{children:"save"})," method will automatically add the appropriate ",(0,s.jsx)(n.code,{children:"post_id"})," value to the new ",(0,s.jsx)(n.code,{children:"Comment"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["If you need to save multiple related models, you may use the ",(0,s.jsx)(n.code,{children:"saveMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\npost->comments()->saveMany({\n {{"message", "A new comment."}},\n {{"message", "Another new comment."}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods will not add the new models to any in-memory relationships that are already loaded onto the parent model. If you plan on accessing the relationship after using the ",(0,s.jsx)(n.code,{children:"save"})," or ",(0,s.jsx)(n.code,{children:"saveMany"})," methods, you may wish to use the ",(0,s.jsx)(n.code,{children:"refresh"})," method to reload the model and its relationships:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'post->comments()->save(comment);\n\npost->refresh();\n\n// All comments, including the newly saved comment...\npost->getRelation("comments");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The many-to-many relationship also supports the ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods. In addition, you may pass the pivot attributes as a second argument and select if you want to touch parent timestamps as a third argument:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(2);\n\nRole role {{"name", "admin"}};\n\nuser->roles()->save(role, {{"active", true}});\n\nRole role1 {{"name", "edit"}};\nRole role2 {{"name", "view"}};\n\nuser->roles()->saveMany({role1, role2}, {{{"active", true}},\n {{"active", false}}});\n\n// No pivot attributes for role1\nuser->roles()->saveMany({role1, role2}, {{}, {{"active", false}}});\n'})}),"\n",(0,s.jsx)(n.h4,{id:"recursively-saving-models--relationships",children:"Recursively Saving Models & Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to ",(0,s.jsx)(n.code,{children:"save"})," your model and all of its associated relationships, you may use the ",(0,s.jsx)(n.code,{children:"push"})," method. In this example, the ",(0,s.jsx)(n.code,{children:"Post"})," model will be saved as well as its comments and the comment's authors:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\npost->getRelationValue("comments").at(0)->setAttribute("message", "Message");\n\npost->getRelationValue("comments").first()\n ->getRelationValue("author")->setAttribute("name", "Author Name");\n\npost->push();\n'})}),"\n",(0,s.jsxs)(n.h3,{id:"the-create-method",children:["The ",(0,s.jsx)(n.code,{children:"create"})," Method"]}),"\n",(0,s.jsxs)(n.p,{children:["In addition to the ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods, you may also use the ",(0,s.jsx)(n.code,{children:"create"})," method, which accepts a vector of attributes, creates a model, and inserts it into the database. The difference between ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"create"})," is that ",(0,s.jsx)(n.code,{children:"save"})," accepts a full TinyORM model instance while ",(0,s.jsx)(n.code,{children:"create"})," accepts a ",(0,s.jsx)(n.code,{children:"QList"}),". The newly created model will be returned by the ",(0,s.jsx)(n.code,{children:"create"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto post = Post::find(1);\n\nauto comment = post->comments()->create({\n {"message", "A new comment."},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may use the ",(0,s.jsx)(n.code,{children:"createMany"})," method to create multiple related models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\nauto comments = post->comments()->createMany({\n {{"message", "A new comment."}, {"is_published", true}},\n {{"message", "Another new comment."}, {"is_published", false}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The many-to-many relationship also supports the ",(0,s.jsx)(n.code,{children:"create"})," and ",(0,s.jsx)(n.code,{children:"createMany"})," methods. In addition, you may pass the pivot attributes as a second argument and select if you want to touch parent timestamps as a third argument:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(2);\n\nuser->roles()->create({{"name", "admin"}}, {{"active", true}});\n\nuser->roles()->createMany({\n {{"name", "edit"}},\n {{"name", "view"}},\n}, {\n {{"active", true}},\n {{"active", false}},\n});\n\n// No pivot attributes for the first role\nuser->roles()->createMany({\n {{"name", "edit"}},\n {{"name", "view"}},\n}, {\n {},\n {{"active", false}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may also use the ",(0,s.jsx)(n.code,{children:"findOrNew"}),", ",(0,s.jsx)(n.code,{children:"firstOrNew"}),", ",(0,s.jsx)(n.code,{children:"firstOrCreate"}),", and ",(0,s.jsx)(n.code,{children:"updateOrCreate"})," methods to ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#retrieving-or-creating-models",children:"create and update models on relationships"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["Before using the ",(0,s.jsx)(n.code,{children:"create"})," method, be sure to review the ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#mass-assignment",children:"mass assignment"})," documentation."]})}),"\n",(0,s.jsx)(n.h3,{id:"updating-belongs-to-relationships",children:"Belongs To Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to assign a child model to a new parent model, you may use the ",(0,s.jsx)(n.code,{children:"associate"})," method. In this example, the ",(0,s.jsx)(n.code,{children:"User"})," model defines a ",(0,s.jsx)(n.code,{children:"belongsTo"})," relationship to the ",(0,s.jsx)(n.code,{children:"Account"})," model. The ",(0,s.jsx)(n.code,{children:"associate"})," method will set the foreign key on the child model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nUser user {{"name", "Mike"}};\n\nauto account = Account::find(10);\n\nuser.account()->associate(*account);\n\nuser.save();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["To remove a parent model from a child model, you may use the ",(0,s.jsx)(n.code,{children:"dissociate"})," method. This method will set the relationship's foreign key to ",(0,s.jsx)(n.code,{children:"null"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user.account()->dissociate();\n\nuser.save();\n"})}),"\n",(0,s.jsx)(n.h3,{id:"updating-many-to-many-relationships",children:"Many To Many Relationships"}),"\n",(0,s.jsx)(n.h4,{id:"attaching--detaching",children:"Attaching / Detaching"}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM also provides methods to make working with many-to-many relationships more convenient. For example, let's imagine a user can have many roles and a role can have many users. You may use the ",(0,s.jsx)(n.code,{children:"attach"})," method to attach a role to a user by inserting a record in the relationship's intermediate table:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nuser->roles()->attach(roleId);\n'})}),"\n",(0,s.jsx)(n.p,{children:"When attaching a relationship to a model, you may also pass a vector of additional data to be inserted into the intermediate table:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'const auto expires = true;\n\nuser->roles()->attach(roleId, {{"expires", expires}});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes it may be necessary to remove a role from a user. To remove a many-to-many relationship record, use the ",(0,s.jsx)(n.code,{children:"detach"})," method. The ",(0,s.jsx)(n.code,{children:"detach"})," method will delete the appropriate record out of the intermediate table; however, both models will remain in the database:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"// Detach a single role from the user...\nuser->roles()->detach(roleId);\n\n// Detach all roles from the user...\nuser->roles()->detachAll();\n"})}),"\n",(0,s.jsxs)(n.p,{children:["For convenience, ",(0,s.jsx)(n.code,{children:"attach"})," and ",(0,s.jsx)(n.code,{children:"detach"})," also accept vectors of IDs or Model instances as input:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nuser->roles()->detach({1, 2, 3});\n\nRole role1({{"name", "Role 1"}});\nrole1.save();\nRole role2({{"name", "Role 2"}});\nrole2.save();\n\nuser->roles()->attach({{role1}, {role2}});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"attach"})," method also accepts ",(0,s.jsx)(n.code,{children:"std::map"})," as input, so you can pass different attributes for each model you are attaching:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->roles()->attach({\n {1, {{"expires", true}, {"is_active", false}}},\n {2, {{"expires", false}, {"is_active", true}}},\n});\n'})}),"\n",(0,s.jsx)(n.h4,{id:"syncing-associations",children:"Syncing Associations"}),"\n",(0,s.jsxs)(n.p,{children:["You may also use the ",(0,s.jsx)(n.code,{children:"sync"})," method to construct many-to-many associations. The ",(0,s.jsx)(n.code,{children:"sync"})," method accepts a vector of IDs to place on the intermediate table. Any IDs that are not in the given vector will be removed from the intermediate table. So, after this operation is complete, only the IDs in the given vector will exist in the intermediate table:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user->roles()->sync({1, 2, 3});\n"})}),"\n",(0,s.jsx)(n.p,{children:"You may also pass additional intermediate table values with the IDs:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->roles()->sync({\n {1, {{"expires", true}}},\n {2, {}},\n {3, {}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you do not want to detach existing IDs that are missing from the given vector, you may use the ",(0,s.jsx)(n.code,{children:"syncWithoutDetaching"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user->roles()->syncWithoutDetaching({1, 2, 3});\n"})}),"\n",(0,s.jsx)(n.h4,{id:"updating-a-record-on-the-intermediate-table",children:"Updating A Record On The Intermediate Table"}),"\n",(0,s.jsxs)(n.p,{children:["If you need to update an existing row in your relationship's intermediate table, you may use the ",(0,s.jsx)(n.code,{children:"updateExistingPivot"})," method. This method accepts the intermediate record foreign key and the vector of attributes to update:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nuser->roles()->updateExistingPivot(roleId, {\n {"active", false},\n});\n'})}),"\n",(0,s.jsx)(n.h2,{id:"touching-parent-timestamps",children:"Touching Parent Timestamps"}),"\n",(0,s.jsxs)(n.p,{children:["When a model defines a ",(0,s.jsx)(n.code,{children:"belongsTo"})," relationship to another model, such as a ",(0,s.jsx)(n.code,{children:"Comment"})," which belongs to a ",(0,s.jsx)(n.code,{children:"Post"}),", it is sometimes helpful to update the parent's timestamp when the child model is updated."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, when a ",(0,s.jsx)(n.code,{children:"Comment"}),' model is updated, you may want to automatically "touch" the ',(0,s.jsx)(n.code,{children:"updated_at"})," timestamp of the owning ",(0,s.jsx)(n.code,{children:"Post"})," so that it is set to the current date and time. To accomplish this, you may add a ",(0,s.jsx)(n.code,{children:"u_touches"})," data member to your child model containing the names of the relationships that should have their ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamps updated when the child model is updated:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Comment final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the post that owns the comment. */\n std::unique_ptr>\n post()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"post", [](auto &v) { v(&Comment::post); }},\n };\n\n /*! All of the relationships to be touched. */\n QStringList u_touches {"post"};\n};\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["Parent model timestamps will only be updated if the child model is updated using TinyORM's ",(0,s.jsx)(n.code,{children:"save"}),", ",(0,s.jsx)(n.code,{children:"push"}),", or ",(0,s.jsx)(n.code,{children:"remove"})," method."]})})]})}function m(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},8453:(e,n,o)=>{o.d(n,{R:()=>a,x:()=>r});var s=o(6540);const t={},i=s.createContext(t);function a(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/7333c691.84bb69f7.js b/assets/js/7333c691.84bb69f7.js new file mode 100644 index 000000000..ca21cff83 --- /dev/null +++ b/assets/js/7333c691.84bb69f7.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[638],{6577:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>d,contentTitle:()=>r,default:()=>m,frontMatter:()=>a,metadata:()=>l,toc:()=>h});var s=o(4848),t=o(8453),i=o(8774);const a={sidebar_position:1,sidebar_label:"Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",keywords:["c++ orm","relationships","relations","tinyorm"]},r="TinyORM: Relationships",l={id:"tinyorm/relationships",title:"TinyORM: Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",source:"@site/docs/tinyorm/relationships.mdx",sourceDirName:"tinyorm",slug:"/tinyorm/relationships",permalink:"/tinyorm/relationships",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Relationships",description:"TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful query builders, defining relationships as methods provides powerful method chaining and querying capabilities.",keywords:["c++ orm","relationships","relations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/tinyorm/getting-started"},next:{title:"Collections",permalink:"/tinyorm/collections"}},d={},h=[{value:"Introduction",id:"introduction",level:2},{value:"Defining Relationships",id:"defining-relationships",level:2},{value:"Common Rules",id:"common-rules",level:3},{value:"One To One",id:"one-to-one",level:3},{value:"Defining The Inverse Of The Relationship",id:"defining-the-inverse-of-the-relationship",level:4},{value:"One To Many",id:"one-to-many",level:3},{value:"One To Many (Inverse) / Belongs To",id:"one-to-many-inverse",level:3},{value:"Default Models",id:"default-models",level:4},{value:"Many To Many Relationships",id:"many-to-many",level:2},{value:"Table Structure",id:"table-structure",level:4},{value:"Model Structure",id:"model-structure",level:4},{value:"Defining The Inverse Of The Relationship",id:"defining-the-inverse-of-the-relationship-1",level:4},{value:"Retrieving Intermediate Table Columns",id:"retrieving-intermediate-table-columns",level:3},{value:"Customizing The pivot Relation Name",id:"customizing-the-pivot-relation-name",level:4},{value:"Defining Custom Intermediate Table Models",id:"defining-custom-intermediate-table-models",level:3},{value:"Custom Pivot Models And Incrementing IDs",id:"custom-pivot-models-and-incrementing-ids",level:4},{value:"Closer Look At Defining Custom Intermediate Table Models",id:"closer-look-at-defining-custom-intermediate-table-models",level:4},{value:"User Data Members on Custom Intermediate Table Models",id:"user-data-members-on-custom-intermediate-table-models",level:5},{value:"Querying Relations",id:"querying-relations",level:2},{value:"Chaining orWhere Clauses After Relationships",id:"chaining-orwhere-clauses-after-relationships",level:4},{value:"Relationship Methods",id:"relationship-methods",level:3},{value:"Querying Relationship Existence",id:"querying-relationship-existence",level:3},{value:"Related template parameter",id:"related-template-parameter",level:4},{value:"Querying Relationship Absence",id:"querying-relationship-absence",level:3},{value:"Eager Loading",id:"eager-loading",level:2},{value:"Eager Loading Multiple Relationships",id:"eager-loading-multiple-relationships",level:4},{value:"Nested Eager Loading",id:"nested-eager-loading",level:4},{value:"Eager Loading Specific Columns",id:"eager-loading-specific-columns",level:4},{value:"Eager Loading By Default",id:"eager-loading-by-default",level:4},{value:"Constraining Eager Loads",id:"constraining-eager-loads",level:3},{value:"Lazy Eager Loading",id:"lazy-eager-loading",level:3},{value:"Inserting & Updating Related Models",id:"inserting-and-updating-related-models",level:2},{value:"The save Method",id:"the-save-method",level:3},{value:"Recursively Saving Models & Relationships",id:"recursively-saving-models--relationships",level:4},{value:"The create Method",id:"the-create-method",level:3},{value:"Belongs To Relationships",id:"updating-belongs-to-relationships",level:3},{value:"Many To Many Relationships",id:"updating-many-to-many-relationships",level:3},{value:"Attaching / Detaching",id:"attaching--detaching",level:4},{value:"Syncing Associations",id:"syncing-associations",level:4},{value:"Updating A Record On The Intermediate Table",id:"updating-a-record-on-the-intermediate-table",level:4},{value:"Touching Parent Timestamps",id:"touching-parent-timestamps",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"tinyorm-relationships",children:"TinyORM: Relationships"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#defining-relationships",children:"Defining Relationships"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#common-rules",children:"Common Rules"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-one",children:"One To One"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many",children:"One To Many"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many-inverse",children:"One To Many (Inverse) / Belongs To"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#many-to-many",children:"Many To Many Relationships"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#retrieving-intermediate-table-columns",children:"Retrieving Intermediate Table Columns"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#defining-custom-intermediate-table-models",children:"Defining Custom Intermediate Table Models"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#querying-relations",children:"Querying Relations"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#relationship-methods",children:"Relationship Methods"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#querying-relationship-existence",children:"Querying Relationship Existence"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#querying-relationship-absence",children:"Querying Relationship Absence"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#eager-loading",children:"Eager Loading"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#constraining-eager-loads",children:"Constraining Eager Loads"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#lazy-eager-loading",children:"Lazy Eager Loading"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#inserting-and-updating-related-models",children:"Inserting & Updating Related Models"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsxs)(n.a,{href:"#the-save-method",children:["The ",(0,s.jsx)(n.code,{children:"save"})," Method"]})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsxs)(n.a,{href:"#the-create-method",children:["The ",(0,s.jsx)(n.code,{children:"create"})," Method"]})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#updating-belongs-to-relationships",children:"Belongs To Relationships"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#updating-many-to-many-relationships",children:"Many To Many Relationships"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#touching-parent-timestamps",children:"Touching Parent Timestamps"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(i.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 1"})})," - Preview",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["High memory consumption during compilation using the ",(0,s.jsx)(n.code,{children:"GCC"})," compiler if the number of TinyORM model instantiations with deep ",(0,s.jsx)(n.strong,{children:"Relationships"})," is counting in hundreds or thousands (eg. like TinyORM functional tests). Generated executables are fine and are small. This is not a problem if only a few hundred instantiations are being done. Other compilers like ",(0,s.jsx)(n.code,{children:"MSVC"})," or ",(0,s.jsx)(n.code,{children:"Clang"})," are fine."]})]})}),"\n",(0,s.jsx)(n.p,{children:"Database tables are often related to one another. For example, a blog post may have many comments or an order could be related to the user who placed it. TinyORM makes managing and working with these relationships easy, and supports basic relationships:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-one",children:"One To One"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#one-to-many",children:"One To Many"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#many-to-many",children:"Many To Many"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"defining-relationships",children:"Defining Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM relationships are defined as methods on your TinyORM model classes. Since relationships also serve as powerful ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", defining relationships as methods provides powerful method chaining and querying capabilities. For example, we may chain additional query constraints on this ",(0,s.jsx)(n.code,{children:"posts"})," relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()->whereEq("active", 1).get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"But, before diving too deep into using relationships, let's learn how to define each type of relationship supported by TinyORM."}),"\n",(0,s.jsx)(n.h3,{id:"common-rules",children:"Common Rules"}),"\n",(0,s.jsx)(n.p,{children:'Before you start defining relationship methods, you have to declare a model class, let\'s examine following model class with a "one" type relation:'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/phone.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the phone associated with the user. */\n std::unique_ptr>\n phone()\n {\n return hasOne();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"phone", &User::phone); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["First, you have to extend the ",(0,s.jsx)(n.code,{children:"Model"}),", it is a common class for all models, the first template parameter is the type-id of the defined model itself, this pattern is called a ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern",children:"Curiously recurring template pattern"})," pattern."]}),"\n",(0,s.jsx)(n.p,{children:"However, the second parameter is more interesting, here you have to provide a type-id of all related models. The TinyORM needs these types to store relationships in the hash."}),"\n",(0,s.jsxs)(n.p,{children:["Next, you have to define the ",(0,s.jsx)(n.code,{children:"u_relations"})," hash, which maps relation names to relationship methods. \ud83d\udd25\ud83d\ude80\ud83d\ude4c"]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You may omit the ",(0,s.jsx)(n.code,{children:"friend Model"})," declaration and define all the private data and function members as public."]})}),"\n",(0,s.jsx)(n.h3,{id:"one-to-one",children:"One To One"}),"\n",(0,s.jsxs)(n.p,{children:["A one-to-one relationship is a very basic type of database relationship. For example, a ",(0,s.jsx)(n.code,{children:"User"})," model might be associated with one ",(0,s.jsx)(n.code,{children:"Phone"})," model. To define this relationship, we will place a ",(0,s.jsx)(n.code,{children:"phone"})," method on the ",(0,s.jsx)(n.code,{children:"User"})," model. The ",(0,s.jsx)(n.code,{children:"phone"})," method should call the ",(0,s.jsx)(n.code,{children:"hasOne"})," method and return its result. The ",(0,s.jsx)(n.code,{children:"hasOne"})," method is available to your model via the model's ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"})," base class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/phone.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the phone associated with the user. */\n std::unique_ptr>\n phone()\n {\n return hasOne();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"phone", [](auto &v) { v(&User::phone); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"Related"})," template argument provided to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method is the type-id of the related model class. Once the relationship is defined, we may retrieve the related record using Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto phone = User::find(1)->getRelationValue("phone");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key of the relationship based on the parent model name. In this case, the ",(0,s.jsx)(n.code,{children:"Phone"})," model is automatically assumed to have a ",(0,s.jsx)(n.code,{children:"user_id"})," foreign key. If you wish to override this convention, you may pass a first argument to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasOne("foreign_key");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Additionally, TinyORM assumes that the foreign key should have a value matching the primary key column of the parent. In other words, TinyORM will look for the value of the user's ",(0,s.jsx)(n.code,{children:"id"})," column in the ",(0,s.jsx)(n.code,{children:"user_id"})," column of the ",(0,s.jsx)(n.code,{children:"Phone"})," record. If you would like the relationship to use a primary key value other than ",(0,s.jsx)(n.code,{children:"id"})," or your model's ",(0,s.jsx)(n.code,{children:"u_primaryKey"})," data member, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"hasOne"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasOne("foreign_key", "local_key");\n'})}),"\n",(0,s.jsx)(n.h4,{id:"defining-the-inverse-of-the-relationship",children:"Defining The Inverse Of The Relationship"}),"\n",(0,s.jsxs)(n.p,{children:["So, we can access the ",(0,s.jsx)(n.code,{children:"Phone"})," model from our ",(0,s.jsx)(n.code,{children:"User"})," model. Next, let's define a relationship on the ",(0,s.jsx)(n.code,{children:"Phone"})," model that will let us access the user that owns the phone. We can define the inverse of a ",(0,s.jsx)(n.code,{children:"hasOne"})," relationship using the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef PHONE_HPP\n#define PHONE_HPP\n\n#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Phone final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the user that owns the phone. */\n std::unique_ptr>\n user()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"user", [](auto &v) { v(&Phone::user); }},\n };\n};\n\n#endif // PHONE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["When invoking the ",(0,s.jsx)(n.code,{children:"user"})," method, TinyORM will attempt to find a ",(0,s.jsx)(n.code,{children:"User"})," model that has an ",(0,s.jsx)(n.code,{children:"id"})," which matches the ",(0,s.jsx)(n.code,{children:"user_id"})," column on the ",(0,s.jsx)(n.code,{children:"Phone"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key name by examining the type-name of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter and suffixing the type-name with ",(0,s.jsx)(n.code,{children:"_id"}),". So, in this case, TinyORM assumes that the ",(0,s.jsx)(n.code,{children:"Phone"})," model has a ",(0,s.jsx)(n.code,{children:"user_id"})," column."]}),"\n",(0,s.jsxs)(n.p,{children:["However, if the foreign key on the ",(0,s.jsx)(n.code,{children:"Phone"})," model is not ",(0,s.jsx)(n.code,{children:"user_id"}),", you may pass a custom key name as the first argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the user that owns the phone. */\nstd::unique_ptr>\nuser()\n{\n return belongsTo("foreign_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If the parent model does not use ",(0,s.jsx)(n.code,{children:"id"})," as its primary key, or you wish to find the associated model using a different column, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method specifying the parent table's custom key:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the user that owns the phone. */\nstd::unique_ptr>\nuser()\n{\n return belongsTo("foreign_key", "owner_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The third ",(0,s.jsx)(n.code,{children:"belongsTo"}),' parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a ',(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column to generate foreign key, the ",(0,s.jsx)(n.code,{children:"__func__"})," predefined identifier is ideal for this. The relation name is also used in BelongsTo's ",(0,s.jsx)(n.code,{children:"associate"})," and ",(0,s.jsx)(n.code,{children:"disassociate"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the user that owns the phone. */\nstd::unique_ptr>\nsomeUser()\n{\n return belongsTo({}, {}, QString::fromUtf8(__func__)); // the foreign key will be some_user_id\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The relation name will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name and changes the first character to lower case, so in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"user"}),"."]}),"\n",(0,s.jsx)(n.h3,{id:"one-to-many",children:"One To Many"}),"\n",(0,s.jsxs)(n.p,{children:["A one-to-many relationship is used to define relationships where a single model is the parent to one or more child models. For example, a blog post may have an infinite number of comments. Like all other TinyORM relationships, one-to-many relationships are defined by defining a ",(0,s.jsx)(n.code,{children:"hasMany"})," method on your TinyORM model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef POST_HPP\n#define POST_HPP\n\n#include \n\n#include "models/comment.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Post final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the comments for the blog post. */\n std::unique_ptr>\n comments()\n {\n return hasMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"comments", [](auto &v) { v(&Post::comments); }},\n };\n};\n\n#endif // POST_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Remember, TinyORM will automatically determine the proper foreign key column for the ",(0,s.jsx)(n.code,{children:"Comment"}),' model. By convention, TinyORM will take the "snake_case" name of the parent model and suffix it with ',(0,s.jsx)(n.code,{children:"_id"}),". So, in this example, TinyORM will assume the foreign key column on the ",(0,s.jsx)(n.code,{children:"Comment"})," model is ",(0,s.jsx)(n.code,{children:"post_id"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship method has been defined, we can access the ",(0,s.jsx)(n.code,{children:"QList"})," of related comments by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto comments = Post::find(1)->getRelationValue("comments");\n\nfor (auto *comment : comments) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Since all relationships also serve as ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", you may add further constraints to the relationship query by calling the ",(0,s.jsx)(n.code,{children:"comments"})," method and continuing to chain conditions onto the query, all the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," methods which are related to building queries are proxied:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto comment = Post::find(1)->comments()\n ->whereEq("title", "foo")\n .first();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Like the ",(0,s.jsx)(n.code,{children:"hasOne"})," method, you may also override the foreign and local keys by passing additional arguments to the ",(0,s.jsx)(n.code,{children:"hasMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return hasMany("foreign_key");\n\nreturn hasMany("foreign_key", "local_key");\n'})}),"\n",(0,s.jsx)(n.h3,{id:"one-to-many-inverse",children:"One To Many (Inverse) / Belongs To"}),"\n",(0,s.jsxs)(n.p,{children:["Now that we can access all of a post's comments, let's define a relationship to allow a comment to access its parent post. To define the inverse of a ",(0,s.jsx)(n.code,{children:"hasMany"})," relationship, define a relationship method on the child model which calls the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef COMMENT_HPP\n#define COMMENT_HPP\n\n#include \n\n#include "models/post.hpp"\n\nusing Orm::Tiny::Model;\n\nclass Comment final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the post that owns the comment. */\n std::unique_ptr>\n post()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"post", [](auto &v) { v(&Comment::post); }},\n };\n};\n\n#endif // COMMENT_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship has been defined, we can retrieve a comment's parent post by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/comment.hpp"\n\nauto comment = Comment::find(1);\n\nreturn comment->getRelationValue("post")->getAttribute("title");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In the example above, TinyORM will attempt to find a ",(0,s.jsx)(n.code,{children:"Post"})," model that has an ",(0,s.jsx)(n.code,{children:"id"})," which matches the ",(0,s.jsx)(n.code,{children:"post_id"})," column on the ",(0,s.jsx)(n.code,{children:"Comment"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM determines the foreign key name by examining the type-name of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter and suffixing the type-name with a ",(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column. So, in this case, TinyORM assumes that the ",(0,s.jsx)(n.code,{children:"Post"})," model's foreign key on the ",(0,s.jsx)(n.code,{children:"comments"})," table is ",(0,s.jsx)(n.code,{children:"post_id"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["However, if the foreign key for your relationship does not follow these conventions, you may pass a custom foreign key name as the first argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the post that owns the comment. */\nstd::unique_ptr>\npost()\n{\n return belongsTo("foreign_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If your parent model does not use ",(0,s.jsx)(n.code,{children:"id"})," as its primary key, or you wish to find the associated model using a different column, you may pass a second argument to the ",(0,s.jsx)(n.code,{children:"belongsTo"})," method specifying your parent table's custom key:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the post that owns the comment. */\nstd::unique_ptr>\npost()\n{\n return belongsTo("foreign_key", "owner_key");\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The third ",(0,s.jsx)(n.code,{children:"belongsTo"}),' parameter is the relation name, if you pass it, the foreign key name will be determined from it. By convention, TinyORM will "snake_case" this relation name and suffix it with a ',(0,s.jsx)(n.code,{children:"_"})," followed by the name of the parent model's primary key column to generate foreign key, the ",(0,s.jsx)(n.code,{children:"__func__"})," predefined identifier is ideal for this. The relation name is also used in BelongsTo's ",(0,s.jsx)(n.code,{children:"associate"})," and ",(0,s.jsx)(n.code,{children:"disassociate"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the post that owns the comment. */\nstd::unique_ptr>\nsomePost()\n{\n return belongsTo({}, {}, QString::fromUtf8(__func__)); // the foreign key will be some_post_id\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The relation name will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name and changes the first character to lower case, so in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"user"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"default-models",children:"Default Models"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"belongsTo"}),", and ",(0,s.jsx)(n.code,{children:"hasOne"})," relationships allow you to define a default model that will be returned if the given relationship is ",(0,s.jsx)(n.code,{children:"null"}),". This pattern is often referred to as the ",(0,s.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Null_Object_pattern",children:"Null Object pattern"})," and can help remove conditional checks in your code. In the following example, the ",(0,s.jsx)(n.code,{children:"user"})," relation will return an empty ",(0,s.jsx)(n.code,{children:"User"})," model if no user is attached to the ",(0,s.jsx)(n.code,{children:"Post"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Get the author of the post. */\nstd::unique_ptr>\nuser()\n{\n // Ownership of a unique_ptr()\n auto relation = belongsTo();\n\n relation->withDefault();\n\n return relation;\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["To populate the default model with attributes, you may pass the vector of attributes to the ",(0,s.jsx)(n.code,{children:"withDefault"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'/*! Get the author of the post. */\nstd::unique_ptr>\nuser()\n{\n // Ownership of a unique_ptr()\n auto relation = belongsTo();\n\n relation->withDefault({{"name", "Guest Author"},\n {"is_active", false}});\n\n return relation;\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"many-to-many",children:"Many To Many Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["Many-to-many relations are slightly more complicated than ",(0,s.jsx)(n.code,{children:"hasOne"})," and ",(0,s.jsx)(n.code,{children:"hasMany"}),' relationships. An example of a many-to-many relationship is a user that has many roles and those roles are also shared by other users in the application. For example, a user may be assigned the role of "Author" and "Editor"; however, those roles may also be assigned to other users as well. So, a user has many roles and a role has many users.']}),"\n",(0,s.jsx)(n.h4,{id:"table-structure",children:"Table Structure"}),"\n",(0,s.jsxs)(n.p,{children:["To define this relationship, three database tables are needed: ",(0,s.jsx)(n.code,{children:"users"}),", ",(0,s.jsx)(n.code,{children:"roles"}),", and ",(0,s.jsx)(n.code,{children:"role_user"}),". The ",(0,s.jsx)(n.code,{children:"role_user"})," table is derived from the alphabetical order of the related model names and contains ",(0,s.jsx)(n.code,{children:"user_id"})," and ",(0,s.jsx)(n.code,{children:"role_id"})," columns. This table is used as an intermediate table linking the users and roles."]}),"\n",(0,s.jsxs)(n.p,{children:["Remember, since a role can belong to many users, we cannot simply place a ",(0,s.jsx)(n.code,{children:"user_id"})," column on the ",(0,s.jsx)(n.code,{children:"roles"})," table. This would mean that a role could only belong to a single user. In order to provide support for roles being assigned to multiple users, the ",(0,s.jsx)(n.code,{children:"role_user"})," table is needed. We can summarize the relationship's table structure like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"users\n id - integer\n name - string\n\nroles\n id - integer\n name - string\n\nrole_user\n user_id - integer\n role_id - integer\n"})}),"\n",(0,s.jsx)(n.h4,{id:"model-structure",children:"Model Structure"}),"\n",(0,s.jsxs)(n.p,{children:["Many-to-many relationships are defined by writing a method that returns the result of the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method. The ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method is provided by the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Model"})," base class that is used by all of your application's TinyORM models. For example, let's define a ",(0,s.jsx)(n.code,{children:"roles"})," method on our ",(0,s.jsx)(n.code,{children:"User"})," model. The first argument passed to this method is the name of the related model class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/role.hpp"\n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The roles that belong to the user. */\n std::unique_ptr>\n roles()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"roles", [](auto &v) { v(&User::roles); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the relationship is defined, you may access the user's roles as the ",(0,s.jsx)(n.code,{children:"QList"})," by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nauto user = User::find(1);\n\nfor (auto *role : user->getRelationValue("roles"))\n qDebug() << role->getAttribute("id");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Since all relationships also serve as query builders, you may add further constraints to the relationship query by calling the ",(0,s.jsx)(n.code,{children:"roles"})," method and continuing to chain conditions onto the query:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto roles = User::find(1)->roles()->orderBy("name").get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["To determine the table name of the relationship's intermediate table, TinyORM will join the two related model names in alphabetical order. However, you are free to override this convention. You may do so by passing a first argument to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return belongsToMany("role_user");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In addition to customizing the name of the intermediate table, you may also customize the column names of the keys on the table by passing additional arguments to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method. The second argument is the foreign key name of the model on which you are defining the relationship, while the third argument is the foreign key name of the model that you are joining to:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'return belongsToMany("role_user", "user_id", "role_id");\n'})}),"\n",(0,s.jsx)(n.p,{children:"The fourth and fifth arguments are primary key names on models in the many-to-many relation and the sixth argument is the relation name."}),"\n",(0,s.jsxs)(n.p,{children:["The relation name is used during ",(0,s.jsx)(n.a,{href:"#touching-parent-timestamps",children:"Touching Parent Timestamps"})," and will be guessed from the type-id of the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, TinyORM takes this name, changes the first character to lower case, and appends ",(0,s.jsx)(n.code,{children:"s"})," character. So in the example above, the relation name will be ",(0,s.jsx)(n.code,{children:"roles"}),"."]}),"\n",(0,s.jsx)(n.h4,{id:"defining-the-inverse-of-the-relationship-1",children:"Defining The Inverse Of The Relationship"}),"\n",(0,s.jsxs)(n.p,{children:['To define the "inverse" of a many-to-many relationship, you should define a method on the related model which also returns the result of the ',(0,s.jsx)(n.code,{children:"belongsToMany"})," method. To complete our user / role example, let's define the ",(0,s.jsx)(n.code,{children:"users"})," method on the ",(0,s.jsx)(n.code,{children:"Role"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef ROLE_HPP\n#define ROLE_HPP\n\n#include \n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User; // Forward declaration to avoid cyclic dependency\n\nclass Role final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The users that belong to the role. */\n std::unique_ptr>\n users()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"users", [](auto &v) { v(&Role::users); }},\n };\n};\n\n#endif // ROLE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As you can see, the relationship is defined exactly the same as its ",(0,s.jsx)(n.code,{children:"User"})," model counterpart with the exception of referencing the ",(0,s.jsx)(n.code,{children:"User"})," model. Since we're reusing the ",(0,s.jsx)(n.code,{children:"belongsToMany"}),' method, all of the usual table and key customization options are available when defining the "inverse" of many-to-many relationships.']}),"\n",(0,s.jsx)(n.h3,{id:"retrieving-intermediate-table-columns",children:"Retrieving Intermediate Table Columns"}),"\n",(0,s.jsxs)(n.p,{children:["As you have already learned, working with many-to-many relations requires the presence of an intermediate table. TinyORM provides some very helpful ways of interacting with this table. For example, let's assume our ",(0,s.jsx)(n.code,{children:"User"})," model has many ",(0,s.jsx)(n.code,{children:"Role"})," models that it is related to. After accessing this relationship, we may access the intermediate table using the ",(0,s.jsx)(n.code,{children:"pivot"})," attribute on the models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Relations::Pivot;\n\nauto user = User::find(1);\n\nfor (auto *role : user->getRelationValue("roles"))\n qDebug() << role->getRelation("pivot")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Notice that each ",(0,s.jsx)(n.code,{children:"Role"})," model we retrieve has automatically assigned a ",(0,s.jsx)(n.code,{children:"pivot"})," relationship. This relation contains a model representing the intermediate table and it is an instance of the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::Pivot"})," model class."]}),"\n",(0,s.jsxs)(n.p,{children:["By default, only the model keys will be present on the ",(0,s.jsx)(n.code,{children:"pivot"})," model. If your intermediate table contains extra attributes, you must specify them when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->withPivot({"active", "created_by"});\n\nreturn relation;\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like your intermediate table to have ",(0,s.jsx)(n.code,{children:"created_at"})," and ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamps that are automatically maintained by TinyORM, call the ",(0,s.jsx)(n.code,{children:"withTimestamps"})," method when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->withTimestamps();\n\nreturn relation;\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["Intermediate tables that utilize TinyORM's automatically maintained timestamps are required to have both ",(0,s.jsx)(n.code,{children:"created_at"})," and ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamp columns."]})}),"\n",(0,s.jsxs)(n.h4,{id:"customizing-the-pivot-relation-name",children:["Customizing The ",(0,s.jsx)(n.code,{children:"pivot"})," Relation Name"]}),"\n",(0,s.jsxs)(n.p,{children:["As noted previously, attributes from the intermediate table may be accessed on models via the ",(0,s.jsx)(n.code,{children:"pivot"})," relation name. However, you are free to customize the name of this relation to better reflect its purpose within your application."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, if your application contains users that may subscribe to podcasts, you likely have a many-to-many relationship between users and podcasts. If this is the case, you may wish to rename your intermediate table relation name to ",(0,s.jsx)(n.code,{children:"subscription"})," instead of ",(0,s.jsx)(n.code,{children:"pivot"}),". This can be done using the ",(0,s.jsx)(n.code,{children:"as"})," method when defining the relationship:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Ownership of a unique_ptr()\nauto relation = belongsToMany();\n\nrelation->as("subscription")\n .withTimestamps();\n\nreturn relation;\n'})}),"\n",(0,s.jsx)(n.p,{children:"Once the custom intermediate table relation name has been specified, you may access the intermediate table data using the customized name:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nusing Orm::Tiny::Relations::Pivot;\n\nauto users = User::with("podcasts")->get();\n\nfor (auto &user : users)\n for (auto *podcast : user.getRelation("podcasts"))\n qDebug() << podcast->getRelation("subscription")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsx)(n.h3,{id:"defining-custom-intermediate-table-models",children:"Defining Custom Intermediate Table Models"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to define a custom model to represent the intermediate table of your many-to-many relationship, you may pass the custom pivot type as a second template argument to the ",(0,s.jsx)(n.code,{children:"belongsToMany"})," method when defining the relationship. Custom pivot models give you the opportunity to define additional methods on the pivot model."]}),"\n",(0,s.jsxs)(n.p,{children:["Custom many-to-many pivot models should extend the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::BasePivot"})," class. For example, we may define a ",(0,s.jsx)(n.code,{children:"User"})," model which uses a custom ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef USER_HPP\n#define USER_HPP\n\n#include \n\n#include "models/role.hpp"\n\nusing Orm::Tiny::Model;\nusing Orm::Tiny::Relations::Pivot;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The roles that belong to the user. */\n std::unique_ptr>\n roles()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"roles", [](auto &v) { v(&User::roles); }},\n };\n};\n\n#endif // USER_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["When defining the ",(0,s.jsx)(n.code,{children:"RoleUser"})," model, you should extend the ",(0,s.jsx)(n.code,{children:"Orm::Tiny::Relations::BasePivot"})," class:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"#pragma once\n#ifndef ROLEUSER_HPP\n#define ROLEUSER_HPP\n\n#include \n\nusing Orm::Tiny::Relations::BasePivot;\n\nclass RoleUser final : public BasePivot\n{\n friend Model;\n friend BasePivot;\n\n using BasePivot::BasePivot;\n};\n\n#endif // ROLEUSER_HPP\n"})}),"\n",(0,s.jsxs)(n.p,{children:["You have to pass a custom pivot type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on ",(0,s.jsx)(n.code,{children:"Model"})," so that the ",(0,s.jsx)(n.code,{children:"Model"})," knows how to generate a ",(0,s.jsx)(n.code,{children:"std::variant"}),", which holds all the relations and also you have to add a new mapping from the relation name to the custom pivot model type-id, this is described in more detail in the ",(0,s.jsx)(n.a,{href:"#common-rules",children:"Common Rules"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#pragma once\n#ifndef ROLE_HPP\n#define ROLE_HPP\n\n#include \n\n#include "models/roleuser.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User; // Forward declaration to avoid cyclic dependency\n\nclass Role final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! The users that belong to the role. */\n std::unique_ptr>\n users()\n {\n return belongsToMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"users", [](auto &v) { v(&Role::users); }},\n };\n};\n\n#endif // ROLE_HPP\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Once the custom pivot model ",(0,s.jsx)(n.code,{children:"RoleUser"})," has been defined, ",(0,s.jsx)(n.code,{children:"getRelation"})," or ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method returns proper pivot type:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/user.hpp"\n\nauto users = User::with("roles")->get();\n\nfor (auto &user : users)\n for (auto *role : user.getRelation("roles"))\n qDebug() << role->getRelation("pivot")\n ->getAttribute("created_at");\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["Custom Pivot models may not use the ",(0,s.jsx)(n.code,{children:"SoftDeletes"})," base class. If you need to soft delete pivot records consider converting your pivot model to an actual TinyORM model."]})}),"\n",(0,s.jsx)(n.h4,{id:"custom-pivot-models-and-incrementing-ids",children:"Custom Pivot Models And Incrementing IDs"}),"\n",(0,s.jsxs)(n.p,{children:["If you have defined a many-to-many relationship that uses a custom pivot model, and that pivot model has an auto-incrementing primary key, you should ensure your custom pivot model class defines an ",(0,s.jsx)(n.code,{children:"u_incrementing"})," data member that is set to ",(0,s.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"/*! Indicates if the IDs are auto-incrementing. */\nbool u_incrementing = true;\n"})}),"\n",(0,s.jsx)(n.h4,{id:"closer-look-at-defining-custom-intermediate-table-models",children:"Closer Look At Defining Custom Intermediate Table Models"}),"\n",(0,s.jsx)(n.p,{children:"I can tell that defining a custom intermediate table models is the most confusing part of the TinyORM framework, let's look closer at it."}),"\n",(0,s.jsxs)(n.p,{children:["If you are defining a custom ",(0,s.jsx)(n.code,{children:"RoleUser"})," intermediate table for the ",(0,s.jsx)(n.code,{children:"Role"})," model like in the example above then you have to pass the ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot type as the second template argument to the ",(0,s.jsx)(n.code,{children:"User::roles()"})," ",(0,s.jsx)(n.code,{children:"belongsToMany"})," relationship method and you have to pass the ",(0,s.jsx)(n.code,{children:"RoleUser"})," pivot type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack ",(0,s.jsxs)(n.strong,{children:["on the ",(0,s.jsx)(n.code,{children:"Role"})," model!"]})]}),"\n",(0,s.jsxs)(n.p,{children:["Do you see the confusing part? In short, if defining the ",(0,s.jsx)(n.code,{children:"User::roles()"})," relation with the custom ",(0,s.jsx)(n.code,{children:"UserRole"})," pivot model then add the ",(0,s.jsx)(n.code,{children:"UserRole"})," type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on the ",(0,s.jsx)(n.code,{children:"Role"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the basic ",(0,s.jsx)(n.code,{children:"Pivot"})," model, if you are using a basic pivot model and not a custom pivot model you still need to add the ",(0,s.jsx)(n.code,{children:"Pivot"})," type to the ",(0,s.jsx)(n.code,{children:"AllRelations"})," template parameter pack on the ",(0,s.jsx)(n.code,{children:"Model"})," class!"]}),"\n",(0,s.jsxs)(n.p,{children:["The reason for all of this is that the ",(0,s.jsx)(n.code,{children:"Model"})," knows how to generate and work with the ",(0,s.jsx)(n.code,{children:"std::variant"})," that holds the pivot model in the ",(0,s.jsx)(n.code,{children:"Model::m_relations"})," data member map, then you can get the pivot model using the ",(0,s.jsx)(n.code,{children:"Model::getRelationValue"})," or ",(0,s.jsx)(n.code,{children:"Model::getRelation"})," methods."]}),"\n",(0,s.jsx)(n.h5,{id:"user-data-members-on-custom-intermediate-table-models",children:"User Data Members on Custom Intermediate Table Models"}),"\n",(0,s.jsxs)(n.p,{children:["This is another nonstandard part of the custom pivot models. The ",(0,s.jsx)(n.code,{children:"u_connection"})," and ",(0,s.jsx)(n.code,{children:"u_timestamps"})," user data members and the ",(0,s.jsx)(n.code,{children:"CREATED_AT()"})," and ",(0,s.jsx)(n.code,{children:"UPDATED_AT()"})," static getter methods are ignored when obtaining pivot records from the database during the lazy or eager loading."]}),"\n",(0,s.jsx)(n.p,{children:"Let's describe how these data members are resolved:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"u_connection"})," - inferred from the parent model"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"u_timestamps"})," - true if obtained pivot attributes contain both the ",(0,s.jsx)(n.code,{children:"CREATED_AT"})," and ",(0,s.jsx)(n.code,{children:"UPDATED_AT"})," attributes"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"CREATED_AT"}),", ",(0,s.jsx)(n.code,{children:"UPDATED_AT"})," - inferred from the parent model, can be overridden using the ",(0,s.jsx)(n.code,{children:"withTimestamps()"})," method"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["All these data members are taken into account normally when you call the ",(0,s.jsx)(n.code,{children:"create"}),", ",(0,s.jsx)(n.code,{children:"save"}),", ",(0,s.jsx)(n.code,{children:"update"}),", ... on the Custom Pivot models!"]}),"\n",(0,s.jsx)(n.h2,{id:"querying-relations",children:"Querying Relations"}),"\n",(0,s.jsxs)(n.p,{children:["Since all TinyORM relationships are defined via methods, you may call those methods to obtain an instance of the relationship without actually executing a query to load the related models. In addition, all types of TinyORM relationships also serve as ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builders"}),", allowing you to continue to chain constraints onto the relationship query before finally executing the SQL query against your database."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, imagine a blog application in which a ",(0,s.jsx)(n.code,{children:"User"})," model has many associated ",(0,s.jsx)(n.code,{children:"Post"})," models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nusing Orm::Tiny::Model;\n\nclass User final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get all of the posts for the user. */\n std::unique_ptr>\n posts()\n {\n return hasMany();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"posts", [](auto &v) { v(&User::posts); }},\n };\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may query the ",(0,s.jsx)(n.code,{children:"posts"})," relationship and add additional constraints to the relationship like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nuser->posts()->whereEq("active", 1).get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You are able to use any of the TinyORM ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builder's"})," methods on the relationship, so be sure to explore the query builder documentation to learn about all of the methods that are available to you."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["All the ",(0,s.jsx)(n.code,{children:"TinyBuilder"})," methods which are related to building queries are proxied on the ",(0,s.jsx)(n.code,{children:"Relation"})," base class."]})}),"\n",(0,s.jsxs)(n.h4,{id:"chaining-orwhere-clauses-after-relationships",children:["Chaining ",(0,s.jsx)(n.code,{children:"orWhere"})," Clauses After Relationships"]}),"\n",(0,s.jsxs)(n.p,{children:["As demonstrated in the example above, you are free to add additional constraints to relationships when querying them. However, be careful when chaining ",(0,s.jsx)(n.code,{children:"orWhere"})," clauses onto a relationship, as the ",(0,s.jsx)(n.code,{children:"orWhere"})," clauses will be logically grouped at the same level as the relationship constraint:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()\n ->whereEq("active", 1)\n .orWhere("votes", ">=", 100)\n .get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The example above will generate the following SQL. As you can see, the ",(0,s.jsx)(n.code,{children:"or"})," clause instructs the query to return ",(0,s.jsx)(n.em,{children:"any"})," user with greater than 100 votes. The query is no longer constrained to a specific user:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select *\nfrom posts\nwhere user_id = ? and active = 1 or votes >= 100\n"})}),"\n",(0,s.jsxs)(n.p,{children:["In most situations, you should use ",(0,s.jsx)(n.a,{href:"/database/query-builder#logical-grouping",children:"logical groups"})," to group the conditional checks between parentheses:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->posts()\n ->where([](auto &query)\n {\n query.whereEq("active", 1)\n .orWhere("votes", ">=", 100);\n })\n .get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"The example above will produce the following SQL. Note that the logical grouping has properly grouped the constraints and the query remains constrained to a specific user:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select *\nfrom posts\nwhere user_id = ? and (active = 1 or votes >= 100)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"relationship-methods",children:"Relationship Methods"}),"\n",(0,s.jsxs)(n.p,{children:["If you do not need to add additional constraints to the TinyORM relationship query, you may access the relationship directly. For example, continuing to use our ",(0,s.jsx)(n.code,{children:"User"})," and ",(0,s.jsx)(n.code,{children:"Post"})," example models, we may access all of a user's posts like so:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nfor (auto *post : user->getRelationValue("posts")) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' method performs "lazy loading", meaning they will only load their relationship data when you actually access them. Because of this, developers often use ',(0,s.jsx)(n.a,{href:"#eager-loading",children:"eager loading"})," to pre-load relationships they know will be accessed after loading the model. Eager loading provides a significant reduction in SQL queries that must be executed to load a model's relations."]}),"\n",(0,s.jsxs)(n.p,{children:["To access eager loaded relationship use Model's ",(0,s.jsx)(n.code,{children:"getRelation"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nfor (auto *post : user->getRelation("posts")) {\n //\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["As described above TinyORM offers two methods to access relationships; ",(0,s.jsx)(n.code,{children:"getRelation"})," and ",(0,s.jsx)(n.code,{children:"getRelationValue"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelation"}),' method is for "eager loaded" relations, when the relationship is not loaded, it throws the exception ',(0,s.jsx)(n.code,{children:"RelationNotLoadedError"}),". The ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' is for "lazy loading", when the relationship is not loaded, it will load it.']}),"\n",(0,s.jsxs)(n.p,{children:["Both methods have two overloads, the ",(0,s.jsx)(n.code,{children:"getRelation"})," overload is for obtaining many type relationships:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = User::find(1)->getRelation("posts");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"getRelation"}),' overload is for obtaining "one" type relationships:']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = Post::find(1)->getRelation("user");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The same is true for the ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method."]}),"\n",(0,s.jsx)(n.h3,{id:"querying-relationship-existence",children:"Querying Relationship Existence"}),"\n",(0,s.jsxs)(n.p,{children:["When retrieving model records, you may wish to limit your results based on the existence of a relationship. For example, imagine you want to retrieve all blog posts that have at least one comment. To do so, you may pass the name of the relationship to the ",(0,s.jsx)(n.code,{children:"has"})," and ",(0,s.jsx)(n.code,{children:"orHas"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\n// Retrieve all posts that have at least one comment...\nauto posts = Post::has("comments")->get();\n'})}),"\n",(0,s.jsx)(n.p,{children:"You may also specify an operator and count value to further customize the query:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve all posts that have three or more comments...\nauto posts = Post::has("comments", ">=", 3)->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Nested ",(0,s.jsx)(n.code,{children:"has"}),' statements may be constructed using "dot" notation. For example, you may retrieve all posts that have at least one comment that has at least one image:']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve posts that have at least one comment with images...\nauto posts = Post::has("comments.images")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you need even more power, you may use the ",(0,s.jsx)(n.code,{children:"whereHas"})," and ",(0,s.jsx)(n.code,{children:"orWhereHas"})," methods to define additional query constraints on your ",(0,s.jsx)(n.code,{children:"has"})," queries, such as inspecting the content of a comment:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'// Retrieve posts with at least one comment containing words like code%...\nauto posts = Post::whereHas("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n})->get();\n\n// Retrieve posts with at least ten comments containing words like code%...\nauto posts = Post::whereHas("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n}, ">=", 10)->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsx)(n.p,{children:"TinyORM does not currently support querying for relationship existence across databases. The relationships must exist within the same database."})}),"\n",(0,s.jsx)(n.h4,{id:"related-template-parameter",children:"Related template parameter"}),"\n",(0,s.jsxs)(n.p,{children:["All the ",(0,s.jsx)(n.code,{children:"has"}),"-related methods are templated by the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter, it looks something like the following ",(0,s.jsx)(n.code,{children:"has(..., const std::function &)> &callback = nullptr)"}),", you can pass a query callback to this methods and on the base of the ",(0,s.jsx)(n.code,{children:"Related"})," template argument will be decided whether the ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," or ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder"})," will be passed to the callback. As you can see this ",(0,s.jsx)(n.code,{children:"Related"})," parameter exists because the ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder"})," needs it."]}),"\n",(0,s.jsx)(n.p,{children:"The rule of thumbs are:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["if you don't pass the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter or you pass ",(0,s.jsx)(n.code,{children:"void"})," then the ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder &"})," will be passed to the callback"]}),"\n",(0,s.jsxs)(n.li,{children:["if you pass it, then the ",(0,s.jsx)(n.code,{children:"Orm::TinyBuilder &"})," will be passed to the callback"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Related"})," has to be of the same type as a relation name passed to the ",(0,s.jsx)(n.code,{children:"has"}),"-related method (a real type of the relation eg. type of the ",(0,s.jsx)(n.code,{children:"posts"})," relation name is ",(0,s.jsx)(n.code,{children:"Post"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:["you have to always pass the ",(0,s.jsx)(n.code,{children:"Related"})," template parameter for nested relations, you can not use nested relations with ",(0,s.jsx)(n.code,{children:"Related = void"})]}),"\n",(0,s.jsxs)(n.li,{children:['in nested relations, where you can pass more relation names using "dot" notation, ',(0,s.jsx)(n.code,{children:"Related"})," has to be of the same type as the ",(0,s.jsx)(n.strong,{children:"last"})," relation name passed to the ",(0,s.jsx)(n.code,{children:"has"}),"-related method like you can see in the nested example above or below"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"querying-relationship-absence",children:"Querying Relationship Absence"}),"\n",(0,s.jsxs)(n.p,{children:["When retrieving model records, you may wish to limit your results based on the absence of a relationship. For example, imagine you want to retrieve all blog posts that ",(0,s.jsx)(n.strong,{children:"don't"})," have any comments. To do so, you may pass the name of the relationship to the ",(0,s.jsx)(n.code,{children:"doesntHave"})," and ",(0,s.jsx)(n.code,{children:"orDoesntHave"})," methods:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto posts = Post::doesntHave("comments")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you need even more power, you may use the ",(0,s.jsx)(n.code,{children:"whereDoesntHave"})," and ",(0,s.jsx)(n.code,{children:"orWhereDoesntHave"})," methods to add additional query constraints to your ",(0,s.jsx)(n.code,{children:"doesntHave"})," queries, such as inspecting the content of a comment:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = Post::whereDoesntHave("comments", [](auto &query)\n{\n query.where("content", LIKE, "code%");\n})->get();\n'})}),"\n",(0,s.jsx)(n.p,{children:'You may use "dot" notation to execute a query against a nested relationship. For example, the following query will retrieve all posts that have comments from authors that are not banned:'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto posts = Post::whereDoesntHave("comments.author",\n [](auto &query)\n{\n query.where("banned", false);\n})->get();\n'})}),"\n",(0,s.jsx)(n.h2,{id:"eager-loading",children:"Eager Loading"}),"\n",(0,s.jsxs)(n.p,{children:["When accessing TinyORM relationships by Model's ",(0,s.jsx)(n.code,{children:"getRelationValue"}),' method, the related models are "lazy loaded". This means the relationship data is not actually loaded until you first access them. However, TinyORM can "eager load" relationships at the time you query the parent model. Eager loading alleviates the "N + 1" query problem. To illustrate the N + 1 query problem, consider a ',(0,s.jsx)(n.code,{children:"Book"}),' model that "belongs to" to an ',(0,s.jsx)(n.code,{children:"Author"})," model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Book final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the author that wrote the book. */\n std::unique_ptr>\n author()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"author", [](auto &v) { v(&Book::author); }},\n };\n};\n'})}),"\n",(0,s.jsx)(n.p,{children:"Now, let's retrieve all books and their authors:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include "models/book.hpp"\n\nauto books = Book::all();\n\nfor (auto &book : books)\n qDebug() << book.getRelationValue("author")\n ->getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"This loop will execute one query to retrieve all of the books within the database table, then another query for each book in order to retrieve the book's author. So, if we have 25 books, the code above would run 26 queries: one for the original book, and 25 additional queries to retrieve the author of each book."}),"\n",(0,s.jsxs)(n.p,{children:["Thankfully, we can use eager loading to reduce this operation to just two queries. When building a query, you may specify which relationships should be eager loaded using the ",(0,s.jsx)(n.code,{children:"with"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author")->get();\n\nfor (auto &book : books)\n qDebug() << book.getRelation("author")\n ->getAttribute("name");\n'})}),"\n",(0,s.jsx)(n.p,{children:"For this operation, only two queries will be executed - one query to retrieve all of the books and one query to retrieve all of the authors for all of the books:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"select * from books\n\nselect * from authors where id in (1, 2, 3, 4, 5, ...)\n"})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-multiple-relationships",children:"Eager Loading Multiple Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you may need to eager load several different relationships. To do so, just pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"with"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with({"author", "publisher"})->get();\n'})}),"\n",(0,s.jsx)(n.h4,{id:"nested-eager-loading",children:"Nested Eager Loading"}),"\n",(0,s.jsx)(n.p,{children:"To eager a relationship's relationships, you may use \"dot\" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author.contacts")->get();\n'})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-specific-columns",children:"Eager Loading Specific Columns"}),"\n",(0,s.jsx)(n.p,{children:"You may not always need every column from the relationships you are retrieving. For this reason, TinyORM allows you to specify which columns of the relationship you would like to retrieve:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::with("author:id,name,book_id")->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["When using this feature, you should always include the ",(0,s.jsx)(n.code,{children:"id"})," column and any relevant foreign key columns in the list of columns you wish to retrieve, otherwise relations will not be loaded correctly."]})}),"\n",(0,s.jsx)(n.h4,{id:"eager-loading-by-default",children:"Eager Loading By Default"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you might want to always load some relationships when retrieving a model. To accomplish this, you may define a ",(0,s.jsx)(n.code,{children:"u_with"})," data member on the model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Book final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the author that wrote the book. */\n std::unique_ptr>\n author()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"author", [](auto &v) { v(&Book::author); }},\n };\n\n /*! The relationships that should always be loaded. */\n QList u_with {\n "author",\n };\n};\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to remove an item from the ",(0,s.jsx)(n.code,{children:"u_with"})," data member for a single query, you may use the ",(0,s.jsx)(n.code,{children:"without"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::without("author")->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to override all items within the ",(0,s.jsx)(n.code,{children:"u_with"})," data member for a single query, you may use the ",(0,s.jsx)(n.code,{children:"withOnly"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto books = Book::withOnly("genre")->get();\n'})}),"\n",(0,s.jsx)(n.h3,{id:"constraining-eager-loads",children:"Constraining Eager Loads"}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes you may wish to eager load a relationship but also specify additional query conditions for the eager loading query. You can accomplish this by passing a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"with"})," method where the ",(0,s.jsx)(n.code,{children:"name"})," data member of ",(0,s.jsx)(n.code,{children:"Orm::WithItem"})," struct is a relationship name and the ",(0,s.jsx)(n.code,{children:"constraints"})," data member expects a lambda expression that adds additional constraints to the eager loading query. The first argument passed to the ",(0,s.jsx)(n.code,{children:"constraints"})," lambda expression is an underlying ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," for a related model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto users = User::with({{"posts", [](auto &query)\n{\n query.where("title", "like", "%code%");\n}}})->get();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["In this example, TinyORM will only eager load posts where the post's ",(0,s.jsx)(n.code,{children:"title"})," column contains the word ",(0,s.jsx)(n.code,{children:"code"}),". You may call other ",(0,s.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," methods to further customize the eager loading operation:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto users = User::with({{"posts", [](auto &query)\n{\n query.orderBy("created_at", "desc");\n}}})->get();\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"limit"})," and ",(0,s.jsx)(n.code,{children:"take"})," query builder methods may not be used when constraining eager loads."]})}),"\n",(0,s.jsx)(n.h3,{id:"lazy-eager-loading",children:"Lazy Eager Loading"}),"\n",(0,s.jsx)(n.p,{children:"Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/book.hpp"\n\nauto book = Book::find(1);\n\nif (someCondition)\n book->load("author");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may load more relationships at once, to do so, just pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"load"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'Book::find(1)->load({"author", "publisher"});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["So far, this only works on models, not on containers returned from Model's ",(0,s.jsx)(n.code,{children:"get"})," or ",(0,s.jsx)(n.code,{children:"all"})," methods."]})}),"\n",(0,s.jsxs)(n.p,{children:["If you need to set additional query constraints on the eager loading query, you may pass a ",(0,s.jsx)(n.code,{children:"QList"})," of relationships to the ",(0,s.jsx)(n.code,{children:"load"})," method where the ",(0,s.jsx)(n.code,{children:"name"})," data member of ",(0,s.jsx)(n.code,{children:"Orm::WithItem"})," struct is a relationship name and the ",(0,s.jsx)(n.code,{children:"constraints"})," data member expects a lambda expression that adds additional constraints to the eager loading query. The first argument passed to the ",(0,s.jsx)(n.code,{children:"constraints"})," lambda expression is an underlying ",(0,s.jsx)(n.code,{children:"Orm::QueryBuilder"})," for a related model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'author->load({{"books", [](auto &query)\n{\n query.orderBy("published_date", "asc");\n}}});\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can also use eager constraining in the Model's ",(0,s.jsx)(n.code,{children:"fresh"})," method."]})}),"\n",(0,s.jsx)(n.h2,{id:"inserting-and-updating-related-models",children:"Inserting & Updating Related Models"}),"\n",(0,s.jsxs)(n.h3,{id:"the-save-method",children:["The ",(0,s.jsx)(n.code,{children:"save"})," Method"]}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM provides convenient methods for adding new models to relationships. For example, perhaps you need to add a new comment to a post. Instead of manually setting the ",(0,s.jsx)(n.code,{children:"post_id"})," attribute on the ",(0,s.jsx)(n.code,{children:"Comment"})," model you may insert the comment using the relationship's ",(0,s.jsx)(n.code,{children:"save"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/comment.hpp"\n#include "models/post.hpp"\n\nComment comment({{"message", "A new comment."}});\n\nauto post = Post::find(1);\n\npost->comments()->save(comment);\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Note that we did not access the ",(0,s.jsx)(n.code,{children:"comments"})," relationship with the ",(0,s.jsx)(n.code,{children:"getRelation"})," or ",(0,s.jsx)(n.code,{children:"getRelationValue"})," method. Instead, we called the ",(0,s.jsx)(n.code,{children:"comments"})," method to obtain an instance of the relationship. The ",(0,s.jsx)(n.code,{children:"save"})," method will automatically add the appropriate ",(0,s.jsx)(n.code,{children:"post_id"})," value to the new ",(0,s.jsx)(n.code,{children:"Comment"})," model."]}),"\n",(0,s.jsxs)(n.p,{children:["If you need to save multiple related models, you may use the ",(0,s.jsx)(n.code,{children:"saveMany"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\npost->comments()->saveMany({\n {{"message", "A new comment."}},\n {{"message", "Another new comment."}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods will not add the new models to any in-memory relationships that are already loaded onto the parent model. If you plan on accessing the relationship after using the ",(0,s.jsx)(n.code,{children:"save"})," or ",(0,s.jsx)(n.code,{children:"saveMany"})," methods, you may wish to use the ",(0,s.jsx)(n.code,{children:"refresh"})," method to reload the model and its relationships:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'post->comments()->save(comment);\n\npost->refresh();\n\n// All comments, including the newly saved comment...\npost->getRelation("comments");\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The many-to-many relationship also supports the ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods. In addition, you may pass the pivot attributes as a second argument and select if you want to touch parent timestamps as a third argument:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(2);\n\nRole role {{"name", "admin"}};\n\nuser->roles()->save(role, {{"active", true}});\n\nRole role1 {{"name", "edit"}};\nRole role2 {{"name", "view"}};\n\nuser->roles()->saveMany({role1, role2}, {{{"active", true}},\n {{"active", false}}});\n\n// No pivot attributes for role1\nuser->roles()->saveMany({role1, role2}, {{}, {{"active", false}}});\n'})}),"\n",(0,s.jsx)(n.h4,{id:"recursively-saving-models--relationships",children:"Recursively Saving Models & Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to ",(0,s.jsx)(n.code,{children:"save"})," your model and all of its associated relationships, you may use the ",(0,s.jsx)(n.code,{children:"push"})," method. In this example, the ",(0,s.jsx)(n.code,{children:"Post"})," model will be saved as well as its comments and the comment's authors:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\npost->getRelationValue("comments").at(0)->setAttribute("message", "Message");\n\npost->getRelationValue("comments").first()\n ->getRelationValue("author")->setAttribute("name", "Author Name");\n\npost->push();\n'})}),"\n",(0,s.jsxs)(n.h3,{id:"the-create-method",children:["The ",(0,s.jsx)(n.code,{children:"create"})," Method"]}),"\n",(0,s.jsxs)(n.p,{children:["In addition to the ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"saveMany"})," methods, you may also use the ",(0,s.jsx)(n.code,{children:"create"})," method, which accepts a vector of attributes, creates a model, and inserts it into the database. The difference between ",(0,s.jsx)(n.code,{children:"save"})," and ",(0,s.jsx)(n.code,{children:"create"})," is that ",(0,s.jsx)(n.code,{children:"save"})," accepts a full TinyORM model instance while ",(0,s.jsx)(n.code,{children:"create"})," accepts a ",(0,s.jsx)(n.code,{children:"QList"}),". The newly created model will be returned by the ",(0,s.jsx)(n.code,{children:"create"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/post.hpp"\n\nauto post = Post::find(1);\n\nauto comment = post->comments()->create({\n {"message", "A new comment."},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may use the ",(0,s.jsx)(n.code,{children:"createMany"})," method to create multiple related models:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto post = Post::find(1);\n\nauto comments = post->comments()->createMany({\n {{"message", "A new comment."}, {"is_published", true}},\n {{"message", "Another new comment."}, {"is_published", false}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The many-to-many relationship also supports the ",(0,s.jsx)(n.code,{children:"create"})," and ",(0,s.jsx)(n.code,{children:"createMany"})," methods. In addition, you may pass the pivot attributes as a second argument and select if you want to touch parent timestamps as a third argument:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(2);\n\nuser->roles()->create({{"name", "admin"}}, {{"active", true}});\n\nuser->roles()->createMany({\n {{"name", "edit"}},\n {{"name", "view"}},\n}, {\n {{"active", true}},\n {{"active", false}},\n});\n\n// No pivot attributes for the first role\nuser->roles()->createMany({\n {{"name", "edit"}},\n {{"name", "view"}},\n}, {\n {},\n {{"active", false}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["You may also use the ",(0,s.jsx)(n.code,{children:"findOrNew"}),", ",(0,s.jsx)(n.code,{children:"firstOrNew"}),", ",(0,s.jsx)(n.code,{children:"firstOrCreate"}),", and ",(0,s.jsx)(n.code,{children:"updateOrCreate"})," methods to ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#retrieving-or-creating-models",children:"create and update models on relationships"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["Before using the ",(0,s.jsx)(n.code,{children:"create"})," method, be sure to review the ",(0,s.jsx)(n.a,{href:"/tinyorm/getting-started#mass-assignment",children:"mass assignment"})," documentation."]})}),"\n",(0,s.jsx)(n.h3,{id:"updating-belongs-to-relationships",children:"Belongs To Relationships"}),"\n",(0,s.jsxs)(n.p,{children:["If you would like to assign a child model to a new parent model, you may use the ",(0,s.jsx)(n.code,{children:"associate"})," method. In this example, the ",(0,s.jsx)(n.code,{children:"User"})," model defines a ",(0,s.jsx)(n.code,{children:"belongsTo"})," relationship to the ",(0,s.jsx)(n.code,{children:"Account"})," model. The ",(0,s.jsx)(n.code,{children:"associate"})," method will set the foreign key on the child model:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nUser user {{"name", "Mike"}};\n\nauto account = Account::find(10);\n\nuser.account()->associate(*account);\n\nuser.save();\n'})}),"\n",(0,s.jsxs)(n.p,{children:["To remove a parent model from a child model, you may use the ",(0,s.jsx)(n.code,{children:"dissociate"})," method. This method will set the relationship's foreign key to ",(0,s.jsx)(n.code,{children:"null"}),":"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user.account()->dissociate();\n\nuser.save();\n"})}),"\n",(0,s.jsx)(n.h3,{id:"updating-many-to-many-relationships",children:"Many To Many Relationships"}),"\n",(0,s.jsx)(n.h4,{id:"attaching--detaching",children:"Attaching / Detaching"}),"\n",(0,s.jsxs)(n.p,{children:["TinyORM also provides methods to make working with many-to-many relationships more convenient. For example, let's imagine a user can have many roles and a role can have many users. You may use the ",(0,s.jsx)(n.code,{children:"attach"})," method to attach a role to a user by inserting a record in the relationship's intermediate table:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto user = User::find(1);\n\nuser->roles()->attach(roleId);\n'})}),"\n",(0,s.jsx)(n.p,{children:"When attaching a relationship to a model, you may also pass a vector of additional data to be inserted into the intermediate table:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'const auto expires = true;\n\nuser->roles()->attach(roleId, {{"expires", expires}});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["Sometimes it may be necessary to remove a role from a user. To remove a many-to-many relationship record, use the ",(0,s.jsx)(n.code,{children:"detach"})," method. The ",(0,s.jsx)(n.code,{children:"detach"})," method will delete the appropriate record out of the intermediate table; however, both models will remain in the database:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"// Detach a single role from the user...\nuser->roles()->detach(roleId);\n\n// Detach all roles from the user...\nuser->roles()->detachAll();\n"})}),"\n",(0,s.jsxs)(n.p,{children:["For convenience, ",(0,s.jsx)(n.code,{children:"attach"})," and ",(0,s.jsx)(n.code,{children:"detach"})," also accept vectors of IDs or Model instances as input:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nuser->roles()->detach({1, 2, 3});\n\nRole role1({{"name", "Role 1"}});\nrole1.save();\nRole role2({{"name", "Role 2"}});\nrole2.save();\n\nuser->roles()->attach({{role1}, {role2}});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"attach"})," method also accepts ",(0,s.jsx)(n.code,{children:"std::map"})," as input, so you can pass different attributes for each model you are attaching:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->roles()->attach({\n {1, {{"expires", true}, {"is_active", false}}},\n {2, {{"expires", false}, {"is_active", true}}},\n});\n'})}),"\n",(0,s.jsx)(n.h4,{id:"syncing-associations",children:"Syncing Associations"}),"\n",(0,s.jsxs)(n.p,{children:["You may also use the ",(0,s.jsx)(n.code,{children:"sync"})," method to construct many-to-many associations. The ",(0,s.jsx)(n.code,{children:"sync"})," method accepts a vector of IDs to place on the intermediate table. Any IDs that are not in the given vector will be removed from the intermediate table. So, after this operation is complete, only the IDs in the given vector will exist in the intermediate table:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user->roles()->sync({1, 2, 3});\n"})}),"\n",(0,s.jsx)(n.p,{children:"You may also pass additional intermediate table values with the IDs:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'user->roles()->sync({\n {1, {{"expires", true}}},\n {2, {}},\n {3, {}},\n});\n'})}),"\n",(0,s.jsxs)(n.p,{children:["If you do not want to detach existing IDs that are missing from the given vector, you may use the ",(0,s.jsx)(n.code,{children:"syncWithoutDetaching"})," method:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:"user->roles()->syncWithoutDetaching({1, 2, 3});\n"})}),"\n",(0,s.jsx)(n.h4,{id:"updating-a-record-on-the-intermediate-table",children:"Updating A Record On The Intermediate Table"}),"\n",(0,s.jsxs)(n.p,{children:["If you need to update an existing row in your relationship's intermediate table, you may use the ",(0,s.jsx)(n.code,{children:"updateExistingPivot"})," method. This method accepts the intermediate record foreign key and the vector of attributes to update:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'auto user = User::find(1);\n\nuser->roles()->updateExistingPivot(roleId, {\n {"active", false},\n});\n'})}),"\n",(0,s.jsx)(n.h2,{id:"touching-parent-timestamps",children:"Touching Parent Timestamps"}),"\n",(0,s.jsxs)(n.p,{children:["When a model defines a ",(0,s.jsx)(n.code,{children:"belongsTo"})," relationship to another model, such as a ",(0,s.jsx)(n.code,{children:"Comment"})," which belongs to a ",(0,s.jsx)(n.code,{children:"Post"}),", it is sometimes helpful to update the parent's timestamp when the child model is updated."]}),"\n",(0,s.jsxs)(n.p,{children:["For example, when a ",(0,s.jsx)(n.code,{children:"Comment"}),' model is updated, you may want to automatically "touch" the ',(0,s.jsx)(n.code,{children:"updated_at"})," timestamp of the owning ",(0,s.jsx)(n.code,{children:"Post"})," so that it is set to the current date and time. To accomplish this, you may add a ",(0,s.jsx)(n.code,{children:"u_touches"})," data member to your child model containing the names of the relationships that should have their ",(0,s.jsx)(n.code,{children:"updated_at"})," timestamps updated when the child model is updated:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",children:'using Orm::Tiny::Model;\n\nclass Comment final : public Model\n{\n friend Model;\n using Model::Model;\n\npublic:\n /*! Get the post that owns the comment. */\n std::unique_ptr>\n post()\n {\n return belongsTo();\n }\n\nprivate:\n /*! Map of relation names to methods. */\n QHash u_relations {\n {"post", [](auto &v) { v(&Comment::post); }},\n };\n\n /*! All of the relationships to be touched. */\n QStringList u_touches {"post"};\n};\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["Parent model timestamps will only be updated if the child model is updated using TinyORM's ",(0,s.jsx)(n.code,{children:"save"}),", ",(0,s.jsx)(n.code,{children:"push"}),", or ",(0,s.jsx)(n.code,{children:"remove"})," method."]})})]})}function m(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},8453:(e,n,o)=>{o.d(n,{R:()=>a,x:()=>r});var s=o(6540);const t={},i=s.createContext(t);function a(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/8a8faf8d.c1f86db1.js b/assets/js/8a8faf8d.c1f86db1.js deleted file mode 100644 index 1681d0282..000000000 --- a/assets/js/8a8faf8d.c1f86db1.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[129],{6455:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>u,default:()=>j,frontMatter:()=>h,metadata:()=>m,toc:()=>g});var s=i(4848),t=i(8453),a=i(8774),r=i(2364),l=i(9365),o=i(1470),d=i(7324),c=i(6694);const h={sidebar_position:3,sidebar_label:"Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",keywords:["c++ orm","building","migrations","tinyorm"]},u="Building: Migrations",m={id:"building/migrations",title:"Building: Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",source:"@site/docs/building/migrations.mdx",sourceDirName:"building",slug:"/building/migrations",permalink:"/building/migrations",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",keywords:["c++ orm","building","migrations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Hello world",permalink:"/building/hello-world"},next:{title:"\ud83d\udea9 Stability",permalink:"/stability"}},p={},g=[{value:"Introduction",id:"introduction",level:2},{value:"Install dependencies",id:"install-dependencies",level:2},{value:"Using vcpkg.json (manifest mode)",id:"using-vcpkg-json-manifest-mode",level:4},{value:"Using vcpkg install (manually)",id:"using-vcpkg-install-manually",level:4},{value:"Source code",id:"source-code",level:2},{value:"Main file",id:"main-file",level:3},{value:"Migrations",id:"migrations",level:3},{value:"Seeders",id:"seeders",level:3},{value:"Migrations with CMake",id:"migrations-with-cmake",level:2},{value:"CMake project",id:"cmake-project",level:3},{value:"Build migrations",id:"build-migrations-cmake",level:3},{value:"Execute migrations",id:"execute-migrations-cmake",level:3},{value:"Migrations with qmake",id:"migrations-with-qmake",level:2},{value:"qmake project",id:"qmake-project",level:3},{value:"Auto-configure using .qmake.conf and .env",id:"auto-configure-using-qmakeconf-and-env",level:4},{value:"Migrations source files",id:"migrations-source-files",level:4},{value:"Seeders source files",id:"seeders-source-files",level:4},{value:"Build migrations",id:"build-migrations-qmake",level:3},{value:"Execute migrations",id:"execute-migrations-qmake",level:3},{value:"Finish",id:"finish",level:2}];function x(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"building-migrations",children:"Building: Migrations"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#using-vcpkg-json-manifest-mode",children:"Using vcpkg.json"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#using-vcpkg-install-manually",children:"Using vcpkg install"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#source-code",children:"Source code"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#main-file",children:"Main file"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#migrations",children:"Migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#seeders",children:"Seeders"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#migrations-with-cmake",children:"Migrations with CMake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-project",children:"CMake project"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#build-migrations-cmake",children:"Build migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#execute-migrations-cmake",children:"Execute migrations"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#migrations-with-qmake",children:"Migrations with qmake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#qmake-project",children:"qmake project"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#build-migrations-qmake",children:"Build migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#execute-migrations-qmake",children:"Execute migrations"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#finish",children:"Finish"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["We will try to create a working migrations console application called as ",(0,s.jsx)("abbr",{title:"TinyORM migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," in the terminal with the ",(0,s.jsx)(n.code,{children:"CMake"})," and in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"})," with the ",(0,s.jsx)(n.code,{children:"qmake"})," build systems."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tom"})," console application also expects the following ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"}),", let's create them."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}\nmkdir tom/tom\ncd tom`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}\nmkdir -p tom/tom\ncd tom`})})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.code,{children:"tom"})," example application, you can inspire or look at the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/examples/tom",children:"source code"}),". Also, ",(0,s.jsx)(n.code,{children:"TinyORM"})," unit tests use a ",(0,s.jsx)(n.code,{children:"tom"})," migrations internally to create the database structure, internally called as the ",(0,s.jsxs)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/tests/testdata_tom",children:[(0,s.jsx)(n.code,{children:"tom"})," migrations for unit tests"]}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["All these three console applications the ",(0,s.jsx)(n.code,{children:"tom"})," example, ",(0,s.jsx)(n.code,{children:"tom"})," migrations for unit tests, and the application described in this tutorial have practically identical source code (the main.cpp file)."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tom"})," is able to generate ",(0,s.jsx)("a",{href:"https://en.wikipedia.org/wiki/Data_definition_language",title:"Data Definition Language",children:"DDL"})," queries for all the ",(0,s.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"})," databases."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can see the ",(0,s.jsx)(n.a,{href:"/features-summary#tom-console-application",children:"Tom showcase image"})," of how the resulting ",(0,s.jsx)(n.code,{children:"tom"})," console application will look like."]})}),"\n",(0,s.jsx)(n.h2,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.p,{children:["First, install the ",(0,s.jsx)(n.code,{children:"vcpkg"})," package manager as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#vcpkg",children:"here"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," libraries are required dependencies because ",(0,s.jsx)(n.code,{children:"TinyORM"})," uses them in header files, you have to install them before you can use ",(0,s.jsx)(n.code,{children:"TinyORM"}),". The ",(0,s.jsx)(n.code,{children:"tabulate"})," library is only needed in the ",(0,s.jsx)(n.code,{children:"tom"})," migrations it's used by the ",(0,s.jsx)(n.code,{children:"migrate:status"})," command."]}),"\n",(0,s.jsxs)(n.p,{children:["There are two ways how to install the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," libraries using ",(0,s.jsx)(n.code,{children:"vcpkg"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Also, don't forget to build the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library with the ",(0,s.jsx)(n.code,{children:"tom"})," source code enabled (it's enabled by default) as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm",children:"here"}),"."]}),"\n",(0,s.jsxs)(n.h4,{id:"using-vcpkg-json-manifest-mode",children:["Using vcpkg.json ",(0,s.jsx)("small",{children:"(manifest mode)"})]}),"\n",(0,s.jsxs)(n.p,{children:["Create a ",(0,s.jsx)(n.code,{children:"vcpkg.json"})," file with the following content. ",(0,s.jsx)(n.code,{children:"CMake"})," example below uses this method."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd tom\nvim vcpkg.json\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"title='vcpkg.json'",children:'{\n "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",\n "name": "tom",\n "version-semver": "0.1.0",\n "maintainers": "Silver Zachara ",\n "description": "Tom console application for TinyORM C++ library",\n "homepage": "https://github.com/silverqx/TinyORM",\n "documentation": "https://www.tinyorm.org/building/migrations",\n "supports": "!(uwp | arm | android | emscripten | osx | ios | xbox | freebsd | openbsd | wasm32)",\n "dependencies": [\n "range-v3",\n "tabulate"\n ]\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["Only ",(0,s.jsx)(n.code,{children:"CMake"})," via the ",(0,s.jsx)(n.code,{children:"toolchain file"})," supports this method."]})}),"\n",(0,s.jsxs)(n.h4,{id:"using-vcpkg-install-manually",children:["Using vcpkg install ",(0,s.jsx)("small",{children:"(manually)"})]}),"\n",(0,s.jsxs)(n.p,{children:["This method can be used with both ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,s.jsx)(n.h2,{id:"source-code",children:"Source code"}),"\n",(0,s.jsxs)(n.p,{children:["Let's start in the ",(0,s.jsx)(n.code,{children:"tom"})," project folder."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/tom/tom`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/tom/tom`})})]}),"\n",(0,s.jsx)(n.h3,{id:"main-file",children:"Main file"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"main.cpp"})," source file."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"vim main.cpp\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,s.jsx)(n.code,{children:"vim"}),", press ",(0,s.jsx)("kbd",{children:"Shift"})," + ",(0,s.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(a.A,{id:"string-constants-example"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='main.cpp'",children:'#include \n\n#include \n\n#include "migrations/2014_10_12_000000_create_posts_table.hpp"\n\n#include "seeders/databaseseeder.hpp"\n\nusing Orm::DatabaseManager;\nusing Orm::DB;\n\nusing TomApplication = Tom::Application;\n\nusing namespace Migrations; // NOLINT(google-build-using-namespace)\nusing namespace Seeders; // NOLINT(google-build-using-namespace)\n\n/*! Create the database manager instance and add a database connection. */\nstd::shared_ptr setupDatabaseManager();\n\n/*! C++ main function. */\nint main(int argc, char *argv[])\n{\n try {\n // Ownership of the shared_ptr()\n auto db = setupDatabaseManager();\n\n return TomApplication(argc, argv, std::move(db), "TOM_EXAMPLE_ENV")\n .migrations()\n .seeders()\n // Fire it up \ud83d\udd25\ud83d\ude80\u2728\n .run();\n\n } catch (const std::exception &e) {\n\n TomApplication::logException(e);\n }\n\n return EXIT_FAILURE;\n}\n\nstd::shared_ptr setupDatabaseManager()\n{\n using namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n // Ownership of the shared_ptr()\n return DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_MYSQL_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_MYSQL_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_MYSQL_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_MYSQL_USERNAME", EMPTY)},\n {password_, qEnvironmentVariable("DB_MYSQL_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_MYSQL_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_MYSQL_COLLATION", UTF8MB40900aici)},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {strict_, true},\n },\n QStringLiteral("tinyorm_tom_mysql")); // shell:connection\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If you have defined more database connections then you can tag the lines with the database connection names with the ",(0,s.jsx)(n.code,{children:"// shell:connection"})," comment and this connection names will be provided to the bash, zsh, pwsh completions for the ",(0,s.jsx)(n.code,{children:"--database="})," option \ud83d\ude0e, ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/examples/tom/main.cpp#L76",children:"example"}),"."]})}),"\n",(0,s.jsx)(n.h3,{id:"migrations",children:"Migrations"}),"\n",(0,s.jsxs)(n.p,{children:["If you have already built the ",(0,s.jsx)(n.code,{children:"tom"})," application then you can generate a migrations using the ",(0,s.jsx)(n.a,{href:"/database/migrations#generating-migrations",children:(0,s.jsx)(n.code,{children:"make:migration"})})," command \ud83d\ude0e."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tom make:migration create_posts_table\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Below is the expected folders structure for the migrations. The ",(0,s.jsx)(n.a,{href:"#migrations-source-files",children:(0,s.jsx)(n.code,{children:"migrations.pri"})})," file is used only by the ",(0,s.jsx)(n.code,{children:"qmake"})," build system and is not needed with ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]}),"\n",(0,s.jsx)(a.A,{id:"folders-structure"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"tom/\n\u2514\u2500\u2500 database/\n \u251c\u2500\u2500 migrations/\n \u251c\u2500\u2500 seeders/\n \u251c\u2500\u2500 migrations.pri\n \u2514\u2500\u2500 seeders.pri\n"})}),"\n",(0,s.jsx)(n.p,{children:"Let's create the first migration manually."}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"mkdir database/migrations\n\nvim database/migrations/2014_10_12_000000_create_posts_table.hpp"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"mkdir -p database/migrations\n\nvim database/migrations/2014_10_12_000000_create_posts_table.hpp"})})]}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='database/migrations/2014_10_12_000000_create_posts_table.hpp'",children:'#pragma once\n\n#include \n\nnamespace Migrations\n{\n\n struct CreatePostsTable : Migration\n {\n /*! Filename of the migration file. */\n T_MIGRATION\n\n /*! Run the migrations. */\n void up() const override\n {\n Schema::create("posts", [](Blueprint &table)\n {\n table.id();\n\n table.string(NAME);\n table.timestamps();\n });\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n Schema::dropIfExists("posts");\n }\n };\n\n} // namespace Migrations\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/database/migrations/2014_10_12_000000_create_posts_table.hpp#L5",children:(0,s.jsx)(n.code,{children:"CreatePostsTable"})})," example migration that also acts as the full-fledged example migration. It has defined and also nicely commented all possible features that migration classes can use or define."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["If you want, you can also build the ",(0,s.jsx)(n.code,{children:"tom"})," application without the migrations, simply comment out the ",(0,s.jsx)(n.code,{children:"migrations"})," method and the corresponding ",(0,s.jsx)(n.code,{children:'#include "migrations/xyz.hpp"'})," files."]})}),"\n",(0,s.jsx)(n.h3,{id:"seeders",children:"Seeders"}),"\n",(0,s.jsxs)(n.p,{children:["If you have already built the ",(0,s.jsx)(n.code,{children:"tom"})," application then you can generate a seeder using the ",(0,s.jsx)(n.a,{href:"/database/seeding#writing-seeders",children:(0,s.jsx)(n.code,{children:"make:seeder"})})," command \ud83d\ude0e."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tom make:seeder PostSeeder\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The expected folders structure is described a few paragraphs ",(0,s.jsx)(n.a,{href:"#folders-structure",children:"above"}),". The ",(0,s.jsx)(n.a,{href:"#seeders-source-files",children:(0,s.jsx)(n.code,{children:"seeders.pri"})})," file is used only by the ",(0,s.jsx)(n.code,{children:"qmake"})," build system and is not needed with ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]}),"\n",(0,s.jsx)(n.p,{children:"Let's create the root seeder class manually."}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"mkdir database/seeders\n\nvim database/seeders/databaseseeder.hpp"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"mkdir -p database/seeders\n\nvim database/seeders/databaseseeder.hpp"})})]}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='database/seeders/databaseseeder.hpp'",children:'#pragma once\n\n#include \n\nnamespace Seeders\n{\n\n /*! Main database seeder. */\n struct DatabaseSeeder : Seeder\n {\n /*! Run the database seeders. */\n void run() override\n {\n DB::table("posts")->insert({\n {{"name", "1. post"}},\n {{"name", "2. post"}},\n });\n }\n };\n\n} // namespace Seeders\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/database/seeders/databaseseeder.hpp#L8",children:(0,s.jsx)(n.code,{children:"DatabaseSeeder"})})," root seeder example class that also acts as the full-fledged example seeder. It has defined and also nicely commented all possible features that seeder classes can use or define."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can create more seeder classes like this and use the ",(0,s.jsx)(n.code,{children:"call<>()"})," method to invoke them as is described in the ",(0,s.jsx)(n.a,{href:"/database/seeding#calling-additional-seeders",children:"Calling Additional Seeders"})," section."]})}),"\n",(0,s.jsx)(n.h2,{id:"migrations-with-cmake",children:"Migrations with CMake"}),"\n",(0,s.jsxs)(n.p,{children:["Create a folder for the ",(0,s.jsx)(n.code,{children:"CMake"})," build."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"cd ..\nmkdir tom-builds-cmake/build-debug\n\ncd tom"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"cd ..\nmkdir -p tom-builds-cmake/build-debug\n\ncd tom"})})]}),"\n",(0,s.jsx)(n.h3,{id:"cmake-project",children:"CMake project"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file with the following content. I leave the comments in the ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file because it's not as simple as the ",(0,s.jsx)(n.code,{children:"Hello world"})," example; to make it clear what's going on."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",metastring:"title='CMakeLists.txt'",children:'cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\n# Specify the C++ standard\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# Initialize variables\n# ---\n\nset(Tom_ns tom)\nset(Tom_target tom)\n\nfile(REAL_PATH "../../TinyORM" TinyMainDir)\n\nset(TinyOrmSourceDir "${TinyMainDir}/TinyORM")\nset(TinyOrmBuildDir "${TinyMainDir}/TinyORM-builds-cmake/build-debug")\n\n# TinyORM CMake modules (needed to set the executable version and RC file on Windows)\nlist(APPEND CMAKE_MODULE_PATH "${TinyOrmSourceDir}/cmake/CommonModules")\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${TinyOrmBuildDir}")\n\n# Initialize Project Version\n# ---\n\ninclude(TinyHelpers)\ntiny_read_version(TINY_VERSION\n TINY_VERSION_MAJOR TINY_VERSION_MINOR TINY_VERSION_PATCH TINY_VERSION_TWEAK\n VERSION_HEADER "${TinyOrmSourceDir}/tom/include/tom/version.hpp"\n PREFIX TINYTOM\n HEADER_FOR "${Tom_ns}"\n)\n\n# Basic project\n# ---\n\nproject(${Tom_ns}\n DESCRIPTION "Tom console application for TinyORM C++ library"\n HOMEPAGE_URL "https://www.tinyorm.org"\n LANGUAGES CXX\n VERSION ${TINY_VERSION}\n)\n\n# Tom command-line application\n# ---\n\nadd_executable(${Tom_target}\n main.cpp\n)\nadd_executable(${Tom_ns}::${Tom_target} ALIAS ${Tom_target})\n\n# Tom command-line application specific configuration\n# ---\n\nset_target_properties(${Tom_target}\n PROPERTIES\n C_VISIBILITY_PRESET "hidden"\n CXX_VISIBILITY_PRESET "hidden"\n VISIBILITY_INLINES_HIDDEN YES\n VERSION ${PROJECT_VERSION}\n)\n\ntarget_include_directories(${Tom_target}\n PRIVATE "$"\n)\n\n# Tom command-line application defines\n# ---\n\ntarget_compile_definitions(${Tom_target}\n PRIVATE\n PROJECT_TOM\n)\n\n# Windows resource and manifest files\n# ---\n\n# Find icons, tom/version.hpp, and Windows manifest file for MinGW\nif(CMAKE_SYSTEM_NAME STREQUAL "Windows")\n tiny_set_rc_flags("-I \\"${TinyOrmSourceDir}/tom/resources\\"")\nendif()\n\ninclude(TinyResourceAndManifest)\ntiny_resource_and_manifest(${Tom_target}\n OUTPUT_DIR "${TINY_BUILD_GENDIR}/tmp/"\n RESOURCES_DIR "${TinyOrmSourceDir}/tom/resources"\n)\n\n# Resolve and link dependencies\n# ---\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\n# Unconditional dependencies\ntarget_link_libraries(${Tom_target}\n PRIVATE\n # Never use versionless Qt targets\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)\n'})}),"\n",(0,s.jsx)(n.h3,{id:"build-migrations-cmake",children:"Build migrations"}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure ",(0,s.jsx)(n.code,{children:"tom"})," ",(0,s.jsx)(n.code,{children:"CMake"})," application. Don't forget to prepare the build environment with the ",(0,s.jsx)(n.a,{href:"/building/tinyorm#windows-prerequisites",children:(0,s.jsx)(n.code,{children:"qtenv6.ps1"})})," command if you are building with the ",(0,s.jsx)(n.code,{children:"MSVC"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../tom-builds-cmake/build-debug\n"})}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,c.OZ)(d.b)}/tom/tom" \`\n-B "${(0,c.OZ)(d.b)}/tom/tom-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.b)}/tmp/tom"`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cmake \\\n-S "${(0,c.OZ)(d.xj)}/tom/tom" \\\n-B "${(0,c.OZ)(d.xj)}/tom/tom-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.xj)}/tmp/tom"`})})]}),"\n",(0,s.jsx)(n.p,{children:"And build."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\n"})}),"\n",(0,s.jsx)(n.h3,{id:"execute-migrations-cmake",children:"Execute migrations"}),"\n",(0,s.jsxs)(n.p,{children:["Do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so ",(0,s.jsx)(n.code,{children:"tom"})," application can find it during execution, as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#tinyorm-on-path-cmake",children:"here"}),"."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`$env:Path = "${(0,c.OZ)(d.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,c.OZ)(d.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Execute ",(0,s.jsx)(n.code,{children:"tom"})," application."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:".\\tom.exe migrate:status\n"})})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./tom migrate:status\n"})})})]}),"\n",(0,s.jsx)(n.p,{children:"The output will look something like this."}),"\n",(0,s.jsx)("img",{src:i(53).A,alt:"Tom migrations - migrate:status command output",width:"660"}),"\n",(0,s.jsxs)(n.p,{children:["See also the ",(0,s.jsx)(n.a,{href:"#finish",children:"final thoughts"})," on how to verify the ",(0,s.jsx)(n.code,{children:"tom"})," executable file properties."]}),"\n",(0,s.jsx)(n.p,{children:"Happy migrating \ud83c\udf89\ud83d\udc4c"}),"\n",(0,s.jsx)(n.h2,{id:"migrations-with-qmake",children:"Migrations with qmake"}),"\n",(0,s.jsxs)(n.p,{children:["Create a folder for the ",(0,s.jsx)(n.code,{children:"qmake"})," build."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/tom\n\nmkdir tom-builds-qmake`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/tom\n\nmkdir tom-builds-qmake`})})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#source-code",children:(0,s.jsx)(n.code,{children:"source code"})})," is the same as for the ",(0,s.jsx)(n.code,{children:"Migrations with CMake"})," console application."]}),"\n",(0,s.jsx)(n.h3,{id:"qmake-project",children:"qmake project"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"tom.pro"})," qmake file with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd tom\nvim tom.pro\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,s.jsx)(n.code,{children:"vim"}),", press ",(0,s.jsx)("kbd",{children:"Shift"})," + ",(0,s.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='tom.pro'",children:"QT -= gui\n\nTEMPLATE = app\nTARGET = tom\n\nCONFIG *= cmdline\n\nDEFINES *= PROJECT_TOM\n\nSOURCES += $$PWD/main.cpp\n\n# Database migrations\ninclude($$PWD/database/migrations.pri)\n# Database seeders\ninclude($$PWD/database/seeders.pri)\n\n# Auto-configure TinyORM library for the migrations purposes \ud83d\udd25\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/tom.pri)\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["The exact ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," is crucial in this example because the paths to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," source and build folders are relative."]})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsx)(n.p,{children:"Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!"})}),"\n",(0,s.jsxs)(n.h4,{id:"auto-configure-using-qmakeconf-and-env",children:[(0,s.jsx)(n.code,{children:"Auto-configure"})," using ",(0,s.jsx)(n.code,{children:".qmake.conf"})," and ",(0,s.jsx)(n.code,{children:".env"})]}),"\n",(0,s.jsxs)(n.p,{children:["If you want to have properly configured ",(0,s.jsx)(n.code,{children:"DEFINES"})," (C preprocessor macros), have Qt headers marked as system headers, or eg. have properly set properties of an executable file such as version and description, then you need to specify a path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,s.jsx)(n.code,{children:".prf"})," files) which handle this correctly; this path is provided by the ",(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})," variable and can only be set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["Read the ",(0,s.jsx)(n.a,{href:"/building/tinyorm#consume-tinyorm-library-qmake",children:"Consume TinyOrm library (qmake)"})," section, as everything that is described in that section applies here as well."]})}),"\n",(0,s.jsxs)(n.p,{children:["Create the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file in the ",(0,s.jsx)(n.code,{children:"tom"})," application root folder with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)\n# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n# Path to the current build tree (used to guess the TinyORM build tree)\n#TINY_BUILD_TREE = $$shadowed($$PWD)\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Then, create a ",(0,s.jsx)("code",{children:".env.(win32|unix|mingw)"})," file in the ",(0,s.jsx)(n.code,{children:"tom"})," application root folder with the following content."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:".env.win32",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-windows\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n"})})}),(0,s.jsx)(l.A,{value:d.xj,label:".env.unix",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-linux\n\n# Use faster linker\nclang: CONFIG *= use_lld_linker\nelse: CONFIG *= use_gold_linker\n\n# Or use the mold linker\n#QMAKE_LFLAGS *= -fuse-ld=mold\n"})})}),(0,s.jsx)(l.A,{value:"mingw",label:".env.mingw",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_clang_64bit-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-mingw-dynamic\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n\n# Use faster linker (for both GCC and Clang)\n# CONFIG *= use_lld_linker does not work on MinGW\nQMAKE_LFLAGS *= -fuse-ld=lld\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["Don't forget to update the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," folder paths to your needs if you are not using the recommended ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:(0,s.jsx)(n.code,{children:"Folders structure"})}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually. Just comment out the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and uncomment the ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"})," in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can entirely avoid the ",(0,s.jsx)(n.code,{children:".env"})," files, just move the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," to the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," or remove it by help of ",(0,s.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," and set the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable at system level as is described in ",(0,s.jsx)(n.a,{href:"/building/tinyorm#set-up-vcpkg-environment",children:(0,s.jsx)(n.code,{children:"Set up vcpkg environment"})}),"."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["Configuring by the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," and ",(0,s.jsx)(n.code,{children:".env"})," files has one big advantage, which is that you don't have to modify the project files."]})}),"\n",(0,s.jsx)(n.h4,{id:"migrations-source-files",children:"Migrations source files"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"database/migrations.pri"})," file and paste the following code."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='database/migrations.pri'",children:"INCLUDEPATH *= $$PWD\n\nHEADERS += \\\n $$PWD/migrations/2014_10_12_000000_create_posts_table.hpp \\\n"})}),"\n",(0,s.jsx)(n.h4,{id:"seeders-source-files",children:"Seeders source files"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"database/seeders.pri"})," file and paste the following code."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='database/seeders.pri'",children:"INCLUDEPATH *= $$PWD\n\nHEADERS += \\\n $$PWD/seeders/databaseseeder.hpp \\\n"})}),"\n",(0,s.jsx)(n.h3,{id:"build-migrations-qmake",children:"Build migrations"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["I recommend creating a new ",(0,s.jsx)(n.code,{children:"Session"})," in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"})," as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#open-qtcreator-ide",children:"here"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["Now you can open the ",(0,s.jsx)(n.code,{children:"tom.pro"})," project in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This will open the ",(0,s.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,s.jsx)("img",{src:i(2394).A,alt:"tom - QtCreator - Configure Project",width:"760"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#qtcreator-default-build-directory",children:"here"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,s.jsx)("img",{src:i(6106).A,className:"no-blurry",alt:"tom - QtCreator - Build Settings",width:"760"}),"\n",(0,s.jsxs)(n.p,{children:["Disable ",(0,s.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,s.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,s.jsxs)(n.p,{children:["In the left sidebar open ",(0,s.jsx)(n.code,{children:"Dependencies"})," and check ",(0,s.jsx)(n.code,{children:"TinyORM"})," project and ",(0,s.jsx)(n.code,{children:"Synchronize configuration"}),", this setting ensures that the current project will be rebuilt correctly when the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library source code changes."]}),"\n",(0,s.jsxs)(n.p,{children:["Everything is ready to build, you can press ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,s.jsx)(n.h3,{id:"execute-migrations-qmake",children:"Execute migrations"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"QtCreator"})," takes care of all the necessary configurations, sets up the build environment correctly, and also prepends dependency libraries on the system path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux."]}),"\n",(0,s.jsxs)(n.p,{children:["The only thing you might want to change is to run the ",(0,s.jsx)(n.code,{children:"tom"})," application in the new terminal window. To do so, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open the ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Run"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Run Settings"}),", then in the ",(0,s.jsx)(n.code,{children:"Run"})," section select the ",(0,s.jsx)(n.code,{children:"Run in terminal"})," checkbox."]}),"\n",(0,s.jsxs)(n.p,{children:["You can also set the ",(0,s.jsx)(n.code,{children:"Command line arguments"})," in this ",(0,s.jsx)(n.code,{children:"Run"})," section, eg. the ",(0,s.jsx)(n.code,{children:"migrate:status"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["To execute the ",(0,s.jsx)(n.code,{children:"tom"})," application press ",(0,s.jsx)("kbd",{children:"Ctrl"})," + ",(0,s.jsx)("kbd",{children:"r"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The output will look ",(0,s.jsx)(n.strong,{children:"very similar"})," to this if you add more migrations."]}),"\n",(0,s.jsx)("img",{src:i(53).A,alt:"Tom migrations - migrate:status command output",width:"660"}),"\n",(0,s.jsx)(n.p,{children:"Happy migrating \ud83c\udf89\ud83d\udc4c"}),"\n",(0,s.jsx)(n.h2,{id:"finish",children:"Finish"}),"\n",(0,s.jsxs)(n.p,{children:["As the last thing, you can check that all the file properties were correctly set by the ",(0,s.jsx)(n.a,{href:"https://docs.microsoft.com/en-us/windows/win32/menurc/resource-compiler",children:(0,s.jsx)(n.code,{children:"rc"})})," compiler."]}),"\n",(0,s.jsxs)(n.p,{children:["Find the ",(0,s.jsx)(n.code,{children:"tom.exe"})," file and press ",(0,s.jsx)("kbd",{children:"Alt"})," + ",(0,s.jsx)("kbd",{children:"Enter"})," to open the file properties. To check the executable manifest you can use eg. the ",(0,s.jsx)(n.a,{href:"http://www.angusj.com/resourcehacker/",children:"Resource Hacker"}),"."]}),"\n",(0,s.jsx)("img",{src:i(4679).A,alt:"tom.exe file properties detail",width:"440"})]})}function j(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>r});i(6540);var s=i(4164);const t={tabItem:"tabItem_Ymn6"};var a=i(4848);function r(e){let{children:n,hidden:i,className:r}=e;return(0,a.jsx)("div",{role:"tabpanel",className:(0,s.A)(t.tabItem,r),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>v});var s=i(6540),t=i(4164),a=i(3104),r=i(6347),l=i(205),o=i(7485),d=i(1682),c=i(679);function h(e){return s.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:i}=e;return(0,s.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:s,default:t}}=e;return{value:n,label:i,attributes:s,default:t}}))}(i);return function(e){const n=(0,d.X)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function m(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function p(e){let{queryString:n=!1,groupId:i}=e;const t=(0,r.W6)(),a=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,o.aZ)(a),(0,s.useCallback)((e=>{if(!a)return;const n=new URLSearchParams(t.location.search);n.set(a,e),t.replace({...t.location,search:n.toString()})}),[a,t])]}function g(e){const{defaultValue:n,queryString:i=!1,groupId:t}=e,a=u(e),[r,o]=(0,s.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!m({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const s=i.find((e=>e.default))??i[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:n,tabValues:a}))),[d,h]=p({queryString:i,groupId:t}),[g,x]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[t,a]=(0,c.Dv)(i);return[t,(0,s.useCallback)((e=>{i&&a.set(e)}),[i,a])]}({groupId:t}),j=(()=>{const e=d??g;return m({value:e,tabValues:a})?e:null})();(0,l.A)((()=>{j&&o(j)}),[j]);return{selectedValue:r,selectValue:(0,s.useCallback)((e=>{if(!m({value:e,tabValues:a}))throw new Error(`Can't select invalid tab value=${e}`);o(e),h(e),x(e)}),[h,x,a]),tabValues:a}}var x=i(2303);const j={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=i(4848);function f(e){let{className:n,block:i,selectedValue:s,selectValue:r,tabValues:l}=e;const o=[],{blockElementScrollPositionUntilNextRender:d}=(0,a.a_)(),c=e=>{const n=e.currentTarget,i=o.indexOf(n),t=l[i].value;t!==s&&(d(n),r(t))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const i=o.indexOf(e.currentTarget)+1;n=o[i]??o[0];break}case"ArrowLeft":{const i=o.indexOf(e.currentTarget)-1;n=o[i]??o[o.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":i},n),children:l.map((e=>{let{value:n,label:i,attributes:a}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:e=>o.push(e),onKeyDown:h,onClick:c,...a,className:(0,t.A)("tabs__item",j.tabItem,a?.className,{"tabs__item--active":s===n}),children:i??n},n)}))})}function _(e){let{lazy:n,children:i,selectedValue:t}=e;const a=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=a.find((e=>e.props.value===t));return e?(0,s.cloneElement)(e,{className:"margin-top--md"}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:a.map(((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==t})))})}function T(e){const n=g(e);return(0,b.jsxs)("div",{className:(0,t.A)("tabs-container",j.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(_,{...n,...e})]})}function v(e){const n=(0,x.A)();return(0,b.jsx)(T,{...e,children:h(e.children)},String(n))}},7324:(e,n,i)=>{i.d(n,{$E:()=>x,A3:()=>b,CW:()=>j,Dx:()=>c,F4:()=>u,Fi:()=>d,J_:()=>v,LQ:()=>f,Lf:()=>y,OO:()=>t,Q7:()=>_,b:()=>l,cy:()=>o,gg:()=>p,kl:()=>m,os:()=>h,pW:()=>a,ux:()=>g,vf:()=>s,xj:()=>r,xt:()=>T});const s="shell",t="database",a="application",r="bash",l="pwsh",o="zsh",d="maria",c="mysql",h="postgres",u="sqlite",m="application",p="bash",g="pwsh",x="zsh",j="MariaDB",b="MySQL",f="PostgreSQL",_="SQLite",T="tinyorm.org",v="$HOME/Code/c/",y="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>a});var s=i(6540),t=i(1838);function a(){const e=(0,s.useContext)(t.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>o,Sn:()=>r,T3:()=>c,bw:()=>d,nC:()=>h,np:()=>l});var s=i(6362),t=i(2303),a=i(7324);const r=function(e,n){return void 0===n&&(n=!0),u((0,s.A)().rootFolder[e]??d(e),e,n)},l=()=>(0,s.A)().rootFolder[a.pW]??d(a.pW),o=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==a.b?"/":"\\";return u(r(e)+i+l(),e,n)};function d(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,t.A)())return"";switch(e){case a.b:return a.Lf;case a.xj:return a.J_;case a.pW:return a.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===a.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case a.b:return p(n).replace(/\$env:(.+?)(\/.*)/,i);case a.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function u(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==a.b)return m(e);const s=m(e);return i?p(s):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(s)}function m(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function p(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},6106:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-build_settings-e10927d1c4ed852620f9eb7564198940.png"},2394:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-configure_project-4721257090370204b0272d166512adef.png"},4679:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/tom_file_properties-0df513c47ceadd5c09165e41c6b53086.png"},53:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/tom_migrate_status-63c129a10bfe6bffe8d2d5ea280860e5.png"}}]); \ No newline at end of file diff --git a/assets/js/8a8faf8d.d4ae9a8c.js b/assets/js/8a8faf8d.d4ae9a8c.js new file mode 100644 index 000000000..658412f68 --- /dev/null +++ b/assets/js/8a8faf8d.d4ae9a8c.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[129],{6455:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>u,default:()=>j,frontMatter:()=>h,metadata:()=>m,toc:()=>g});var s=i(4848),t=i(8453),a=i(8774),r=i(2364),l=i(9365),o=i(1470),d=i(7324),c=i(6694);const h={sidebar_position:3,sidebar_label:"Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",keywords:["c++ orm","building","migrations","tinyorm"]},u="Building: Migrations",m={id:"building/migrations",title:"Building: Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",source:"@site/docs/building/migrations.mdx",sourceDirName:"building",slug:"/building/migrations",permalink:"/building/migrations",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Migrations",description:"How to compile the TinyORM migrations (tom) C++ console application on Windows and Linux.",keywords:["c++ orm","building","migrations","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Hello world",permalink:"/building/hello-world"},next:{title:"\ud83d\udea9 Stability",permalink:"/stability"}},p={},g=[{value:"Introduction",id:"introduction",level:2},{value:"Install dependencies",id:"install-dependencies",level:2},{value:"Using vcpkg.json (manifest mode)",id:"using-vcpkg-json-manifest-mode",level:4},{value:"Using vcpkg install (manually)",id:"using-vcpkg-install-manually",level:4},{value:"Source code",id:"source-code",level:2},{value:"Main file",id:"main-file",level:3},{value:"Migrations",id:"migrations",level:3},{value:"Seeders",id:"seeders",level:3},{value:"Migrations with CMake",id:"migrations-with-cmake",level:2},{value:"CMake project",id:"cmake-project",level:3},{value:"Build migrations",id:"build-migrations-cmake",level:3},{value:"Execute migrations",id:"execute-migrations-cmake",level:3},{value:"Migrations with qmake",id:"migrations-with-qmake",level:2},{value:"qmake project",id:"qmake-project",level:3},{value:"Auto-configure using .qmake.conf and .env",id:"auto-configure-using-qmakeconf-and-env",level:4},{value:"Migrations source files",id:"migrations-source-files",level:4},{value:"Seeders source files",id:"seeders-source-files",level:4},{value:"Build migrations",id:"build-migrations-qmake",level:3},{value:"Execute migrations",id:"execute-migrations-qmake",level:3},{value:"Finish",id:"finish",level:2}];function x(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"building-migrations",children:"Building: Migrations"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#using-vcpkg-json-manifest-mode",children:"Using vcpkg.json"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#using-vcpkg-install-manually",children:"Using vcpkg install"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#source-code",children:"Source code"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#main-file",children:"Main file"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#migrations",children:"Migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#seeders",children:"Seeders"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#migrations-with-cmake",children:"Migrations with CMake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#cmake-project",children:"CMake project"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#build-migrations-cmake",children:"Build migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#execute-migrations-cmake",children:"Execute migrations"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"#migrations-with-qmake",children:"Migrations with qmake"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#qmake-project",children:"qmake project"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#build-migrations-qmake",children:"Build migrations"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#execute-migrations-qmake",children:"Execute migrations"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"#finish",children:"Finish"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--success",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,s.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,s.jsxs)(n.p,{children:["We will try to create a working migrations console application called as ",(0,s.jsx)("abbr",{title:"TinyORM migrations",children:(0,s.jsx)(n.code,{children:"tom"})})," in the terminal with the ",(0,s.jsx)(n.code,{children:"CMake"})," and in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"})," with the ",(0,s.jsx)(n.code,{children:"qmake"})," build systems."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tom"})," console application also expects the following ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"}),", let's create them."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}\nmkdir tom/tom\ncd tom`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}\nmkdir -p tom/tom\ncd tom`})})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.code,{children:"tom"})," example application, you can inspire or look at the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/examples/tom",children:"source code"}),". Also, ",(0,s.jsx)(n.code,{children:"TinyORM"})," unit tests use a ",(0,s.jsx)(n.code,{children:"tom"})," migrations internally to create the database structure, internally called as the ",(0,s.jsxs)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/tests/testdata_tom",children:[(0,s.jsx)(n.code,{children:"tom"})," migrations for unit tests"]}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["All these three console applications the ",(0,s.jsx)(n.code,{children:"tom"})," example, ",(0,s.jsx)(n.code,{children:"tom"})," migrations for unit tests, and the application described in this tutorial have practically identical source code (the main.cpp file)."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"tom"})," is able to generate ",(0,s.jsx)("a",{href:"https://en.wikipedia.org/wiki/Data_definition_language",title:"Data Definition Language",children:"DDL"})," queries for all the ",(0,s.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"})," databases."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["You can see the ",(0,s.jsx)(n.a,{href:"/features-summary#tom-console-application",children:"Tom showcase image"})," of how the resulting ",(0,s.jsx)(n.code,{children:"tom"})," console application will look like."]})}),"\n",(0,s.jsx)(n.h2,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,s.jsxs)(n.p,{children:["First, install the ",(0,s.jsx)(n.code,{children:"vcpkg"})," package manager as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#vcpkg",children:"here"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," libraries are required dependencies because ",(0,s.jsx)(n.code,{children:"TinyORM"})," uses them in header files, you have to install them before you can use ",(0,s.jsx)(n.code,{children:"TinyORM"}),". The ",(0,s.jsx)(n.code,{children:"tabulate"})," library is only needed in the ",(0,s.jsx)(n.code,{children:"tom"})," migrations it's used by the ",(0,s.jsx)(n.code,{children:"migrate:status"})," command."]}),"\n",(0,s.jsxs)(n.p,{children:["There are two ways how to install the ",(0,s.jsx)(n.code,{children:"range-v3"})," and ",(0,s.jsx)(n.code,{children:"tabulate"})," libraries using ",(0,s.jsx)(n.code,{children:"vcpkg"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Also, don't forget to build the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library with the ",(0,s.jsx)(n.code,{children:"tom"})," source code enabled (it's enabled by default) as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm",children:"here"}),"."]}),"\n",(0,s.jsxs)(n.h4,{id:"using-vcpkg-json-manifest-mode",children:["Using vcpkg.json ",(0,s.jsx)("small",{children:"(manifest mode)"})]}),"\n",(0,s.jsxs)(n.p,{children:["Create a ",(0,s.jsx)(n.code,{children:"vcpkg.json"})," file with the following content. ",(0,s.jsx)(n.code,{children:"CMake"})," example below uses this method."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd tom\nvim vcpkg.json\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:"title='vcpkg.json'",children:'{\n "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",\n "name": "tom",\n "version-semver": "0.1.0",\n "maintainers": "Silver Zachara ",\n "description": "Tom console application for TinyORM C++ library",\n "homepage": "https://github.com/silverqx/TinyORM",\n "documentation": "https://www.tinyorm.org/building/migrations",\n "supports": "!(uwp | arm | android | emscripten | osx | ios | xbox | freebsd | openbsd | wasm32)",\n "dependencies": [\n "range-v3",\n "tabulate"\n ]\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["Only ",(0,s.jsx)(n.code,{children:"CMake"})," via the ",(0,s.jsx)(n.code,{children:"toolchain file"})," supports this method."]})}),"\n",(0,s.jsxs)(n.h4,{id:"using-vcpkg-install-manually",children:["Using vcpkg install ",(0,s.jsx)("small",{children:"(manually)"})]}),"\n",(0,s.jsxs)(n.p,{children:["This method can be used with both ",(0,s.jsx)(n.code,{children:"CMake"})," and ",(0,s.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,s.jsx)(n.h2,{id:"source-code",children:"Source code"}),"\n",(0,s.jsxs)(n.p,{children:["Let's start in the ",(0,s.jsx)(n.code,{children:"tom"})," project folder."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/tom/tom`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/tom/tom`})})]}),"\n",(0,s.jsx)(n.h3,{id:"main-file",children:"Main file"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"main.cpp"})," source file."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"vim main.cpp\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,s.jsx)(n.code,{children:"vim"}),", press ",(0,s.jsx)("kbd",{children:"Shift"})," + ",(0,s.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(a.A,{id:"string-constants-example"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='main.cpp'",children:'#include \n\n#include \n\n#include "migrations/2014_10_12_000000_create_posts_table.hpp"\n\n#include "seeders/databaseseeder.hpp"\n\nusing Orm::DatabaseManager;\nusing Orm::DB;\n\nusing TomApplication = Tom::Application;\n\nusing namespace Migrations; // NOLINT(google-build-using-namespace)\nusing namespace Seeders; // NOLINT(google-build-using-namespace)\n\n/*! Create the database manager instance and add a database connection. */\nstd::shared_ptr setupDatabaseManager();\n\n/*! C++ main function. */\nint main(int argc, char *argv[])\n{\n try {\n // Ownership of the shared_ptr()\n auto db = setupDatabaseManager();\n\n return TomApplication(argc, argv, std::move(db), "TOM_EXAMPLE_ENV")\n .migrations()\n .seeders()\n // Fire it up \ud83d\udd25\ud83d\ude80\u2728\n .run();\n\n } catch (const std::exception &e) {\n\n TomApplication::logException(e);\n }\n\n return EXIT_FAILURE;\n}\n\nstd::shared_ptr setupDatabaseManager()\n{\n using namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n // Ownership of the shared_ptr()\n return DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_MYSQL_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_MYSQL_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_MYSQL_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_MYSQL_USERNAME", EMPTY)},\n {password_, qEnvironmentVariable("DB_MYSQL_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_MYSQL_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_MYSQL_COLLATION", UTF8MB40900aici)},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {strict_, true},\n },\n QStringLiteral("tinyorm_tom_mysql")); // shell:connection\n}\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["If you have defined more database connections then you can tag the lines with the database connection names with the ",(0,s.jsx)(n.code,{children:"// shell:connection"})," comment and this connection names will be provided to the bash, zsh, pwsh completions for the ",(0,s.jsx)(n.code,{children:"--database="})," option \ud83d\ude0e, ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/examples/tom/main.cpp#L76",children:"example"}),"."]})}),"\n",(0,s.jsx)(n.h3,{id:"migrations",children:"Migrations"}),"\n",(0,s.jsxs)(n.p,{children:["If you have already built the ",(0,s.jsx)(n.code,{children:"tom"})," application then you can generate a migrations using the ",(0,s.jsx)(n.a,{href:"/database/migrations#generating-migrations",children:(0,s.jsx)(n.code,{children:"make:migration"})})," command \ud83d\ude0e."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tom make:migration create_posts_table\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Below is the expected folders structure for the migrations. The ",(0,s.jsx)(n.a,{href:"#migrations-source-files",children:(0,s.jsx)(n.code,{children:"migrations.pri"})})," file is used only by the ",(0,s.jsx)(n.code,{children:"qmake"})," build system and is not needed with ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]}),"\n",(0,s.jsx)(a.A,{id:"folders-structure"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"tom/\n\u2514\u2500\u2500 database/\n \u251c\u2500\u2500 migrations/\n \u251c\u2500\u2500 seeders/\n \u251c\u2500\u2500 migrations.pri\n \u2514\u2500\u2500 seeders.pri\n"})}),"\n",(0,s.jsx)(n.p,{children:"Let's create the first migration manually."}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"mkdir database/migrations\n\nvim database/migrations/2014_10_12_000000_create_posts_table.hpp"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"mkdir -p database/migrations\n\nvim database/migrations/2014_10_12_000000_create_posts_table.hpp"})})]}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='database/migrations/2014_10_12_000000_create_posts_table.hpp'",children:'#pragma once\n\n#include \n\nnamespace Migrations\n{\n\n struct CreatePostsTable : Migration\n {\n /*! Filename of the migration file. */\n T_MIGRATION\n\n /*! Run the migrations. */\n void up() const override\n {\n Schema::create("posts", [](Blueprint &table)\n {\n table.id();\n\n table.string(NAME);\n table.timestamps();\n });\n }\n\n /*! Reverse the migrations. */\n void down() const override\n {\n Schema::dropIfExists("posts");\n }\n };\n\n} // namespace Migrations\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/database/migrations/2014_10_12_000000_create_posts_table.hpp#L5",children:(0,s.jsx)(n.code,{children:"CreatePostsTable"})})," example migration that also acts as the full-fledged example migration. It has defined and also nicely commented all possible features that migration classes can use or define."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["If you want, you can also build the ",(0,s.jsx)(n.code,{children:"tom"})," application without the migrations, simply comment out the ",(0,s.jsx)(n.code,{children:"migrations"})," method and the corresponding ",(0,s.jsx)(n.code,{children:'#include "migrations/xyz.hpp"'})," files."]})}),"\n",(0,s.jsx)(n.h3,{id:"seeders",children:"Seeders"}),"\n",(0,s.jsxs)(n.p,{children:["If you have already built the ",(0,s.jsx)(n.code,{children:"tom"})," application then you can generate a seeder using the ",(0,s.jsx)(n.a,{href:"/database/seeding#writing-seeders",children:(0,s.jsx)(n.code,{children:"make:seeder"})})," command \ud83d\ude0e."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"tom make:seeder PostSeeder\n"})}),"\n",(0,s.jsxs)(n.p,{children:["The expected folders structure is described a few paragraphs ",(0,s.jsx)(n.a,{href:"#folders-structure",children:"above"}),". The ",(0,s.jsx)(n.a,{href:"#seeders-source-files",children:(0,s.jsx)(n.code,{children:"seeders.pri"})})," file is used only by the ",(0,s.jsx)(n.code,{children:"qmake"})," build system and is not needed with ",(0,s.jsx)(n.code,{children:"CMake"})," builds."]}),"\n",(0,s.jsx)(n.p,{children:"Let's create the root seeder class manually."}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"mkdir database/seeders\n\nvim database/seeders/databaseseeder.hpp"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"mkdir -p database/seeders\n\nvim database/seeders/databaseseeder.hpp"})})]}),"\n",(0,s.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cpp",metastring:"title='database/seeders/databaseseeder.hpp'",children:'#pragma once\n\n#include \n\nnamespace Seeders\n{\n\n /*! Main database seeder. */\n struct DatabaseSeeder : Seeder\n {\n /*! Run the database seeders. */\n void run() override\n {\n DB::table("posts")->insert({\n {{"name", "1. post"}},\n {{"name", "2. post"}},\n });\n }\n };\n\n} // namespace Seeders\n'})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"TinyORM"})," source tree contains the ",(0,s.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/tests/database/seeders/databaseseeder.hpp#L8",children:(0,s.jsx)(n.code,{children:"DatabaseSeeder"})})," root seeder example class that also acts as the full-fledged example seeder. It has defined and also nicely commented all possible features that seeder classes can use or define."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can create more seeder classes like this and use the ",(0,s.jsx)(n.code,{children:"call<>()"})," method to invoke them as is described in the ",(0,s.jsx)(n.a,{href:"/database/seeding#calling-additional-seeders",children:"Calling Additional Seeders"})," section."]})}),"\n",(0,s.jsx)(n.h2,{id:"migrations-with-cmake",children:"Migrations with CMake"}),"\n",(0,s.jsxs)(n.p,{children:["Create a folder for the ",(0,s.jsx)(n.code,{children:"CMake"})," build."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:"cd ..\nmkdir tom-builds-cmake/build-debug\n\ncd tom"})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:"cd ..\nmkdir -p tom-builds-cmake/build-debug\n\ncd tom"})})]}),"\n",(0,s.jsx)(n.h3,{id:"cmake-project",children:"CMake project"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file with the following content. I leave the comments in the ",(0,s.jsx)(n.code,{children:"CMakeLists.txt"})," file because it's not as simple as the ",(0,s.jsx)(n.code,{children:"Hello world"})," example; to make it clear what's going on."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-cmake",metastring:"title='CMakeLists.txt'",children:'cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\n# Specify the C++ standard\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# Initialize variables\n# ---\n\nset(Tom_ns tom)\nset(Tom_target tom)\n\nfile(REAL_PATH "../../TinyORM" TinyMainDir)\n\nset(TinyOrmSourceDir "${TinyMainDir}/TinyORM")\nset(TinyOrmBuildDir "${TinyMainDir}/TinyORM-builds-cmake/build-debug")\n\n# TinyORM CMake modules (needed to set the executable version and RC file on Windows)\nlist(APPEND CMAKE_MODULE_PATH "${TinyOrmSourceDir}/cmake/CommonModules")\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${TinyOrmBuildDir}")\n\n# Initialize Project Version\n# ---\n\ninclude(TinyHelpers)\ntiny_read_version(TINY_VERSION\n TINY_VERSION_MAJOR TINY_VERSION_MINOR TINY_VERSION_PATCH TINY_VERSION_TWEAK\n VERSION_HEADER "${TinyOrmSourceDir}/tom/include/tom/version.hpp"\n PREFIX TINYTOM\n HEADER_FOR "${Tom_ns}"\n)\n\n# Basic project\n# ---\n\nproject(${Tom_ns}\n DESCRIPTION "Tom console application for TinyORM C++ library"\n HOMEPAGE_URL "https://www.tinyorm.org"\n LANGUAGES CXX\n VERSION ${TINY_VERSION}\n)\n\n# Tom command-line application\n# ---\n\nadd_executable(${Tom_target}\n main.cpp\n)\nadd_executable(${Tom_ns}::${Tom_target} ALIAS ${Tom_target})\n\n# Tom command-line application specific configuration\n# ---\n\nset_target_properties(${Tom_target}\n PROPERTIES\n C_VISIBILITY_PRESET "hidden"\n CXX_VISIBILITY_PRESET "hidden"\n VISIBILITY_INLINES_HIDDEN YES\n VERSION ${PROJECT_VERSION}\n)\n\ntarget_include_directories(${Tom_target}\n PRIVATE "$"\n)\n\n# Tom command-line application defines\n# ---\n\ntarget_compile_definitions(${Tom_target}\n PRIVATE\n PROJECT_TOM\n)\n\n# Windows resource and manifest files\n# ---\n\n# Find icons, tom/version.hpp, and Windows manifest file for MinGW\nif(CMAKE_SYSTEM_NAME STREQUAL "Windows")\n tiny_set_rc_flags("-I \\"${TinyOrmSourceDir}/tom/resources\\"")\nendif()\n\ninclude(TinyResourceAndManifest)\ntiny_resource_and_manifest(${Tom_target}\n OUTPUT_DIR "${TINY_BUILD_GENDIR}/tmp/"\n RESOURCES_DIR "${TinyOrmSourceDir}/tom/resources"\n)\n\n# Resolve and link dependencies\n# ---\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\n# Unconditional dependencies\ntarget_link_libraries(${Tom_target}\n PRIVATE\n # Never use versionless Qt targets\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)\n'})}),"\n",(0,s.jsx)(n.h3,{id:"build-migrations-cmake",children:"Build migrations"}),"\n",(0,s.jsxs)(n.p,{children:["Now you are ready to configure ",(0,s.jsx)(n.code,{children:"tom"})," ",(0,s.jsx)(n.code,{children:"CMake"})," application. Don't forget to prepare the build environment with the ",(0,s.jsx)(n.a,{href:"/building/tinyorm#windows-prerequisites",children:(0,s.jsx)(n.code,{children:"qtenv6.ps1"})})," command if you are building with the ",(0,s.jsx)(n.code,{children:"MSVC"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd ../tom-builds-cmake/build-debug\n"})}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,c.OZ)(d.b)}/tom/tom" \`\n-B "${(0,c.OZ)(d.b)}/tom/tom-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.b)}/tmp/tom"`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cmake \\\n-S "${(0,c.OZ)(d.xj)}/tom/tom" \\\n-B "${(0,c.OZ)(d.xj)}/tom/tom-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.xj)}/tmp/tom"`})})]}),"\n",(0,s.jsx)(n.p,{children:"And build."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\n"})}),"\n",(0,s.jsx)(n.h3,{id:"execute-migrations-cmake",children:"Execute migrations"}),"\n",(0,s.jsxs)(n.p,{children:["Do not forget to add ",(0,s.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so ",(0,s.jsx)(n.code,{children:"tom"})," application can find it during execution, as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#tinyorm-on-path-cmake",children:"here"}),"."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,name:"tinyorm-on-path",children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`$env:Path = "${(0,c.OZ)(d.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,c.OZ)(d.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,s.jsxs)(n.p,{children:["Execute ",(0,s.jsx)(n.code,{children:"tom"})," application."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:".\\tom.exe migrate:status\n"})})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./tom migrate:status\n"})})})]}),"\n",(0,s.jsx)(n.p,{children:"The output will look something like this."}),"\n",(0,s.jsx)("img",{src:i(53).A,alt:"Tom migrations - migrate:status command output",width:"660"}),"\n",(0,s.jsxs)(n.p,{children:["See also the ",(0,s.jsx)(n.a,{href:"#finish",children:"final thoughts"})," on how to verify the ",(0,s.jsx)(n.code,{children:"tom"})," executable file properties."]}),"\n",(0,s.jsx)(n.p,{children:"Happy migrating \ud83c\udf89\ud83d\udc4c"}),"\n",(0,s.jsx)(n.h2,{id:"migrations-with-qmake",children:"Migrations with qmake"}),"\n",(0,s.jsxs)(n.p,{children:["Create a folder for the ",(0,s.jsx)(n.code,{children:"qmake"})," build."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:d.ux,children:(0,s.jsx)(r.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/tom\n\nmkdir tom-builds-qmake`})}),(0,s.jsx)(l.A,{value:d.xj,label:d.gg,children:(0,s.jsx)(r.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/tom\n\nmkdir tom-builds-qmake`})})]}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.a,{href:"#source-code",children:(0,s.jsx)(n.code,{children:"source code"})})," is the same as for the ",(0,s.jsx)(n.code,{children:"Migrations with CMake"})," console application."]}),"\n",(0,s.jsx)(n.h3,{id:"qmake-project",children:"qmake project"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"tom.pro"})," qmake file with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd tom\nvim tom.pro\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,s.jsx)(n.code,{children:"vim"}),", press ",(0,s.jsx)("kbd",{children:"Shift"})," + ",(0,s.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='tom.pro'",children:"QT -= gui\n\nTEMPLATE = app\nTARGET = tom\n\nCONFIG *= cmdline\n\nDEFINES *= PROJECT_TOM\n\nSOURCES += $$PWD/main.cpp\n\n# Database migrations\ninclude($$PWD/database/migrations.pri)\n# Database seeders\ninclude($$PWD/database/seeders.pri)\n\n# Auto-configure TinyORM library for the migrations purposes \ud83d\udd25\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/tom.pri)\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:["The exact ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," is crucial in this example because the paths to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," source and build folders are relative."]})}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsx)(n.p,{children:"Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!"})}),"\n",(0,s.jsxs)(n.h4,{id:"auto-configure-using-qmakeconf-and-env",children:[(0,s.jsx)(n.code,{children:"Auto-configure"})," using ",(0,s.jsx)(n.code,{children:".qmake.conf"})," and ",(0,s.jsx)(n.code,{children:".env"})]}),"\n",(0,s.jsxs)(n.p,{children:["If you want to have properly configured ",(0,s.jsx)(n.code,{children:"DEFINES"})," (C preprocessor macros), have Qt headers marked as system headers, or eg. have properly set properties of an executable file such as version and description, then you need to specify a path to the ",(0,s.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,s.jsx)(n.code,{children:".prf"})," files) which handle this correctly; this path is provided by the ",(0,s.jsx)(n.code,{children:"QMAKEFEATURES"})," variable and can only be set in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["Read the ",(0,s.jsx)(n.a,{href:"/building/tinyorm#consume-tinyorm-library-qmake",children:"Consume TinyOrm library (qmake)"})," section, as everything that is described in that section applies here as well."]})}),"\n",(0,s.jsxs)(n.p,{children:["Create the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file in the ",(0,s.jsx)(n.code,{children:"tom"})," application root folder with the following content."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)\n# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n# Path to the current build tree (used to guess the TinyORM build tree)\n#TINY_BUILD_TREE = $$shadowed($$PWD)\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Then, create a ",(0,s.jsx)("code",{children:".env.(win32|unix|mingw)"})," file in the ",(0,s.jsx)(n.code,{children:"tom"})," application root folder with the following content."]}),"\n",(0,s.jsxs)(o.A,{groupId:d.vf,children:[(0,s.jsx)(l.A,{value:d.b,label:".env.win32",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-windows\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n"})})}),(0,s.jsx)(l.A,{value:d.xj,label:".env.unix",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-linux\n\n# Use faster linker\nclang: CONFIG *= use_lld_linker\nelse: CONFIG *= use_gold_linker\n\n# Or use the mold linker\n#QMAKE_LFLAGS *= -fuse-ld=mold\n"})})}),(0,s.jsx)(l.A,{value:"mingw",label:".env.mingw",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in the tom.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_clang_64bit-Debug/)\n\n# Path to the vcpkg - range-v3 and tabulate\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-mingw-dynamic\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n\n# Use faster linker (for both GCC and Clang)\n# CONFIG *= use_lld_linker does not work on MinGW\nQMAKE_LFLAGS *= -fuse-ld=lld\n"})})})]}),"\n",(0,s.jsxs)(n.p,{children:["Don't forget to update the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and ",(0,s.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," folder paths to your needs if you are not using the recommended ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:(0,s.jsx)(n.code,{children:"Folders structure"})}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["You can use the ",(0,s.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually. Just comment out the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and uncomment the ",(0,s.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"})," in the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can entirely avoid the ",(0,s.jsx)(n.code,{children:".env"})," files, just move the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," to the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," or remove it by help of ",(0,s.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,s.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," and set the ",(0,s.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable at system level as is described in ",(0,s.jsx)(n.a,{href:"/building/tinyorm#set-up-vcpkg-environment",children:(0,s.jsx)(n.code,{children:"Set up vcpkg environment"})}),"."]})}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsxs)(n.p,{children:["Configuring by the ",(0,s.jsx)(n.code,{children:".qmake.conf"})," and ",(0,s.jsx)(n.code,{children:".env"})," files has one big advantage, which is that you don't have to modify the project files."]})}),"\n",(0,s.jsx)(n.h4,{id:"migrations-source-files",children:"Migrations source files"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"database/migrations.pri"})," file and paste the following code."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='database/migrations.pri'",children:"INCLUDEPATH *= $$PWD\n\nHEADERS += \\\n $$PWD/migrations/2014_10_12_000000_create_posts_table.hpp \\\n"})}),"\n",(0,s.jsx)(n.h4,{id:"seeders-source-files",children:"Seeders source files"}),"\n",(0,s.jsxs)(n.p,{children:["Create ",(0,s.jsx)(n.code,{children:"database/seeders.pri"})," file and paste the following code."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-qmake",metastring:"title='database/seeders.pri'",children:"INCLUDEPATH *= $$PWD\n\nHEADERS += \\\n $$PWD/seeders/databaseseeder.hpp \\\n"})}),"\n",(0,s.jsx)(n.h3,{id:"build-migrations-qmake",children:"Build migrations"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["I recommend creating a new ",(0,s.jsx)(n.code,{children:"Session"})," in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"})," as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#open-qtcreator-ide",children:"here"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["Now you can open the ",(0,s.jsx)(n.code,{children:"tom.pro"})," project in the ",(0,s.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["This will open the ",(0,s.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,s.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,s.jsx)("img",{src:i(2394).A,alt:"tom - QtCreator - Configure Project",width:"760"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["You can force the ",(0,s.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,s.jsx)(n.a,{href:"/building/tinyorm#qtcreator-default-build-directory",children:"here"}),"."]})}),"\n",(0,s.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,s.jsx)("img",{src:i(6106).A,className:"no-blurry",alt:"tom - QtCreator - Build Settings",width:"760"}),"\n",(0,s.jsxs)(n.p,{children:["Disable ",(0,s.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,s.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,s.jsxs)(n.p,{children:["In the left sidebar open ",(0,s.jsx)(n.code,{children:"Dependencies"})," and check ",(0,s.jsx)(n.code,{children:"TinyORM"})," project and ",(0,s.jsx)(n.code,{children:"Synchronize configuration"}),", this setting ensures that the current project will be rebuilt correctly when the ",(0,s.jsx)(n.code,{children:"TinyORM"})," library source code changes."]}),"\n",(0,s.jsxs)(n.p,{children:["Everything is ready to build, you can press ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,s.jsx)(n.h3,{id:"execute-migrations-qmake",children:"Execute migrations"}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"QtCreator"})," takes care of all the necessary configurations, sets up the build environment correctly, and also prepends dependency libraries on the system path on Windows and on the ",(0,s.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux."]}),"\n",(0,s.jsxs)(n.p,{children:["The only thing you might want to change is to run the ",(0,s.jsx)(n.code,{children:"tom"})," application in the new terminal window. To do so, hit ",(0,s.jsx)("kbd",{children:"Ctrl"}),"+",(0,s.jsx)("kbd",{children:"5"})," to open the ",(0,s.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,s.jsx)(n.code,{children:"Run"})," in the left sidebar to open the ",(0,s.jsx)(n.code,{children:"Run Settings"}),", then in the ",(0,s.jsx)(n.code,{children:"Run"})," section select the ",(0,s.jsx)(n.code,{children:"Run in terminal"})," checkbox."]}),"\n",(0,s.jsxs)(n.p,{children:["You can also set the ",(0,s.jsx)(n.code,{children:"Command line arguments"})," in this ",(0,s.jsx)(n.code,{children:"Run"})," section, eg. the ",(0,s.jsx)(n.code,{children:"migrate:status"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["To execute the ",(0,s.jsx)(n.code,{children:"tom"})," application press ",(0,s.jsx)("kbd",{children:"Ctrl"})," + ",(0,s.jsx)("kbd",{children:"r"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["The output will look ",(0,s.jsx)(n.strong,{children:"very similar"})," to this if you add more migrations."]}),"\n",(0,s.jsx)("img",{src:i(53).A,alt:"Tom migrations - migrate:status command output",width:"660"}),"\n",(0,s.jsx)(n.p,{children:"Happy migrating \ud83c\udf89\ud83d\udc4c"}),"\n",(0,s.jsx)(n.h2,{id:"finish",children:"Finish"}),"\n",(0,s.jsxs)(n.p,{children:["As the last thing, you can check that all the file properties were correctly set by the ",(0,s.jsx)(n.a,{href:"https://docs.microsoft.com/en-us/windows/win32/menurc/resource-compiler",children:(0,s.jsx)(n.code,{children:"rc"})})," compiler."]}),"\n",(0,s.jsxs)(n.p,{children:["Find the ",(0,s.jsx)(n.code,{children:"tom.exe"})," file and press ",(0,s.jsx)("kbd",{children:"Alt"})," + ",(0,s.jsx)("kbd",{children:"Enter"})," to open the file properties. To check the executable manifest you can use eg. the ",(0,s.jsx)(n.a,{href:"http://www.angusj.com/resourcehacker/",children:"Resource Hacker"}),"."]}),"\n",(0,s.jsx)("img",{src:i(4679).A,alt:"tom.exe file properties detail",width:"440"})]})}function j(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}},9365:(e,n,i)=>{i.d(n,{A:()=>r});i(6540);var s=i(4164);const t={tabItem:"tabItem_Ymn6"};var a=i(4848);function r(e){let{children:n,hidden:i,className:r}=e;return(0,a.jsx)("div",{role:"tabpanel",className:(0,s.A)(t.tabItem,r),hidden:i,children:n})}},1470:(e,n,i)=>{i.d(n,{A:()=>v});var s=i(6540),t=i(4164),a=i(3104),r=i(6347),l=i(205),o=i(7485),d=i(1682),c=i(679);function h(e){return s.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:i}=e;return(0,s.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:i,attributes:s,default:t}}=e;return{value:n,label:i,attributes:s,default:t}}))}(i);return function(e){const n=(0,d.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,i])}function m(e){let{value:n,tabValues:i}=e;return i.some((e=>e.value===n))}function p(e){let{queryString:n=!1,groupId:i}=e;const t=(0,r.W6)(),a=function(e){let{queryString:n=!1,groupId:i}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!i)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return i??null}({queryString:n,groupId:i});return[(0,o.aZ)(a),(0,s.useCallback)((e=>{if(!a)return;const n=new URLSearchParams(t.location.search);n.set(a,e),t.replace({...t.location,search:n.toString()})}),[a,t])]}function g(e){const{defaultValue:n,queryString:i=!1,groupId:t}=e,a=u(e),[r,o]=(0,s.useState)((()=>function(e){let{defaultValue:n,tabValues:i}=e;if(0===i.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!m({value:n,tabValues:i}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${i.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const s=i.find((e=>e.default))??i[0];if(!s)throw new Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:n,tabValues:a}))),[d,h]=p({queryString:i,groupId:t}),[g,x]=function(e){let{groupId:n}=e;const i=function(e){return e?`docusaurus.tab.${e}`:null}(n),[t,a]=(0,c.Dv)(i);return[t,(0,s.useCallback)((e=>{i&&a.set(e)}),[i,a])]}({groupId:t}),j=(()=>{const e=d??g;return m({value:e,tabValues:a})?e:null})();(0,l.A)((()=>{j&&o(j)}),[j]);return{selectedValue:r,selectValue:(0,s.useCallback)((e=>{if(!m({value:e,tabValues:a}))throw new Error(`Can't select invalid tab value=${e}`);o(e),h(e),x(e)}),[h,x,a]),tabValues:a}}var x=i(2303);const j={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=i(4848);function f(e){let{className:n,block:i,selectedValue:s,selectValue:r,tabValues:l}=e;const o=[],{blockElementScrollPositionUntilNextRender:d}=(0,a.a_)(),c=e=>{const n=e.currentTarget,i=o.indexOf(n),t=l[i].value;t!==s&&(d(n),r(t))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const i=o.indexOf(e.currentTarget)+1;n=o[i]??o[0];break}case"ArrowLeft":{const i=o.indexOf(e.currentTarget)-1;n=o[i]??o[o.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":i},n),children:l.map((e=>{let{value:n,label:i,attributes:a}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:e=>o.push(e),onKeyDown:h,onClick:c,...a,className:(0,t.A)("tabs__item",j.tabItem,a?.className,{"tabs__item--active":s===n}),children:i??n},n)}))})}function _(e){let{lazy:n,children:i,selectedValue:a}=e;const r=(Array.isArray(i)?i:[i]).filter(Boolean);if(n){const e=r.find((e=>e.props.value===a));return e?(0,s.cloneElement)(e,{className:(0,t.A)("margin-top--md",e.props.className)}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:r.map(((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==a})))})}function T(e){const n=g(e);return(0,b.jsxs)("div",{className:(0,t.A)("tabs-container",j.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(_,{...n,...e})]})}function v(e){const n=(0,x.A)();return(0,b.jsx)(T,{...e,children:h(e.children)},String(n))}},7324:(e,n,i)=>{i.d(n,{$E:()=>x,A3:()=>b,CW:()=>j,Dx:()=>c,F4:()=>u,Fi:()=>d,J_:()=>v,LQ:()=>f,Lf:()=>y,OO:()=>t,Q7:()=>_,b:()=>l,cy:()=>o,gg:()=>p,kl:()=>m,os:()=>h,pW:()=>a,ux:()=>g,vf:()=>s,xj:()=>r,xt:()=>T});const s="shell",t="database",a="application",r="bash",l="pwsh",o="zsh",d="maria",c="mysql",h="postgres",u="sqlite",m="application",p="bash",g="pwsh",x="zsh",j="MariaDB",b="MySQL",f="PostgreSQL",_="SQLite",T="tinyorm.org",v="$HOME/Code/c/",y="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,i)=>{i.d(n,{A:()=>a});var s=i(6540),t=i(1838);function a(){const e=(0,s.useContext)(t.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,i)=>{i.d(n,{OZ:()=>o,Sn:()=>r,T3:()=>c,bw:()=>d,nC:()=>h,np:()=>l});var s=i(6362),t=i(2303),a=i(7324);const r=function(e,n){return void 0===n&&(n=!0),u((0,s.A)().rootFolder[e]??d(e),e,n)},l=()=>(0,s.A)().rootFolder[a.pW]??d(a.pW),o=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const i=n||e!==a.b?"/":"\\";return u(r(e)+i+l(),e,n)};function d(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,t.A)())return"";switch(e){case a.b:return a.Lf;case a.xj:return a.J_;case a.pW:return a.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===a.pW}function h(e,n){if(null==n||""===n)return n;const i="$ENV{$1}$2";switch(e){case a.b:return p(n).replace(/\$env:(.+?)(\/.*)/,i);case a.xj:return n.replace(/\$(.+?)(\/.*)/,i);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function u(e,n,i){if(void 0===i&&(i=!0),null==e||""===e)return e;if(n!==a.b)return m(e);const s=m(e);return i?p(s):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(s)}function m(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function p(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},6106:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-build_settings-e10927d1c4ed852620f9eb7564198940.png"},2394:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/qmake-configure_project-4721257090370204b0272d166512adef.png"},4679:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/tom_file_properties-0df513c47ceadd5c09165e41c6b53086.png"},53:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/tom_migrate_status-63c129a10bfe6bffe8d2d5ea280860e5.png"}}]); \ No newline at end of file diff --git a/assets/js/a4d3e054.6b43ed91.js b/assets/js/a4d3e054.6b43ed91.js new file mode 100644 index 000000000..cc6f291ee --- /dev/null +++ b/assets/js/a4d3e054.6b43ed91.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[755],{3696:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>a,default:()=>u,frontMatter:()=>t,metadata:()=>o,toc:()=>c});var d=n(4848),i=n(8453),r=n(8774);const t={sidebar_position:3,sidebar_label:"Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",keywords:["c++ orm","database","seeder","seeding","tinyorm"]},a="Database: Seeding",o={id:"database/seeding",title:"Database: Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",source:"@site/docs/database/seeding.mdx",sourceDirName:"database",slug:"/database/seeding",permalink:"/database/seeding",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",keywords:["c++ orm","database","seeder","seeding","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Migrations",permalink:"/database/migrations"},next:{title:"Getting Started",permalink:"/tinyorm/getting-started"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Writing Seeders",id:"writing-seeders",level:2},{value:"Calling Additional Seeders",id:"calling-additional-seeders",level:3},{value:"Call with additional arguments",id:"call-with-additional-arguments",level:4},{value:"Running Seeders",id:"running-seeders",level:2},{value:"Forcing Seeders To Run In Production",id:"forcing-seeders-to-run-in-production",level:4}];function h(e){const s={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.header,{children:(0,d.jsx)(s.h1,{id:"database-seeding",children:"Database: Seeding"})}),"\n",(0,d.jsxs)(s.ul,{children:["\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,d.jsxs)(s.li,{children:[(0,d.jsx)(s.a,{href:"#writing-seeders",children:"Writing Seeders"}),"\n",(0,d.jsxs)(s.ul,{children:["\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#calling-additional-seeders",children:"Calling Additional Seeders"})}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#running-seeders",children:"Running Seeders"})}),"\n"]}),"\n",(0,d.jsx)(s.h2,{id:"introduction",children:"Introduction"}),"\n",(0,d.jsx)("div",{className:"api-stability alert alert--success",children:(0,d.jsxs)(s.p,{children:[(0,d.jsx)(r.A,{to:"/stability#stability-indexes",children:(0,d.jsx)(s.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,d.jsxs)(s.p,{children:["TinyORM includes the ability to seed your database with data using seed classes. All seed classes should be stored in the ",(0,d.jsx)(s.code,{children:"database/seeders"})," directory. The ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class is considered as the root seeder. From this class, you may use the ",(0,d.jsx)(s.code,{children:"call"})," method to run other seed classes, allowing you to control the seeding order."]}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:[(0,d.jsx)(s.a,{href:"/tinyorm/getting-started#mass-assignment",children:"Mass assignment protection"})," is automatically disabled during database seeding."]})}),"\n",(0,d.jsx)(s.h2,{id:"writing-seeders",children:"Writing Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["To generate a seeder, execute the ",(0,d.jsx)(s.code,{children:"make:seeder"})," ",(0,d.jsx)(s.code,{children:"tom"})," command. A new seeder will be placed in the ",(0,d.jsx)(s.code,{children:"database/seeders"})," directory relative to the current ",(0,d.jsx)("abbr",{title:"Current working directory",children:"pwd"}),":"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom make:seeder UserSeeder\n"})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["You can omit the ",(0,d.jsx)(s.code,{children:"Seeder"})," word in the class name, ",(0,d.jsx)(s.code,{children:"tom"})," appends it for you."]})}),"\n",(0,d.jsxs)(s.p,{children:["A seeder class only contains one method by default: ",(0,d.jsx)(s.code,{children:"run"}),". This method is called when the ",(0,d.jsx)(s.code,{children:"db:seed"})," tom command is executed. Within the ",(0,d.jsx)(s.code,{children:"run"})," method, you may insert data into your database however you wish. You may use the ",(0,d.jsx)(s.a,{href:"/database/query-builder#insert-statements",children:"query builder"})," to manually insert data."]}),"\n",(0,d.jsxs)(s.p,{children:["As an example, let's modify the default ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class and add a database insert statement to the ",(0,d.jsx)(s.code,{children:"run"})," method:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nnamespace Seeders\n{\n\n /*! Main database seeder. */\n struct DatabaseSeeder : Seeder\n {\n /*! Run the database seeders. */\n void run() override\n {\n DB::table("users")->insert({"name", "email"},\n {\n {"1. user", "user1@example.com"},\n {"2. user", "user2@example.com"},\n });\n }\n };\n\n} // namespace Seeders\n'})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["The multi-insert ",(0,d.jsx)(s.a,{href:"/database/query-builder#multi-insert-overload",children:(0,d.jsx)(s.code,{children:"insert"})})," method overload is ideal for seeding data."]})}),"\n",(0,d.jsx)(s.h3,{id:"calling-additional-seeders",children:"Calling Additional Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["Within the ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class, you may use the ",(0,d.jsx)(s.code,{children:"call"})," method to execute additional seed classes. Using the ",(0,d.jsx)(s.code,{children:"call"})," method allows you to break up your database seeding into multiple files so that no single seeder class becomes too large. The ",(0,d.jsx)(s.code,{children:"call"})," method accepts the template parameter pack of seeder classes that should be executed:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:"/*! Run the database seeders. */\nvoid run() override\n{\n call();\n}\n"})}),"\n",(0,d.jsx)(s.h4,{id:"call-with-additional-arguments",children:"Call with additional arguments"}),"\n",(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"call"})," method allows to pass additional arguments to the seeder/s, but it has additional requirements."]}),"\n",(0,d.jsxs)(s.p,{children:["If you define a ",(0,d.jsx)(s.code,{children:"run"})," method without parameters then this method is called using the virtual dispatch (polymorphism) and in this case, you should use the ",(0,d.jsx)(s.code,{children:"override"})," specifier."]}),"\n",(0,d.jsxs)(s.p,{children:["If you define your ",(0,d.jsx)(s.code,{children:"run"})," method eg. like this ",(0,d.jsx)(s.code,{children:"run(bool shouldSeed)"})," or whatever parameters you want, then this method is called using the fold expression (virtual dispatch is not used in this case) so you can't use the ",(0,d.jsx)(s.code,{children:"override"})," specifier and you must call the ",(0,d.jsx)(s.code,{children:"call<>()"})," method with exactly the same arguments like the ",(0,d.jsx)(s.code,{children:"run"})," method was defined with, in our example, it should look like this ",(0,d.jsx)(s.code,{children:"call(true)"}),"."]}),"\n",(0,d.jsxs)(s.p,{children:["Let's demonstrate it on a small example, following is the ",(0,d.jsx)(s.code,{children:"run"})," method in the root ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class."]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:"/*! Run the database seeders. */\nvoid run() override\n{\n // This value can be based eg. on data from the database\n const auto shouldSeed = true;\n\n call(shouldSeed);\n}\n"})}),"\n",(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"run"})," method in the ",(0,d.jsx)(s.code,{children:"UserSeeder"})," class."]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:'/*! Run the database seeders. */\nvoid run(const bool shouldSeed)\n{\n if (!shouldSeed)\n return;\n\n DB::table("users")->insert({\n {"name", "1. user"},\n });\n}\n'})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"call"})," method provides two shortcut methods, ",(0,d.jsx)(s.code,{children:"callWith"})," and ",(0,d.jsx)(s.code,{children:"callSilent"})," (no output from seeders)."]})}),"\n",(0,d.jsx)(s.h2,{id:"running-seeders",children:"Running Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["You may execute the ",(0,d.jsx)(s.code,{children:"db:seed"})," tom command to seed your database. By default, the ",(0,d.jsx)(s.code,{children:"db:seed"})," command runs the ",(0,d.jsx)(s.code,{children:"Seeders::DatabaseSeeder"})," class, which may in turn invoke other seed classes. However, you may use the ",(0,d.jsx)(s.code,{children:"--class"})," option to specify a specific seeder class to run individually:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom db:seed\n\ntom db:seed --class=UserSeeder\n"})}),"\n",(0,d.jsxs)(s.p,{children:["You may also seed your database using the ",(0,d.jsx)(s.code,{children:"migrate"}),", ",(0,d.jsx)(s.code,{children:"migrate:fresh"})," or ",(0,d.jsx)(s.code,{children:"migrate:refresh"})," commands in combination with the ",(0,d.jsx)(s.code,{children:"--seed"})," option. For example the ",(0,d.jsx)(s.code,{children:"migrate:fresh"})," command drops all tables and re-run all of your migrations. This command is useful for completely re-building your database:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom migrate:fresh --seed\n"})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["You can change the default seeders path as is described in the ",(0,d.jsx)(s.a,{href:"/building/tinyorm#TINYTOM_SEEDERS_DIR",children:(0,d.jsx)(s.code,{children:"C preprocessor macros"})}),", CMake provides the ",(0,d.jsx)(s.a,{href:"/building/tinyorm#TOM_SEEDERS_DIR",children:(0,d.jsx)(s.code,{children:"TOM_SEEDERS_DIR"})})," option."]})}),"\n",(0,d.jsx)(s.h4,{id:"forcing-seeders-to-run-in-production",children:"Forcing Seeders To Run In Production"}),"\n",(0,d.jsxs)(s.p,{children:["Some seeding operations may cause you to alter or lose data. In order to protect you from running seeding commands against your production database, you will be prompted for confirmation before the seeders are executed in the ",(0,d.jsx)(s.code,{children:"production"})," environment. To force the seeders to run without a prompt, use the ",(0,d.jsx)(s.code,{children:"--force"})," flag:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom db:seed --force\n"})})]})}function u(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,d.jsx)(s,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}},8453:(e,s,n)=>{n.d(s,{R:()=>t,x:()=>a});var d=n(6540);const i={},r=d.createContext(i);function t(e){const s=d.useContext(r);return d.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function a(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:t(e.components),d.createElement(r.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a4d3e054.c5c4fcd6.js b/assets/js/a4d3e054.c5c4fcd6.js deleted file mode 100644 index 3168ec2a6..000000000 --- a/assets/js/a4d3e054.c5c4fcd6.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[755],{3696:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>a,default:()=>u,frontMatter:()=>r,metadata:()=>o,toc:()=>c});var d=n(4848),i=n(8453),t=n(8774);const r={sidebar_position:3,sidebar_label:"Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",keywords:["c++ orm","database","seeder","seeding","tinyorm"]},a="Database: Seeding",o={id:"database/seeding",title:"Database: Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",source:"@site/docs/database/seeding.mdx",sourceDirName:"database",slug:"/database/seeding",permalink:"/database/seeding",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3,sidebar_label:"Seeding",description:"TinyORM includes the ability to seed your database with data using seed classes. The DatabaseSeeder class is considered as the root seeder. From this class, you may use the `call` method to run other seed classes, allowing you to control the seeding order.",keywords:["c++ orm","database","seeder","seeding","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Migrations",permalink:"/database/migrations"},next:{title:"Getting Started",permalink:"/tinyorm/getting-started"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Writing Seeders",id:"writing-seeders",level:2},{value:"Calling Additional Seeders",id:"calling-additional-seeders",level:3},{value:"Call with additional arguments",id:"call-with-additional-arguments",level:4},{value:"Running Seeders",id:"running-seeders",level:2},{value:"Forcing Seeders To Run In Production",id:"forcing-seeders-to-run-in-production",level:4}];function h(e){const s={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.h1,{id:"database-seeding",children:"Database: Seeding"}),"\n",(0,d.jsxs)(s.ul,{children:["\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,d.jsxs)(s.li,{children:[(0,d.jsx)(s.a,{href:"#writing-seeders",children:"Writing Seeders"}),"\n",(0,d.jsxs)(s.ul,{children:["\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#calling-additional-seeders",children:"Calling Additional Seeders"})}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(s.li,{children:(0,d.jsx)(s.a,{href:"#running-seeders",children:"Running Seeders"})}),"\n"]}),"\n",(0,d.jsx)(s.h2,{id:"introduction",children:"Introduction"}),"\n",(0,d.jsx)("div",{class:"api-stability alert alert--success",children:(0,d.jsxs)(s.p,{children:[(0,d.jsx)(t.A,{to:"/stability#stability-indexes",children:(0,d.jsx)(s.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,d.jsxs)(s.p,{children:["TinyORM includes the ability to seed your database with data using seed classes. All seed classes should be stored in the ",(0,d.jsx)(s.code,{children:"database/seeders"})," directory. The ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class is considered as the root seeder. From this class, you may use the ",(0,d.jsx)(s.code,{children:"call"})," method to run other seed classes, allowing you to control the seeding order."]}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:[(0,d.jsx)(s.a,{href:"/tinyorm/getting-started#mass-assignment",children:"Mass assignment protection"})," is automatically disabled during database seeding."]})}),"\n",(0,d.jsx)(s.h2,{id:"writing-seeders",children:"Writing Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["To generate a seeder, execute the ",(0,d.jsx)(s.code,{children:"make:seeder"})," ",(0,d.jsx)(s.code,{children:"tom"})," command. A new seeder will be placed in the ",(0,d.jsx)(s.code,{children:"database/seeders"})," directory relative to the current ",(0,d.jsx)("abbr",{title:"Current working directory",children:"pwd"}),":"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom make:seeder UserSeeder\n"})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["You can omit the ",(0,d.jsx)(s.code,{children:"Seeder"})," word in the class name, ",(0,d.jsx)(s.code,{children:"tom"})," appends it for you."]})}),"\n",(0,d.jsxs)(s.p,{children:["A seeder class only contains one method by default: ",(0,d.jsx)(s.code,{children:"run"}),". This method is called when the ",(0,d.jsx)(s.code,{children:"db:seed"})," tom command is executed. Within the ",(0,d.jsx)(s.code,{children:"run"})," method, you may insert data into your database however you wish. You may use the ",(0,d.jsx)(s.a,{href:"/database/query-builder#insert-statements",children:"query builder"})," to manually insert data."]}),"\n",(0,d.jsxs)(s.p,{children:["As an example, let's modify the default ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class and add a database insert statement to the ",(0,d.jsx)(s.code,{children:"run"})," method:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:'#pragma once\n\n#include \n\nnamespace Seeders\n{\n\n /*! Main database seeder. */\n struct DatabaseSeeder : Seeder\n {\n /*! Run the database seeders. */\n void run() override\n {\n DB::table("users")->insert({"name", "email"},\n {\n {"1. user", "user1@example.com"},\n {"2. user", "user2@example.com"},\n });\n }\n };\n\n} // namespace Seeders\n'})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["The multi-insert ",(0,d.jsx)(s.a,{href:"/database/query-builder#multi-insert-overload",children:(0,d.jsx)(s.code,{children:"insert"})})," method overload is ideal for seeding data."]})}),"\n",(0,d.jsx)(s.h3,{id:"calling-additional-seeders",children:"Calling Additional Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["Within the ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class, you may use the ",(0,d.jsx)(s.code,{children:"call"})," method to execute additional seed classes. Using the ",(0,d.jsx)(s.code,{children:"call"})," method allows you to break up your database seeding into multiple files so that no single seeder class becomes too large. The ",(0,d.jsx)(s.code,{children:"call"})," method accepts the template parameter pack of seeder classes that should be executed:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:"/*! Run the database seeders. */\nvoid run() override\n{\n call();\n}\n"})}),"\n",(0,d.jsx)(s.h4,{id:"call-with-additional-arguments",children:"Call with additional arguments"}),"\n",(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"call"})," method allows to pass additional arguments to the seeder/s, but it has additional requirements."]}),"\n",(0,d.jsxs)(s.p,{children:["If you define a ",(0,d.jsx)(s.code,{children:"run"})," method without parameters then this method is called using the virtual dispatch (polymorphism) and in this case, you should use the ",(0,d.jsx)(s.code,{children:"override"})," specifier."]}),"\n",(0,d.jsxs)(s.p,{children:["If you define your ",(0,d.jsx)(s.code,{children:"run"})," method eg. like this ",(0,d.jsx)(s.code,{children:"run(bool shouldSeed)"})," or whatever parameters you want, then this method is called using the fold expression (virtual dispatch is not used in this case) so you can't use the ",(0,d.jsx)(s.code,{children:"override"})," specifier and you must call the ",(0,d.jsx)(s.code,{children:"call<>()"})," method with exactly the same arguments like the ",(0,d.jsx)(s.code,{children:"run"})," method was defined with, in our example, it should look like this ",(0,d.jsx)(s.code,{children:"call(true)"}),"."]}),"\n",(0,d.jsxs)(s.p,{children:["Let's demonstrate it on a small example, following is the ",(0,d.jsx)(s.code,{children:"run"})," method in the root ",(0,d.jsx)(s.code,{children:"DatabaseSeeder"})," class."]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:"/*! Run the database seeders. */\nvoid run() override\n{\n // This value can be based eg. on data from the database\n const auto shouldSeed = true;\n\n call(shouldSeed);\n}\n"})}),"\n",(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"run"})," method in the ",(0,d.jsx)(s.code,{children:"UserSeeder"})," class."]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-cpp",children:'/*! Run the database seeders. */\nvoid run(const bool shouldSeed)\n{\n if (!shouldSeed)\n return;\n\n DB::table("users")->insert({\n {"name", "1. user"},\n });\n}\n'})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["The ",(0,d.jsx)(s.code,{children:"call"})," method provides two shortcut methods, ",(0,d.jsx)(s.code,{children:"callWith"})," and ",(0,d.jsx)(s.code,{children:"callSilent"})," (no output from seeders)."]})}),"\n",(0,d.jsx)(s.h2,{id:"running-seeders",children:"Running Seeders"}),"\n",(0,d.jsxs)(s.p,{children:["You may execute the ",(0,d.jsx)(s.code,{children:"db:seed"})," tom command to seed your database. By default, the ",(0,d.jsx)(s.code,{children:"db:seed"})," command runs the ",(0,d.jsx)(s.code,{children:"Seeders::DatabaseSeeder"})," class, which may in turn invoke other seed classes. However, you may use the ",(0,d.jsx)(s.code,{children:"--class"})," option to specify a specific seeder class to run individually:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom db:seed\n\ntom db:seed --class=UserSeeder\n"})}),"\n",(0,d.jsxs)(s.p,{children:["You may also seed your database using the ",(0,d.jsx)(s.code,{children:"migrate"}),", ",(0,d.jsx)(s.code,{children:"migrate:fresh"})," or ",(0,d.jsx)(s.code,{children:"migrate:refresh"})," commands in combination with the ",(0,d.jsx)(s.code,{children:"--seed"})," option. For example the ",(0,d.jsx)(s.code,{children:"migrate:fresh"})," command drops all tables and re-run all of your migrations. This command is useful for completely re-building your database:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom migrate:fresh --seed\n"})}),"\n",(0,d.jsx)(s.admonition,{type:"tip",children:(0,d.jsxs)(s.p,{children:["You can change the default seeders path as is described in the ",(0,d.jsx)(s.a,{href:"/building/tinyorm#TINYTOM_SEEDERS_DIR",children:(0,d.jsx)(s.code,{children:"C preprocessor macros"})}),", CMake provides the ",(0,d.jsx)(s.a,{href:"/building/tinyorm#TOM_SEEDERS_DIR",children:(0,d.jsx)(s.code,{children:"TOM_SEEDERS_DIR"})})," option."]})}),"\n",(0,d.jsx)(s.h4,{id:"forcing-seeders-to-run-in-production",children:"Forcing Seeders To Run In Production"}),"\n",(0,d.jsxs)(s.p,{children:["Some seeding operations may cause you to alter or lose data. In order to protect you from running seeding commands against your production database, you will be prompted for confirmation before the seeders are executed in the ",(0,d.jsx)(s.code,{children:"production"})," environment. To force the seeders to run without a prompt, use the ",(0,d.jsx)(s.code,{children:"--force"})," flag:"]}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-bash",children:"tom db:seed --force\n"})})]})}function u(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,d.jsx)(s,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}},8453:(e,s,n)=>{n.d(s,{R:()=>r,x:()=>a});var d=n(6540);const i={},t=d.createContext(i);function r(e){const s=d.useContext(t);return d.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function a(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),d.createElement(t.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a7bd4aaa.80cc43c0.js b/assets/js/a7bd4aaa.80cc43c0.js deleted file mode 100644 index 35df6a3ba..000000000 --- a/assets/js/a7bd4aaa.80cc43c0.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[98],{4532:(n,e,s)=>{s.r(e),s.d(e,{default:()=>x});s(6540);var r=s(9024),o=s(2967),t=s(2252),i=s(2831),c=s(1463),u=s(4848);function a(n){const{version:e}=n;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.A,{version:e.version,tag:(0,o.tU)(e.pluginId,e.version)}),(0,u.jsx)(r.be,{children:e.noIndex&&(0,u.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})]})}function l(n){const{version:e,route:s}=n;return(0,u.jsx)(r.e3,{className:e.className,children:(0,u.jsx)(t.n,{version:e,children:(0,i.v)(s.routes)})})}function x(n){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a,{...n}),(0,u.jsx)(l,{...n})]})}}}]); \ No newline at end of file diff --git a/assets/js/a7bd4aaa.e71dd57d.js b/assets/js/a7bd4aaa.e71dd57d.js new file mode 100644 index 000000000..9382583cd --- /dev/null +++ b/assets/js/a7bd4aaa.e71dd57d.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[98],{4532:(n,e,s)=>{s.r(e),s.d(e,{default:()=>x});s(6540);var r=s(9024),o=s(2565),t=s(3025),i=s(2831),c=s(1463),u=s(4848);function a(n){const{version:e}=n;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.A,{version:e.version,tag:(0,o.k)(e.pluginId,e.version)}),(0,u.jsx)(r.be,{children:e.noIndex&&(0,u.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})]})}function l(n){const{version:e,route:s}=n;return(0,u.jsx)(r.e3,{className:e.className,children:(0,u.jsx)(t.n,{version:e,children:(0,i.v)(s.routes)})})}function x(n){return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a,{...n}),(0,u.jsx)(l,{...n})]})}}}]); \ No newline at end of file diff --git a/assets/js/a94703ab.2ad1c777.js b/assets/js/a94703ab.2ad1c777.js deleted file mode 100644 index 54c41b75b..000000000 --- a/assets/js/a94703ab.2ad1c777.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[48],{2559:(e,t,n)=>{n.r(t),n.d(t,{default:()=>be});var a=n(6540),o=n(4164),i=n(9024),s=n(7559),l=n(4142),r=n(6588),c=n(1312),d=n(3104),u=n(5062);const m={backToTopButton:"backToTopButton_sjWU",backToTopButtonShow:"backToTopButtonShow_xfvO"};var b=n(4848);function h(){const{shown:e,scrollToTop:t}=function(e){let{threshold:t}=e;const[n,o]=(0,a.useState)(!1),i=(0,a.useRef)(!1),{startScroll:s,cancelScroll:l}=(0,d.gk)();return(0,d.Mq)(((e,n)=>{let{scrollY:a}=e;const s=n?.scrollY;s&&(i.current?i.current=!1:a>=s?(l(),o(!1)):a{e.location.hash&&(i.current=!0,o(!1))})),{shown:n,scrollToTop:()=>s(0)}}({threshold:300});return(0,b.jsx)("button",{"aria-label":(0,c.T)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,o.A)("clean-btn",s.G.common.backToTopButton,m.backToTopButton,e&&m.backToTopButtonShow),type:"button",onClick:t})}var p=n(3109),x=n(6347),f=n(4581),j=n(6342),v=n(3465);function _(e){return(0,b.jsx)("svg",{width:"20",height:"20","aria-hidden":"true",...e,children:(0,b.jsxs)("g",{fill:"#7a7a7a",children:[(0,b.jsx)("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),(0,b.jsx)("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})]})})}const g={collapseSidebarButton:"collapseSidebarButton_PEFL",collapseSidebarButtonIcon:"collapseSidebarButtonIcon_kv0_"};function A(e){let{onClick:t}=e;return(0,b.jsx)("button",{type:"button",title:(0,c.T)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,o.A)("button button--secondary button--outline",g.collapseSidebarButton),onClick:t,children:(0,b.jsx)(_,{className:g.collapseSidebarButtonIcon})})}var k=n(5041),C=n(9532);const S=Symbol("EmptyContext"),T=a.createContext(S);function N(e){let{children:t}=e;const[n,o]=(0,a.useState)(null),i=(0,a.useMemo)((()=>({expandedItem:n,setExpandedItem:o})),[n]);return(0,b.jsx)(T.Provider,{value:i,children:t})}var I=n(1422),B=n(9169),y=n(8774),w=n(2303);function L(e){let{collapsed:t,categoryLabel:n,onClick:a}=e;return(0,b.jsx)("button",{"aria-label":t?(0,c.T)({id:"theme.DocSidebarItem.expandCategoryAriaLabel",message:"Expand sidebar category '{label}'",description:"The ARIA label to expand the sidebar category"},{label:n}):(0,c.T)({id:"theme.DocSidebarItem.collapseCategoryAriaLabel",message:"Collapse sidebar category '{label}'",description:"The ARIA label to collapse the sidebar category"},{label:n}),"aria-expanded":!t,type:"button",className:"clean-btn menu__caret",onClick:a})}function E(e){let{item:t,onItemClick:n,activePath:i,level:r,index:c,...d}=e;const{items:u,label:m,collapsible:h,className:p,href:x}=t,{docs:{sidebar:{autoCollapseCategories:f}}}=(0,j.p)(),v=function(e){const t=(0,w.A)();return(0,a.useMemo)((()=>e.href&&!e.linkUnlisted?e.href:!t&&e.collapsible?(0,l.Nr)(e):void 0),[e,t])}(t),_=(0,l.w8)(t,i),g=(0,B.ys)(x,i),{collapsed:A,setCollapsed:k}=(0,I.u)({initialState:()=>!!h&&(!_&&t.collapsed)}),{expandedItem:N,setExpandedItem:E}=function(){const e=(0,a.useContext)(T);if(e===S)throw new C.dV("DocSidebarItemsExpandedStateProvider");return e}(),M=function(e){void 0===e&&(e=!A),E(e?null:c),k(e)};return function(e){let{isActive:t,collapsed:n,updateCollapsed:o}=e;const i=(0,C.ZC)(t);(0,a.useEffect)((()=>{t&&!i&&n&&o(!1)}),[t,i,n,o])}({isActive:_,collapsed:A,updateCollapsed:M}),(0,a.useEffect)((()=>{h&&null!=N&&N!==c&&f&&k(!0)}),[h,N,c,k,f]),(0,b.jsxs)("li",{className:(0,o.A)(s.G.docs.docSidebarItemCategory,s.G.docs.docSidebarItemCategoryLevel(r),"menu__list-item",{"menu__list-item--collapsed":A},p),children:[(0,b.jsxs)("div",{className:(0,o.A)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":g}),children:[(0,b.jsx)(y.A,{className:(0,o.A)("menu__link",{"menu__link--sublist":h,"menu__link--sublist-caret":!x&&h,"menu__link--active":_}),onClick:h?e=>{n?.(t),x?M(!1):(e.preventDefault(),M())}:()=>{n?.(t)},"aria-current":g?"page":void 0,role:h&&!x?"button":void 0,"aria-expanded":h&&!x?!A:void 0,href:h?v??"#":v,...d,children:m}),x&&h&&(0,b.jsx)(L,{collapsed:A,categoryLabel:m,onClick:e=>{e.preventDefault(),M()}})]}),(0,b.jsx)(I.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:A,children:(0,b.jsx)(U,{items:u,tabIndex:A?-1:0,onItemClick:n,activePath:i,level:r+1})})]})}var M=n(6654),H=n(3186);const G={menuExternalLink:"menuExternalLink_NmtK"};function W(e){let{item:t,onItemClick:n,activePath:a,level:i,index:r,...c}=e;const{href:d,label:u,className:m,autoAddBaseUrl:h}=t,p=(0,l.w8)(t,a),x=(0,M.A)(d);return(0,b.jsx)("li",{className:(0,o.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(i),"menu__list-item",m),children:(0,b.jsxs)(y.A,{className:(0,o.A)("menu__link",!x&&G.menuExternalLink,{"menu__link--active":p}),autoAddBaseUrl:h,"aria-current":p?"page":void 0,to:d,...x&&{onClick:n?()=>n(t):void 0},...c,children:[u,!x&&(0,b.jsx)(H.A,{})]})},u)}const P={menuHtmlItem:"menuHtmlItem_M9Kj"};function R(e){let{item:t,level:n,index:a}=e;const{value:i,defaultStyle:l,className:r}=t;return(0,b.jsx)("li",{className:(0,o.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(n),l&&[P.menuHtmlItem,"menu__list-item"],r),dangerouslySetInnerHTML:{__html:i}},a)}function D(e){let{item:t,...n}=e;switch(t.type){case"category":return(0,b.jsx)(E,{item:t,...n});case"html":return(0,b.jsx)(R,{item:t,...n});default:return(0,b.jsx)(W,{item:t,...n})}}function F(e){let{items:t,...n}=e;const a=(0,l.Y)(t,n.activePath);return(0,b.jsx)(N,{children:a.map(((e,t)=>(0,b.jsx)(D,{item:e,index:t,...n},t)))})}const U=(0,a.memo)(F),V={menu:"menu_SIkG",menuWithAnnouncementBar:"menuWithAnnouncementBar_GW3s"};function Y(e){let{path:t,sidebar:n,className:i}=e;const l=function(){const{isActive:e}=(0,k.M)(),[t,n]=(0,a.useState)(e);return(0,d.Mq)((t=>{let{scrollY:a}=t;e&&n(0===a)}),[e]),e&&t}();return(0,b.jsx)("nav",{"aria-label":(0,c.T)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,o.A)("menu thin-scrollbar",V.menu,l&&V.menuWithAnnouncementBar,i),children:(0,b.jsx)("ul",{className:(0,o.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(U,{items:n,activePath:t,level:1})})})}const K="sidebar_njMd",z="sidebarWithHideableNavbar_wUlq",q="sidebarHidden_VK0M",O="sidebarLogo_isFc";function J(e){let{path:t,sidebar:n,onCollapse:a,isHidden:i}=e;const{navbar:{hideOnScroll:s},docs:{sidebar:{hideable:l}}}=(0,j.p)();return(0,b.jsxs)("div",{className:(0,o.A)(K,s&&z,i&&q),children:[s&&(0,b.jsx)(v.A,{tabIndex:-1,className:O}),(0,b.jsx)(Y,{path:t,sidebar:n}),l&&(0,b.jsx)(A,{onClick:a})]})}const Q=a.memo(J);var X=n(5600),Z=n(2069);const $=e=>{let{sidebar:t,path:n}=e;const a=(0,Z.M)();return(0,b.jsx)("ul",{className:(0,o.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(U,{items:t,activePath:n,onItemClick:e=>{"category"===e.type&&e.href&&a.toggle(),"link"===e.type&&a.toggle()},level:1})})};function ee(e){return(0,b.jsx)(X.GX,{component:$,props:e})}const te=a.memo(ee);function ne(e){const t=(0,f.l)(),n="desktop"===t||"ssr"===t,a="mobile"===t;return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)(Q,{...e}),a&&(0,b.jsx)(te,{...e})]})}const ae={expandButton:"expandButton_TmdG",expandButtonIcon:"expandButtonIcon_i1dp"};function oe(e){let{toggleSidebar:t}=e;return(0,b.jsx)("div",{className:ae.expandButton,title:(0,c.T)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:t,onClick:t,children:(0,b.jsx)(_,{className:ae.expandButtonIcon})})}const ie={docSidebarContainer:"docSidebarContainer_YfHR",docSidebarContainerHidden:"docSidebarContainerHidden_DPk8",sidebarViewport:"sidebarViewport_aRkj"};function se(e){let{children:t}=e;const n=(0,r.t)();return(0,b.jsx)(a.Fragment,{children:t},n?.name??"noSidebar")}function le(e){let{sidebar:t,hiddenSidebarContainer:n,setHiddenSidebarContainer:i}=e;const{pathname:l}=(0,x.zy)(),[r,c]=(0,a.useState)(!1),d=(0,a.useCallback)((()=>{r&&c(!1),!r&&(0,p.O)()&&c(!0),i((e=>!e))}),[i,r]);return(0,b.jsx)("aside",{className:(0,o.A)(s.G.docs.docSidebarContainer,ie.docSidebarContainer,n&&ie.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(ie.docSidebarContainer)&&n&&c(!0)},children:(0,b.jsx)(se,{children:(0,b.jsxs)("div",{className:(0,o.A)(ie.sidebarViewport,r&&ie.sidebarViewportHidden),children:[(0,b.jsx)(ne,{sidebar:t,path:l,onCollapse:d,isHidden:r}),r&&(0,b.jsx)(oe,{toggleSidebar:d})]})})})}const re={docMainContainer:"docMainContainer_TBSr",docMainContainerEnhanced:"docMainContainerEnhanced_lQrH",docItemWrapperEnhanced:"docItemWrapperEnhanced_JWYK"};function ce(e){let{hiddenSidebarContainer:t,children:n}=e;const a=(0,r.t)();return(0,b.jsx)("main",{className:(0,o.A)(re.docMainContainer,(t||!a)&&re.docMainContainerEnhanced),children:(0,b.jsx)("div",{className:(0,o.A)("container padding-top--md padding-bottom--lg",re.docItemWrapper,t&&re.docItemWrapperEnhanced),children:n})})}const de={docRoot:"docRoot_UBD9",docsWrapper:"docsWrapper_hBAB"};function ue(e){let{children:t}=e;const n=(0,r.t)(),[o,i]=(0,a.useState)(!1);return(0,b.jsxs)("div",{className:de.docsWrapper,children:[(0,b.jsx)(h,{}),(0,b.jsxs)("div",{className:de.docRoot,children:[n&&(0,b.jsx)(le,{sidebar:n.items,hiddenSidebarContainer:o,setHiddenSidebarContainer:i}),(0,b.jsx)(ce,{hiddenSidebarContainer:o,children:t})]})]})}var me=n(3363);function be(e){const t=(0,l.B5)(e);if(!t)return(0,b.jsx)(me.A,{});const{docElement:n,sidebarName:a,sidebarItems:c}=t;return(0,b.jsx)(i.e3,{className:(0,o.A)(s.G.page.docsDocPage),children:(0,b.jsx)(r.V,{name:a,items:c,children:(0,b.jsx)(ue,{children:n})})})}},3363:(e,t,n)=>{n.d(t,{A:()=>l});n(6540);var a=n(4164),o=n(1312),i=n(1107),s=n(4848);function l(e){let{className:t}=e;return(0,s.jsx)("main",{className:(0,a.A)("container margin-vert--xl",t),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(i.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}}}]); \ No newline at end of file diff --git a/assets/js/a94703ab.34d838b2.js b/assets/js/a94703ab.34d838b2.js new file mode 100644 index 000000000..fcc1dc82e --- /dev/null +++ b/assets/js/a94703ab.34d838b2.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[48],{1377:(e,t,n)=>{n.r(t),n.d(t,{default:()=>be});var a=n(6540),o=n(4164),i=n(9024),s=n(7559),l=n(6972),r=n(609),c=n(1312),d=n(3104),u=n(5062);const m={backToTopButton:"backToTopButton_sjWU",backToTopButtonShow:"backToTopButtonShow_xfvO"};var b=n(4848);function h(){const{shown:e,scrollToTop:t}=function(e){let{threshold:t}=e;const[n,o]=(0,a.useState)(!1),i=(0,a.useRef)(!1),{startScroll:s,cancelScroll:l}=(0,d.gk)();return(0,d.Mq)(((e,n)=>{let{scrollY:a}=e;const s=n?.scrollY;s&&(i.current?i.current=!1:a>=s?(l(),o(!1)):a{e.location.hash&&(i.current=!0,o(!1))})),{shown:n,scrollToTop:()=>s(0)}}({threshold:300});return(0,b.jsx)("button",{"aria-label":(0,c.T)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,o.A)("clean-btn",s.G.common.backToTopButton,m.backToTopButton,e&&m.backToTopButtonShow),type:"button",onClick:t})}var p=n(3109),x=n(6347),f=n(4581),j=n(6342),v=n(3465);function _(e){return(0,b.jsx)("svg",{width:"20",height:"20","aria-hidden":"true",...e,children:(0,b.jsxs)("g",{fill:"#7a7a7a",children:[(0,b.jsx)("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),(0,b.jsx)("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})]})})}const g={collapseSidebarButton:"collapseSidebarButton_PEFL",collapseSidebarButtonIcon:"collapseSidebarButtonIcon_kv0_"};function A(e){let{onClick:t}=e;return(0,b.jsx)("button",{type:"button",title:(0,c.T)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,o.A)("button button--secondary button--outline",g.collapseSidebarButton),onClick:t,children:(0,b.jsx)(_,{className:g.collapseSidebarButtonIcon})})}var k=n(5041),C=n(9532);const S=Symbol("EmptyContext"),T=a.createContext(S);function N(e){let{children:t}=e;const[n,o]=(0,a.useState)(null),i=(0,a.useMemo)((()=>({expandedItem:n,setExpandedItem:o})),[n]);return(0,b.jsx)(T.Provider,{value:i,children:t})}var I=n(1422),B=n(9169),y=n(8774),w=n(2303);function L(e){let{collapsed:t,categoryLabel:n,onClick:a}=e;return(0,b.jsx)("button",{"aria-label":t?(0,c.T)({id:"theme.DocSidebarItem.expandCategoryAriaLabel",message:"Expand sidebar category '{label}'",description:"The ARIA label to expand the sidebar category"},{label:n}):(0,c.T)({id:"theme.DocSidebarItem.collapseCategoryAriaLabel",message:"Collapse sidebar category '{label}'",description:"The ARIA label to collapse the sidebar category"},{label:n}),"aria-expanded":!t,type:"button",className:"clean-btn menu__caret",onClick:a})}function E(e){let{item:t,onItemClick:n,activePath:i,level:r,index:c,...d}=e;const{items:u,label:m,collapsible:h,className:p,href:x}=t,{docs:{sidebar:{autoCollapseCategories:f}}}=(0,j.p)(),v=function(e){const t=(0,w.A)();return(0,a.useMemo)((()=>e.href&&!e.linkUnlisted?e.href:!t&&e.collapsible?(0,l.Nr)(e):void 0),[e,t])}(t),_=(0,l.w8)(t,i),g=(0,B.ys)(x,i),{collapsed:A,setCollapsed:k}=(0,I.u)({initialState:()=>!!h&&(!_&&t.collapsed)}),{expandedItem:N,setExpandedItem:E}=function(){const e=(0,a.useContext)(T);if(e===S)throw new C.dV("DocSidebarItemsExpandedStateProvider");return e}(),M=function(e){void 0===e&&(e=!A),E(e?null:c),k(e)};return function(e){let{isActive:t,collapsed:n,updateCollapsed:o}=e;const i=(0,C.ZC)(t);(0,a.useEffect)((()=>{t&&!i&&n&&o(!1)}),[t,i,n,o])}({isActive:_,collapsed:A,updateCollapsed:M}),(0,a.useEffect)((()=>{h&&null!=N&&N!==c&&f&&k(!0)}),[h,N,c,k,f]),(0,b.jsxs)("li",{className:(0,o.A)(s.G.docs.docSidebarItemCategory,s.G.docs.docSidebarItemCategoryLevel(r),"menu__list-item",{"menu__list-item--collapsed":A},p),children:[(0,b.jsxs)("div",{className:(0,o.A)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":g}),children:[(0,b.jsx)(y.A,{className:(0,o.A)("menu__link",{"menu__link--sublist":h,"menu__link--sublist-caret":!x&&h,"menu__link--active":_}),onClick:h?e=>{n?.(t),x?M(!1):(e.preventDefault(),M())}:()=>{n?.(t)},"aria-current":g?"page":void 0,role:h&&!x?"button":void 0,"aria-expanded":h&&!x?!A:void 0,href:h?v??"#":v,...d,children:m}),x&&h&&(0,b.jsx)(L,{collapsed:A,categoryLabel:m,onClick:e=>{e.preventDefault(),M()}})]}),(0,b.jsx)(I.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:A,children:(0,b.jsx)(U,{items:u,tabIndex:A?-1:0,onItemClick:n,activePath:i,level:r+1})})]})}var M=n(6654),H=n(3186);const G={menuExternalLink:"menuExternalLink_NmtK"};function W(e){let{item:t,onItemClick:n,activePath:a,level:i,index:r,...c}=e;const{href:d,label:u,className:m,autoAddBaseUrl:h}=t,p=(0,l.w8)(t,a),x=(0,M.A)(d);return(0,b.jsx)("li",{className:(0,o.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(i),"menu__list-item",m),children:(0,b.jsxs)(y.A,{className:(0,o.A)("menu__link",!x&&G.menuExternalLink,{"menu__link--active":p}),autoAddBaseUrl:h,"aria-current":p?"page":void 0,to:d,...x&&{onClick:n?()=>n(t):void 0},...c,children:[u,!x&&(0,b.jsx)(H.A,{})]})},u)}const P={menuHtmlItem:"menuHtmlItem_M9Kj"};function R(e){let{item:t,level:n,index:a}=e;const{value:i,defaultStyle:l,className:r}=t;return(0,b.jsx)("li",{className:(0,o.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(n),l&&[P.menuHtmlItem,"menu__list-item"],r),dangerouslySetInnerHTML:{__html:i}},a)}function D(e){let{item:t,...n}=e;switch(t.type){case"category":return(0,b.jsx)(E,{item:t,...n});case"html":return(0,b.jsx)(R,{item:t,...n});default:return(0,b.jsx)(W,{item:t,...n})}}function F(e){let{items:t,...n}=e;const a=(0,l.Y)(t,n.activePath);return(0,b.jsx)(N,{children:a.map(((e,t)=>(0,b.jsx)(D,{item:e,index:t,...n},t)))})}const U=(0,a.memo)(F),V={menu:"menu_SIkG",menuWithAnnouncementBar:"menuWithAnnouncementBar_GW3s"};function Y(e){let{path:t,sidebar:n,className:i}=e;const l=function(){const{isActive:e}=(0,k.M)(),[t,n]=(0,a.useState)(e);return(0,d.Mq)((t=>{let{scrollY:a}=t;e&&n(0===a)}),[e]),e&&t}();return(0,b.jsx)("nav",{"aria-label":(0,c.T)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,o.A)("menu thin-scrollbar",V.menu,l&&V.menuWithAnnouncementBar,i),children:(0,b.jsx)("ul",{className:(0,o.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(U,{items:n,activePath:t,level:1})})})}const K="sidebar_njMd",z="sidebarWithHideableNavbar_wUlq",q="sidebarHidden_VK0M",O="sidebarLogo_isFc";function J(e){let{path:t,sidebar:n,onCollapse:a,isHidden:i}=e;const{navbar:{hideOnScroll:s},docs:{sidebar:{hideable:l}}}=(0,j.p)();return(0,b.jsxs)("div",{className:(0,o.A)(K,s&&z,i&&q),children:[s&&(0,b.jsx)(v.A,{tabIndex:-1,className:O}),(0,b.jsx)(Y,{path:t,sidebar:n}),l&&(0,b.jsx)(A,{onClick:a})]})}const Q=a.memo(J);var X=n(5600),Z=n(2069);const $=e=>{let{sidebar:t,path:n}=e;const a=(0,Z.M)();return(0,b.jsx)("ul",{className:(0,o.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(U,{items:t,activePath:n,onItemClick:e=>{"category"===e.type&&e.href&&a.toggle(),"link"===e.type&&a.toggle()},level:1})})};function ee(e){return(0,b.jsx)(X.GX,{component:$,props:e})}const te=a.memo(ee);function ne(e){const t=(0,f.l)(),n="desktop"===t||"ssr"===t,a="mobile"===t;return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)(Q,{...e}),a&&(0,b.jsx)(te,{...e})]})}const ae={expandButton:"expandButton_TmdG",expandButtonIcon:"expandButtonIcon_i1dp"};function oe(e){let{toggleSidebar:t}=e;return(0,b.jsx)("div",{className:ae.expandButton,title:(0,c.T)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:t,onClick:t,children:(0,b.jsx)(_,{className:ae.expandButtonIcon})})}const ie={docSidebarContainer:"docSidebarContainer_YfHR",docSidebarContainerHidden:"docSidebarContainerHidden_DPk8",sidebarViewport:"sidebarViewport_aRkj"};function se(e){let{children:t}=e;const n=(0,r.t)();return(0,b.jsx)(a.Fragment,{children:t},n?.name??"noSidebar")}function le(e){let{sidebar:t,hiddenSidebarContainer:n,setHiddenSidebarContainer:i}=e;const{pathname:l}=(0,x.zy)(),[r,c]=(0,a.useState)(!1),d=(0,a.useCallback)((()=>{r&&c(!1),!r&&(0,p.O)()&&c(!0),i((e=>!e))}),[i,r]);return(0,b.jsx)("aside",{className:(0,o.A)(s.G.docs.docSidebarContainer,ie.docSidebarContainer,n&&ie.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(ie.docSidebarContainer)&&n&&c(!0)},children:(0,b.jsx)(se,{children:(0,b.jsxs)("div",{className:(0,o.A)(ie.sidebarViewport,r&&ie.sidebarViewportHidden),children:[(0,b.jsx)(ne,{sidebar:t,path:l,onCollapse:d,isHidden:r}),r&&(0,b.jsx)(oe,{toggleSidebar:d})]})})})}const re={docMainContainer:"docMainContainer_TBSr",docMainContainerEnhanced:"docMainContainerEnhanced_lQrH",docItemWrapperEnhanced:"docItemWrapperEnhanced_JWYK"};function ce(e){let{hiddenSidebarContainer:t,children:n}=e;const a=(0,r.t)();return(0,b.jsx)("main",{className:(0,o.A)(re.docMainContainer,(t||!a)&&re.docMainContainerEnhanced),children:(0,b.jsx)("div",{className:(0,o.A)("container padding-top--md padding-bottom--lg",re.docItemWrapper,t&&re.docItemWrapperEnhanced),children:n})})}const de={docRoot:"docRoot_UBD9",docsWrapper:"docsWrapper_hBAB"};function ue(e){let{children:t}=e;const n=(0,r.t)(),[o,i]=(0,a.useState)(!1);return(0,b.jsxs)("div",{className:de.docsWrapper,children:[(0,b.jsx)(h,{}),(0,b.jsxs)("div",{className:de.docRoot,children:[n&&(0,b.jsx)(le,{sidebar:n.items,hiddenSidebarContainer:o,setHiddenSidebarContainer:i}),(0,b.jsx)(ce,{hiddenSidebarContainer:o,children:t})]})]})}var me=n(3363);function be(e){const t=(0,l.B5)(e);if(!t)return(0,b.jsx)(me.A,{});const{docElement:n,sidebarName:a,sidebarItems:c}=t;return(0,b.jsx)(i.e3,{className:(0,o.A)(s.G.page.docsDocPage),children:(0,b.jsx)(r.V,{name:a,items:c,children:(0,b.jsx)(ue,{children:n})})})}},3363:(e,t,n)=>{n.d(t,{A:()=>l});n(6540);var a=n(4164),o=n(1312),i=n(1107),s=n(4848);function l(e){let{className:t}=e;return(0,s.jsx)("main",{className:(0,a.A)("container margin-vert--xl",t),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(i.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}}}]); \ No newline at end of file diff --git a/assets/js/b4f71b2f.88f92936.js b/assets/js/b4f71b2f.88f92936.js new file mode 100644 index 000000000..5ed902556 --- /dev/null +++ b/assets/js/b4f71b2f.88f92936.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[205],{4218:(e,i,t)=>{t.r(i),t.d(i,{assets:()=>o,contentTitle:()=>a,default:()=>b,frontMatter:()=>r,metadata:()=>l,toc:()=>d});var s=t(4848),n=t(8453);const r={sidebar_position:7,sidebar_label:"\ud83d\udea9 Stability",hide_table_of_contents:!0,description:"Describes and summarizes Stability Indexes for TinyORM library.",keywords:["c++ orm","tinyorm","features","modules","stability"]},a="Stability",l={id:"stability",title:"Stability",description:"Describes and summarizes Stability Indexes for TinyORM library.",source:"@site/docs/stability.mdx",sourceDirName:".",slug:"/stability",permalink:"/stability",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:7,frontMatter:{sidebar_position:7,sidebar_label:"\ud83d\udea9 Stability",hide_table_of_contents:!0,description:"Describes and summarizes Stability Indexes for TinyORM library.",keywords:["c++ orm","tinyorm","features","modules","stability"]},sidebar:"tinyormSidebar",previous:{title:"Migrations",permalink:"/building/migrations"},next:{title:"\ud83d\udcc4 Features Summary",permalink:"/features-summary"}},o={},d=[{value:"Stability Indexes",id:"stability-indexes",level:2}];function c(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,n.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.header,{children:(0,s.jsx)(i.h1,{id:"stability",children:"Stability"})}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#stability-indexes",children:"Stability Indexes"})}),"\n"]}),"\n",(0,s.jsx)(i.h2,{id:"stability-indexes",children:"Stability Indexes"}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--info",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 0 - Experimental"})," : The feature is still under development.",(0,s.jsx)("br",{}),"\n",(0,s.jsx)("small",{children:"Currently, no module/feature is in this Stability Category."})]})}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--warning",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 1 - Preview"})," : The feature is almost done, but still can contain some glitches.",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["Currently, only ",(0,s.jsx)(i.a,{href:"/tinyorm/relationships",children:"TinyORM: Relationships"})," module is in this Stability Category, the reason why is described on its page."]})]})}),"\n",(0,s.jsx)("div",{className:"api-stability alert alert--success",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 2 - Stable"})," : The feature is ready for ",(0,s.jsx)(i.strong,{children:"Production"})," use, everything works as was intended.",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["All ",(0,s.jsx)(i.code,{children:"TinyORM"})," other modules are considered Stable."]})]})})]})}function b(e={}){const{wrapper:i}={...(0,n.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},8453:(e,i,t)=>{t.d(i,{R:()=>a,x:()=>l});var s=t(6540);const n={},r=s.createContext(n);function a(e){const i=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:a(e.components),s.createElement(r.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/b4f71b2f.af30ffa7.js b/assets/js/b4f71b2f.af30ffa7.js deleted file mode 100644 index 4c9adc99b..000000000 --- a/assets/js/b4f71b2f.af30ffa7.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[205],{4218:(e,i,t)=>{t.r(i),t.d(i,{assets:()=>o,contentTitle:()=>l,default:()=>b,frontMatter:()=>r,metadata:()=>a,toc:()=>d});var s=t(4848),n=t(8453);const r={sidebar_position:7,sidebar_label:"\ud83d\udea9 Stability",hide_table_of_contents:!0,description:"Describes and summarizes Stability Indexes for TinyORM library.",keywords:["c++ orm","tinyorm","features","modules","stability"]},l="Stability",a={id:"stability",title:"Stability",description:"Describes and summarizes Stability Indexes for TinyORM library.",source:"@site/docs/stability.mdx",sourceDirName:".",slug:"/stability",permalink:"/stability",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:7,frontMatter:{sidebar_position:7,sidebar_label:"\ud83d\udea9 Stability",hide_table_of_contents:!0,description:"Describes and summarizes Stability Indexes for TinyORM library.",keywords:["c++ orm","tinyorm","features","modules","stability"]},sidebar:"tinyormSidebar",previous:{title:"Migrations",permalink:"/building/migrations"},next:{title:"\ud83d\udcc4 Features Summary",permalink:"/features-summary"}},o={},d=[{value:"Stability Indexes",id:"stability-indexes",level:2}];function c(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...(0,n.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.h1,{id:"stability",children:"Stability"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsx)(i.li,{children:(0,s.jsx)(i.a,{href:"#stability-indexes",children:"Stability Indexes"})}),"\n"]}),"\n",(0,s.jsx)(i.h2,{id:"stability-indexes",children:"Stability Indexes"}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--info",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 0 - Experimental"})," : The feature is still under development.",(0,s.jsx)("br",{}),"\n",(0,s.jsx)("small",{children:"Currently, no module/feature is in this Stability Category."})]})}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--warning",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 1 - Preview"})," : The feature is almost done, but still can contain some glitches.",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["Currently, only ",(0,s.jsx)(i.a,{href:"/tinyorm/relationships",children:"TinyORM: Relationships"})," module is in this Stability Category, the reason why is described on its page."]})]})}),"\n",(0,s.jsx)("div",{class:"api-stability alert alert--success",children:(0,s.jsxs)(i.p,{children:[(0,s.jsx)(i.strong,{children:"Stability: 2 - Stable"})," : The feature is ready for ",(0,s.jsx)(i.strong,{children:"Production"})," use, everything works as was intended.",(0,s.jsx)("br",{}),"\n",(0,s.jsxs)("small",{children:["All ",(0,s.jsx)(i.code,{children:"TinyORM"})," other modules are considered Stable."]})]})})]})}function b(e={}){const{wrapper:i}={...(0,n.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},8453:(e,i,t)=>{t.d(i,{R:()=>l,x:()=>a});var s=t(6540);const n={},r=s.createContext(n);function l(e){const i=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function a(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:l(e.components),s.createElement(r.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/ba3d4959.838dd8c9.js b/assets/js/ba3d4959.838dd8c9.js new file mode 100644 index 000000000..0216b9b3a --- /dev/null +++ b/assets/js/ba3d4959.838dd8c9.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[170],{2512:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>Q,contentTitle:()=>_,default:()=>q,frontMatter:()=>v,metadata:()=>T,toc:()=>D});var i=t(4848),r=t(8453),a=t(8774),s=t(9365),o=t(1470),l=t(6540);let c=null,d=null;function h(){const[e,n]=(0,l.useState)(!1),[t,r]=(0,l.useState)(!1);return(0,l.useEffect)((()=>(u(),()=>{u()})),[]),(0,i.jsxs)("form",{children:[(0,i.jsxs)("div",{className:"tinyorm-configuration-row",children:[(0,i.jsx)("label",{htmlFor:"tinyorm-toggle-full",children:"Full configuration"}),(0,i.jsx)("input",{id:"tinyorm-toggle-full",type:"checkbox",checked:e,onChange:()=>n(p),title:"Show full configuration example"})]}),(0,i.jsxs)("div",{className:"tinyorm-configuration-row",children:[(0,i.jsx)("label",{htmlFor:"tinyorm-toggle-prefix",children:"Prefix environment"}),(0,i.jsx)("input",{id:"tinyorm-toggle-prefix",type:"checkbox",checked:t,onChange:()=>r(S),title:"Prefix all environment variables by the database type"})]})]})}function u(){c=null,d=null}function p(e){const n=c||(c=document.getElementById("tinyorm-configuration")?.querySelectorAll(".tabs-container")),t=!e;if(!n)return e;if(2!==n.length)throw new Error(`Wrong number of .tabs-container (!== 2) found in the toggle configuration feature, found ${n.length}.`);return t?(n[0].style.display="none",n[1].style.display="block"):(n[0].style.display="block",n[1].style.display="none"),!e}const m='"DB_',g="MARIA",x="MYSQL",f="PGSQL",b="SQLITE",j=[x,f,b,g,x,f,b,g];function S(e){const n=function(){if(d)return d;const e=document.getElementById("tinyorm-configuration")?.querySelectorAll(".prism-code > code");if(!e)return e;if(8!==e.length)throw new Error(`Wrong number of .prism-code > code (!== 8) found in the prefix env. feature, found ${e.length}.`);return d=new Array(e.length),e.forEach(((e,n)=>{d[n]=Array.from(e.querySelectorAll(".token.string")).filter((e=>e?.textContent.startsWith(m)))})),d}(),t=!e;return n?(n.forEach(((e,n)=>{e.forEach((e=>{const i=e.textContent,r=`${m}${j[n]}_`;if(t)e.textContent=`${r}${i.substring(4)}`;else{if(!i.startsWith(r))throw new Error(`Token doesn't start with the '${r}' prefix.`);e.textContent=`${m}${i.substring(r.length)}`}}))})),!e):e}var y=t(7324);const v={sidebar_position:0,sidebar_label:"Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",keywords:["c++ orm","database","getting started","tinyorm"]},_="Database: Getting Started",T={id:"database/getting-started",title:"Database: Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",source:"@site/docs/database/getting-started.mdx",sourceDirName:"database",slug:"/database/getting-started",permalink:"/database/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",keywords:["c++ orm","database","getting started","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\ude80 Supported Compilers",permalink:"/supported-compilers"},next:{title:"Query Builder",permalink:"/database/query-builder"}},Q={},D=[{value:"Introduction",id:"introduction",level:2},{value:"Configuration",id:"configuration",level:3},{value:"SQLite Configuration",id:"sqlite-configuration",level:4},{value:"SSL Connections",id:"ssl-connections",level:3},{value:"MySQL",id:"mysql",level:5},{value:"PostgreSQL",id:"postgresql",level:5},{value:"Running SQL Queries",id:"running-sql-queries",level:2},{value:"Running A Select Query",id:"running-a-select-query",level:4},{value:"Selecting Scalar Values",id:"selecting-scalar-values",level:4},{value:"Running An Insert Statement",id:"running-an-insert-statement",level:4},{value:"Running An Update Statement",id:"running-an-update-statement",level:4},{value:"Running A Delete Statement",id:"running-a-delete-statement",level:4},{value:"Running A General Statement",id:"running-a-general-statement",level:4},{value:"Running An Unprepared Statement",id:"running-an-unprepared-statement",level:4},{value:"Implicit Commits",id:"implicit-commits",level:4},{value:"Using Multiple Database Connections",id:"using-multiple-database-connections",level:3},{value:"Database Transactions",id:"database-transactions",level:2},{value:"Manually Using Transactions",id:"manually-using-transactions",level:4},{value:"Multi-threading support",id:"multi-threading-support",level:2}];function L(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"database-getting-started",children:"Database: Getting Started"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#configuration",children:"Configuration"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#ssl-connections",children:"SSL Connections"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#running-sql-queries",children:"Running SQL Queries"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-multiple-database-connections",children:"Using Multiple Database Connections"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#database-transactions",children:"Database Transactions"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#multi-threading-support",children:"Multi-threading support"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{className:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(n.p,{children:["Almost every modern application interacts with a database. TinyORM makes interacting with a database extremely simple using raw SQL, a ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"fluent query builder"}),", and the ",(0,i.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),". Currently, TinyORM provides first-party support for four databases:"]}),"\n",(0,i.jsx)("div",{id:"databases-supported-versions",children:(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["MySQL ",(0,i.jsx)(n.code,{children:">=5.7"})," (",(0,i.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/MySQL#Release_history",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["MariaDB ",(0,i.jsx)(n.code,{children:">=10.3"})," (",(0,i.jsx)(n.a,{href:"https://mariadb.org/about/#maintenance-policy",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["PostgreSQL ",(0,i.jsx)(n.code,{children:">=11"})," (",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/support/versioning/",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["SQLite ",(0,i.jsx)(n.code,{children:">=3.8.8"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["native rename column ",(0,i.jsx)(n.code,{children:">=3.25.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/lang_altertable.html#alter_table_rename_column",children:"docs"})," , ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_25_0.html",children:"release notes"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["native drop column ",(0,i.jsx)(n.code,{children:">=3.35.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/lang_altertable.html#alter_table_drop_column",children:"docs"}),", ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_35_0.html",children:"release notes"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["generated columns ",(0,i.jsx)(n.code,{children:">=3.31.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/gencol.html",children:"docs"}),", ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_31_0.html",children:"release notes"}),")"]}),"\n"]}),"\n"]}),"\n"]})}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM internally uses ",(0,i.jsx)(n.code,{children:"QtSql"})," module, you can look for ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/sql-driver.html#supported-databases",children:"supported databases"}),"."]}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsx)(n.p,{children:"TinyORM's code is ready and designed to simply add support for the SQL Server."})}),"\n",(0,i.jsx)(n.h3,{id:"configuration",children:"Configuration"}),"\n",(0,i.jsxs)(n.p,{children:["You can create and configure a new database connection using the ",(0,i.jsx)(n.code,{children:"create"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsxs)("div",{id:"tinyorm-configuration",children:[(0,i.jsx)(h,{}),(0,i.jsxs)(o.A,{className:"tinyorm-configuration-basic",groupId:y.OO,children:[(0,i.jsx)(s.A,{value:y.Dx,label:y.A3,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_COLLATION", "utf8mb4_0900_ai_ci")},\n {"timezone", "+00:00"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"strict", true},\n {"engine", "InnoDB"},\n {"options", QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.os,label:y.LQ,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "5432")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"search_path", qEnvironmentVariable("DB_SEARCHPATH", "public")},\n {"username", qEnvironmentVariable("DB_USERNAME", "postgres")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8")},\n {"timezone", "UTC"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"options", QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.F4,label:y.Q7,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_DATABASE", "/example/example.sqlite3")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n /* Return a QDateTime/QDate with the correct time zone instead of the QString,\n only works when the qt_timezone isn\'t set to the DontConvert. */\n {"return_qdatetime", true},\n {"prefix", ""},\n {"prefix_indexes", false},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.Fi,label:y.CW,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_COLLATION", "utf8mb4_unicode_520_ci")},\n {"timezone", "+00:00"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"strict", true},\n {"engine", "InnoDB"},\n {"options", QVariantHash()},\n});\n'})})})]}),(0,i.jsxs)(o.A,{className:"tinyorm-configuration-full",groupId:y.OO,children:[(0,i.jsx)(s.A,{value:y.Dx,label:y.A3,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_USERNAME", ROOT)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_COLLATION", UTF8MB40900aici)},\n // SSL-related\n {ssl_ca, QStringLiteral("C:/mysql/data/ca.pem")},\n {ssl_cert, QStringLiteral("C:/mysql/data/client-cert.pem")},\n {ssl_key, QStringLiteral("C:/mysql/data/client-key.pem")},\n {ssl_mode, VerifyCA},\n // Or\n// {options, ConfigUtils::mysqlSslOptions()},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n {strict_, true},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // MySQL default is REPEATABLE READ for InnoDB\n {engine_, InnoDB},\n {Version, {}}, // Autodetect\n {options_, QVariantHash()},\n // Examples\n// {options_, QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT = 1 ; MYSQL_OPT_READ_TIMEOUT=1")},\n// {options_, QVariantHash {{QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT"), 1},\n// {QStringLiteral("MYSQL_OPT_READ_TIMEOUT"), 1}}},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.os,label:y.LQ,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QPSQL},\n {application_name, QStringLiteral("Example application")},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P5432)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {search_path, qEnvironmentVariable("DB_SEARCHPATH", PUBLIC)},\n {username_, qEnvironmentVariable("DB_USERNAME", postgres_)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8)},\n // SSL-related\n {sslmode_, QStringLiteral("verify-full")},\n {sslcert, QStringLiteral("C:/example/postgres.crt")},\n {sslkey, QStringLiteral("C:/example/postgres.key")},\n {sslrootcert, QStringLiteral("C:/example/root.crt")},\n // Or\n// {options_, ConfigUtils::postgresSslOptions()},\n {timezone_, UTC},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // Postgres default is READ COMMITTED\n// {synchronous_commit, QStringLiteral("off")}, // Postgres default is on\n // ConnectionFactory provides a default value for this, this is only for reference\n// {dont_drop, QStringList {spatial_ref_sys}},\n {options_, QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.F4,label:y.Q7,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QSQLITE},\n {database_, qEnvironmentVariable("DB_DATABASE", "C:/SQLite/example.sqlite3")},\n {foreign_key_constraints, qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {check_database_exists, true},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n /* Return a QDateTime/QDate with the correct time zone instead of the QString,\n only works when the qt_timezone isn\'t set to the DontConvert. */\n {return_qdatetime, true},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.Fi,label:y.CW,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_USERNAME", ROOT)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_COLLATION", UTF8MB4Unicode520ci)},\n // SSL-related\n {ssl_ca, QStringLiteral("C:/maria/data/ca.pem")},\n {ssl_cert, QStringLiteral("C:/maria/data/client-cert.pem")},\n {ssl_key, QStringLiteral("C:/maria/data/client-key.pem")},\n // Or\n// {options, ConfigUtils::mariaSslOptions()},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n {strict_, true},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // MariaDB default is REPEATABLE READ for InnoDB\n {engine_, InnoDB},\n {Version, {}}, // Autodetect\n {options_, QVariantHash()},\n // Examples\n// {options_, QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT = 1 ; MYSQL_OPT_READ_TIMEOUT=1")},\n// {options_, QVariantHash {{QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT"), 1},\n// {QStringLiteral("MYSQL_OPT_READ_TIMEOUT"), 1}}},\n});\n'})})})]})]}),"\n",(0,i.jsxs)(n.p,{children:["The first argument is configuration hash which is of type ",(0,i.jsx)(n.code,{children:"QVariantHash"})," and the second argument specifies the name of the ",(0,i.jsx)(n.em,{children:"connection"}),", this connection will also be a ",(0,i.jsx)(n.em,{children:"default connection"}),". You can configure multiple database connections at once and choose the needed one before executing SQL query, section ",(0,i.jsx)(n.a,{href:"#using-multiple-database-connections",children:"Using Multiple Database Connections"})," describes how to create and use multiple database connections."]}),"\n",(0,i.jsxs)(n.p,{children:["You may also configure connection options by ",(0,i.jsx)(n.code,{children:"options"})," key as ",(0,i.jsx)(n.code,{children:"QVariantHash"})," or ",(0,i.jsx)(n.code,{children:"QString"}),", you can pass any ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/qsqldatabase.html#setConnectOptions",children:"connection options"})," supported by ",(0,i.jsx)(n.code,{children:"QSqlDatabase"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You can also configure ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/innodb-transaction-isolation-levels.html",children:"Transaction Isolation Levels"})," for MySQL connection with the ",(0,i.jsx)(n.code,{children:"isolation_level"})," configuration option."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"version"})," option is relevant only for the MySQL connections and you can save/avoid one database query (select version()) if you provide it manually. Based on this version will be decided which ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/src/orm/connectors/mysqlconnector.cpp#L182",children:"session variables"})," will be set if strict mode is enabled and whether to use an ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/src/orm/query/grammars/mysqlgrammar.cpp#L36",children:"alias"})," during the ",(0,i.jsx)(n.code,{children:"upsert"})," method call."]}),"\n",(0,i.jsxs)(n.p,{children:["Breaking values are as follows; use an upsert alias on the MySQL >=8.0.19 and remove the ",(0,i.jsx)(n.code,{children:"NO_AUTO_CREATE_USER"})," sql mode on the MySQL >=8.0.11 if the strict mode is enabled."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["A database connection is resolved lazily, which means that the connection configuration is only saved after the ",(0,i.jsx)(n.code,{children:"DB::create"})," method call. The connection will be resolved after you run some query or you can create it using the ",(0,i.jsx)(n.code,{children:"DB::connection"})," method."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can also use predefined string constants to avoid unnecessary ",(0,i.jsx)(n.code,{children:"QString"})," instantiations, as used in the ",(0,i.jsx)(n.code,{children:"tom"})," migrations ",(0,i.jsx)(n.a,{href:"/building/migrations#string-constants-example",children:"example"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["See ",(0,i.jsx)(n.a,{href:"/tinyorm/casts#date-casting-serialization-and-timezones",children:"Date Casting, Serialization & Timezones"})," if you have problems with ",(0,i.jsx)(n.code,{children:"qt_timezone"})," configuration option and ",(0,i.jsx)(n.code,{children:"QTimeZone"})," value on older ",(0,i.jsx)(n.code,{children:"Qt <6.5"})," versions."]})}),"\n",(0,i.jsx)(n.h4,{id:"sqlite-configuration",children:"SQLite Configuration"}),"\n",(0,i.jsxs)(n.p,{children:["SQLite databases are contained within a single file on your filesystem. You can create a new SQLite database using the ",(0,i.jsx)(n.code,{children:"touch"})," command in your terminal: ",(0,i.jsx)(n.code,{children:"touch database.sqlite3"}),". After the database has been created, you may configure SQLite database connection:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_DATABASE", "/absolute/path/to/database.sqlite3")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n {"prefix", ""},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"database"})," configuration value is the absolute path to the database. To enable foreign key constraints for SQLite connections, you should set the ",(0,i.jsx)(n.code,{children:"foreign_key_constraints"})," configuration value to ",(0,i.jsx)(n.code,{children:"true"}),", if this configuration value is not set, then the default of the SQLite driver will be used (currently the default is ",(0,i.jsx)(n.strong,{children:"disabled"}),")."]}),"\n",(0,i.jsxs)(n.p,{children:["If the ",(0,i.jsx)(n.code,{children:"check_database_exists"})," configuration value is set to the ",(0,i.jsx)(n.code,{children:"true"})," value, then the database connection throws an ",(0,i.jsx)(n.code,{children:"Orm::InvalidArgumentError"})," exception, when the SQLite database file doesn't exist. If it is set to the ",(0,i.jsx)(n.code,{children:"false"})," value and the SQLite database file doesn't exist, then it will be created for you by SQLite driver. The default value is ",(0,i.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,i.jsx)(n.h3,{id:"ssl-connections",children:"SSL Connections"}),"\n",(0,i.jsxs)(n.p,{children:["SSL connections are supported for the ",(0,i.jsx)(n.code,{children:"MySQL"})," and ",(0,i.jsx)(n.code,{children:"PostgreSQL"})," databases. They can be set using the ",(0,i.jsx)(n.code,{children:"options"})," configuration option."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["This feature is heavily dependent on the underlying ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," module. What means that you can pass the same ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/qsqldatabase.html#setConnectOptions",children:"connection options"})," to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," that the ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," accepts."]})}),"\n",(0,i.jsx)(n.h5,{id:"mysql",children:"MySQL"}),"\n",(0,i.jsxs)(n.p,{children:["You have to pass the ",(0,i.jsx)(n.code,{children:"SSL_CA"}),", ",(0,i.jsx)(n.code,{children:"SSL_CERT"}),", ",(0,i.jsx)(n.code,{children:"SSL_KEY"}),", and ",(0,i.jsx)(n.code,{children:"MYSQL_OPT_SSL_MODE"})," options."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"options", QVariantHash({{"SSL_CA", "C:/mysql/data/ca.pem"},\n {"SSL_CERT", "C:/mysql/data/client-cert.pem"},\n {"SSL_KEY", "C:/mysql/data/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"}})},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"options", QVariantHash({{"SSL_CA", "~/.local/share/TinyORM/ssl/ca.pem"},\n {"SSL_CERT", "~/.local/share/TinyORM/ssl/client-cert.pem"},\n {"SSL_KEY", "~/.local/share/TinyORM/ssl/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"}})},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"ConfigUtils::mysqlSslOptions()"})," or the ",(0,i.jsx)(n.code,{children:"ConfigUtils::insertMySqlSslOptions()"})," methods to insert these options for you and define them using the ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_CA"}),", ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_CERT"}),", ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_KEY"}),", and ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_MODE"})," environment variables."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", ConfigUtils::mysqlSslOptions()},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You can define these SSL-related options in the top-level configuration, they will be copied to the ",(0,i.jsx)(n.code,{children:"options"})," option hash during configuration parsing. The top-level configuration takes precedence and overwrites the options in the ",(0,i.jsx)(n.code,{children:"options"})," hash."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"SSL_CA", "C:/mysql/data/ca.pem"},\n {"SSL_CERT", "C:/mysql/data/client-cert.pem"},\n {"SSL_KEY", "C:/mysql/data/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"SSL_CA", "~/.local/share/TinyORM/ssl/ca.pem"},\n {"SSL_CERT", "~/.local/share/TinyORM/ssl/client-cert.pem"},\n {"SSL_KEY", "~/.local/share/TinyORM/ssl/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can take a look at the GitHub actions how the ",(0,i.jsx)(n.code,{children:"MySQL"})," certificates are generated in the CI pipeline for ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/msvc2022-qt6.yml",children:"Windows"})," and ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/linux-qt6.yml",children:"Linux"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can also pass the ",(0,i.jsx)(n.code,{children:"QString"})," to the ",(0,i.jsx)(n.code,{children:"options"})," configuration separated by the ",(0,i.jsx)(n.code,{children:";"})," semicolon character and use the ",(0,i.jsx)(n.code,{children:"="})," to assign values."]})}),"\n",(0,i.jsx)(n.h5,{id:"postgresql",children:"PostgreSQL"}),"\n",(0,i.jsxs)(n.p,{children:["You have to pass the ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS",children:(0,i.jsx)(n.code,{children:"sslmode"})})," or the deprecated ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-REQUIRESSL",children:(0,i.jsx)(n.code,{children:"requiressl"})})," options."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"}})},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["And place your ",(0,i.jsx)(n.strong,{children:"client"})," certificates to the ",(0,i.jsx)(n.code,{children:"~/.postgres/"})," on ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-FILE-USAGE",children:"Linux"})," and ",(0,i.jsx)(n.code,{children:"$env:APPDATA/postgres/"})," on Windows. Everything is described in the PostgreSQL's ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html",children:"libpq client"})," and ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/15/ssl-tcp.html#SSL-FILE-USAGE",children:"server"})," documentation."]}),"\n",(0,i.jsxs)(n.p,{children:["If you want to keep your ",(0,i.jsx)(n.strong,{children:"client"})," certificates in your own location, you can set the ",(0,i.jsx)(n.code,{children:"sslcert"}),", ",(0,i.jsx)(n.code,{children:"sslkey"}),", and ",(0,i.jsx)(n.code,{children:"sslrootcert"})," options."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"},\n // highlight-start\n {"sslcert", "C:/example/postgres.crt"},\n {"sslkey", "C:/example/postgres.key"},\n {"sslrootcert", "C:/example/root.crt"}})},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"},\n // highlight-start\n {"sslcert", "/example/postgres.crt"},\n {"sslkey", "/example/postgres.key"},\n {"sslrootcert", "/example/root.crt"}})},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You can define these SSL-related options in the top-level configuration, they will be copied to the ",(0,i.jsx)(n.code,{children:"options"})," option hash during a configuration parsing. The top-level configuration takes precedence and overwrites the options in the ",(0,i.jsx)(n.code,{children:"options"})," hash."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"sslmode", "verify-full"},\n {"sslcert", "C:/example/postgres.crt"},\n {"sslkey", "C:/example/postgres.key"},\n {"sslrootcert", "C:/example/root.crt"},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"sslmode", "verify-full"},\n {"sslcert", "/example/postgres.crt"},\n {"sslkey", "/example/postgres.key"},\n {"sslrootcert", "/example/root.crt"},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"ConfigUtils::postgresSslOptions()"})," or the ",(0,i.jsx)(n.code,{children:"ConfigUtils::insertPostgresSslOptions()"})," methods to insert the ",(0,i.jsx)(n.code,{children:"sslmode"}),", ",(0,i.jsx)(n.code,{children:"sslcert"}),", ",(0,i.jsx)(n.code,{children:"sslkey"}),", and ",(0,i.jsx)(n.code,{children:"sslrootcert"})," options for you and define them using the ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLMODE"}),", ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLCERT"}),", ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLKEY"}),", and ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLROOTCERT"})," environment variable."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", ConfigUtils::postgresSslOptions()},\n});\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["The PostgreSQL's libpq client library provides the ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.13.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLMODE"})}),", ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.16.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLCERT"})}),", ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.17.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLKEY"})}),", and ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.18.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLROOTCERT"})})," environment variables, so you don't have to use TinyORM's ",(0,i.jsx)(n.code,{children:"options"})," configuration and may use these environment variables instead."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can take a look at the GitHub actions how the ",(0,i.jsx)(n.code,{children:"PostgreSQL"})," certificates are generated in the CI pipeline for ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/msvc2022-qt6.yml",children:"Windows"})," and ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/linux-qt6.yml",children:"Linux"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"running-sql-queries",children:"Running SQL Queries"}),"\n",(0,i.jsxs)(n.p,{children:["Once you have configured your database connection, you may run queries using the ",(0,i.jsx)(n.code,{children:"DB"})," facade. The ",(0,i.jsx)(n.code,{children:"DB"})," facade provides methods for each type of query: ",(0,i.jsx)(n.code,{children:"select"}),", ",(0,i.jsx)(n.code,{children:"update"}),", ",(0,i.jsx)(n.code,{children:"insert"}),", ",(0,i.jsx)(n.code,{children:"delete"}),", and ",(0,i.jsx)(n.code,{children:"statement"}),"."]}),"\n",(0,i.jsx)(n.h4,{id:"running-a-select-query",children:"Running A Select Query"}),"\n",(0,i.jsxs)(n.p,{children:["To run a basic SELECT query, you may use the ",(0,i.jsx)(n.code,{children:"select"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsxs)(n.p,{children:['auto users = DB::select("select * from users where active = ?", ',1,");"]}),"\n",(0,i.jsxs)(n.p,{children:["The first argument passed to the ",(0,i.jsx)(n.code,{children:"select"})," method is the SQL query, while the second argument is any parameter bindings that need to be bound to the query. Typically, these are the values of the ",(0,i.jsx)(n.code,{children:"where"})," clause constraints. Parameter binding provides protection against SQL injection."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"select"})," method returns a ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," containing the results of the query, where each result can be accessed by ",(0,i.jsx)(n.code,{children:"QSqlQuery::next"})," method. Look into the ",(0,i.jsx)(n.code,{children:"QSqlQuery"}),' documentation on how to obtain results from the "query". You may access each column\'s value by ',(0,i.jsx)(n.code,{children:"QSqlQuery::value"})," method. The first ",(0,i.jsx)(n.code,{children:"bool"})," return value is the value returned from ",(0,i.jsx)(n.code,{children:"QSqlQuery::exec"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto users = DB::select("select * from users");\n\nwhile(users.next())\n qDebug() << users.value("name").toString();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"selecting-scalar-values",children:"Selecting Scalar Values"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes your database query may result in a single, scalar value. Instead of being required to retrieve the query's scalar result from a record instance, TinyORM allows you to retrieve this value directly using the ",(0,i.jsx)(n.code,{children:"scalar"})," shortcut method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto states = DB::scalar(\n "select count(case when state = \'pending\' then 1 end) as states "\n "from comments"\n);\n\n// With binding\nauto states = DB::scalar(\n "select count(case when state = ? then 1 end) as states from comments",\n {"pending"}\n);\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-insert-statement",children:"Running An Insert Statement"}),"\n",(0,i.jsxs)(n.p,{children:["To execute an ",(0,i.jsx)(n.code,{children:"insert"})," statement, you may use the ",(0,i.jsx)(n.code,{children:"insert"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade. Like ",(0,i.jsx)(n.code,{children:"select"}),", this method accepts the SQL query as its first argument and bindings as its second argument and returns ",(0,i.jsx)(n.code,{children:"QSqlQuery"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nDB::insert("insert into users (id, name) values (?, ?)", {1, "Marc"});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-update-statement",children:"Running An Update Statement"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"update"})," method should be used to update existing records in the database. The number of rows affected by the statement and ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," is returned by the method as ",(0,i.jsx)(n.code,{children:"std::tuple"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto [affected, query] = DB::update(\n "update users set updated_at = ? where name = ?",\n {QDateTime::currentDateTimeUtc(), "Anita"}\n);\n\nif (!affected)\n qDebug() << "Any record was updated.";\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-a-delete-statement",children:"Running A Delete Statement"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"remove"})," method should be used to delete records from the database. Like ",(0,i.jsx)(n.code,{children:"update"}),", the number of affected rows and ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," will be returned by the method as ",(0,i.jsx)(n.code,{children:"std::tuple"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto [affected, query] = DB::remove("delete from users");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"delete"})," can not be used as the method name because it is the reserved word."]})}),"\n",(0,i.jsx)(n.h4,{id:"running-a-general-statement",children:"Running A General Statement"}),"\n",(0,i.jsxs)(n.p,{children:["Some database statements do not return any value. For these types of operations, you may use the ",(0,i.jsx)(n.code,{children:"statement"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::statement("drop table users");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"DB::statement"})," method should be used for ",(0,i.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Data_definition_language",children:"DDL"}),' queries, don\'t use it for "select" queries because it internally calls ',(0,i.jsx)(n.code,{children:"recordsHaveBeenModified"})," method."]})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-unprepared-statement",children:"Running An Unprepared Statement"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may want to execute an SQL statement without binding any values. You may use the ",(0,i.jsx)(n.code,{children:"DB"})," facade's ",(0,i.jsx)(n.code,{children:"unprepared"})," method to accomplish this:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::unprepared(\"update users set votes = 100 where name = 'Dries'\");\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsx)(n.p,{children:"Since unprepared statements do not bind parameters, they may be vulnerable to SQL injection. You should never allow user controlled values within an unprepared statement."})}),"\n",(0,i.jsx)(n.h4,{id:"implicit-commits",children:"Implicit Commits"}),"\n",(0,i.jsxs)(n.p,{children:["When using the ",(0,i.jsx)(n.code,{children:"DB"})," facade's ",(0,i.jsx)(n.code,{children:"statement"})," methods within transactions, you must be careful to avoid statements that cause ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html",children:"implicit commits"}),". These statements will cause the database engine to indirectly commit the entire transaction, leaving TinyORM unaware of the database's transaction level. An example of such a statement is creating a database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::statement("create table users (name varchar(255) null)");\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Please refer to the MySQL manual for ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html",children:"a list of all statements"})," that trigger implicit commits."]}),"\n",(0,i.jsx)(n.h3,{id:"using-multiple-database-connections",children:"Using Multiple Database Connections"}),"\n",(0,i.jsxs)(n.p,{children:["You can configure multiple database connections at once during ",(0,i.jsx)(n.code,{children:"DatabaseManager"})," instantiation using the ",(0,i.jsx)(n.code,{children:"DB::create"})," overload, where the first argument is a hash of multiple connections and is of type ",(0,i.jsx)(n.code,{children:"QHash"})," and the second argument is the name of the default connection:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"mysql", {\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_MYSQL_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_MYSQL_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_MYSQL_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_MYSQL_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_MYSQL_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_MYSQL_COLLATION", "utf8mb4_0900_ai_ci")},\n {"strict", true},\n {"options", QVariantHash()},\n }},\n {"sqlite", {\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_SQLITE_DATABASE", "")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_SQLITE_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n {"prefix", ""},\n }},\n}, "mysql");\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If your application needs to use multiple connections, you may access each connection via the ",(0,i.jsx)(n.code,{children:"connection"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade. The connection name passed to the ",(0,i.jsx)(n.code,{children:"connection"})," method should correspond to one of the connections key listed in your configuration:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto query = DB::connection("mysql_test").select(...);\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You may access the raw underlying ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," instance of a connection using the ",(0,i.jsx)(n.code,{children:"getSqlQuery"})," method on a connection instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto query = DB::connection().getSqlQuery();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Or you can use the shortcut method ",(0,i.jsx)(n.code,{children:"sqlQuery"})," provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto query = DB::sqlQuery();\n"})}),"\n",(0,i.jsx)(n.h2,{id:"database-transactions",children:"Database Transactions"}),"\n",(0,i.jsx)(n.h4,{id:"manually-using-transactions",children:"Manually Using Transactions"}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to begin a transaction manually and have complete control over rollbacks and commits, you may use the ",(0,i.jsx)(n.code,{children:"beginTransaction"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nDB::beginTransaction();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You can rollback the transaction via the ",(0,i.jsx)(n.code,{children:"rollBack"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::rollBack();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Lastly, you can commit a transaction via the ",(0,i.jsx)(n.code,{children:"commit"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::commit();\n"})}),"\n",(0,i.jsx)(n.p,{children:"All transaction methods accept a connection name as the optional argument:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::beginTransaction("mysql_test");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"DB"})," facade's transaction methods control the transactions for both the ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," and ",(0,i.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"multi-threading-support",children:"Multi-threading support"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"TinyORM"})," supports multi-threading for the ",(0,i.jsx)(n.code,{children:"MSVC"})," and ",(0,i.jsx)(n.code,{children:"GCC"})," on Linux compilers. Multi-threading is disabled for the ",(0,i.jsx)(n.code,{children:"Clang <14.0.3"})," compiler on MSYS2, ",(0,i.jsx)(n.code,{children:"Clang <14.0.4"})," on Linux and for the ",(0,i.jsx)(n.code,{children:"GCC"})," compiler on MSYS2. The reason are bugs in the ",(0,i.jsx)(n.code,{children:"TLS"})," wrapper that is generated by the ",(0,i.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/keyword/thread_local",children:(0,i.jsx)(n.code,{children:"thread_local"})})," keyword."]}),"\n",(0,i.jsx)(n.p,{children:"A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread where the connection was created is not supported."}),"\n",(0,i.jsxs)(n.p,{children:["In addition, the third party libraries used by the ",(0,i.jsx)(n.code,{children:"QSqlDrivers"})," can impose further restrictions on using the SQL Module in a multithreaded program."]}),"\n",(0,i.jsxs)(n.p,{children:["In short, if you create a ",(0,i.jsx)(n.code,{children:"DB::connection"})," in some thread then you have to use this connection only from this particular thread and of course all queries that will be executed on this connection."]}),"\n",(0,i.jsx)(n.p,{children:"If you want to execute some query from another thread for the same connection then you have to create a new connection first and if you have a new connection you can send a query from this new thread to the database."}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.a,{href:"/database/migrations#tables",children:(0,i.jsx)(n.code,{children:"schema builder"})})," and ",(0,i.jsx)(n.a,{href:"/database/migrations",children:(0,i.jsx)(n.code,{children:"migrations"})})," don't support multi-threading."]})})]})}function q(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(L,{...e})}):L(e)}},9365:(e,n,t)=>{t.d(n,{A:()=>s});t(6540);var i=t(4164);const r={tabItem:"tabItem_Ymn6"};var a=t(4848);function s(e){let{children:n,hidden:t,className:s}=e;return(0,a.jsx)("div",{role:"tabpanel",className:(0,i.A)(r.tabItem,s),hidden:t,children:n})}},1470:(e,n,t)=>{t.d(n,{A:()=>v});var i=t(6540),r=t(4164),a=t(3104),s=t(6347),o=t(205),l=t(7485),c=t(1682),d=t(679);function h(e){return i.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,i.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:t}=e;return(0,i.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:t,attributes:i,default:r}}=e;return{value:n,label:t,attributes:i,default:r}}))}(t);return function(e){const n=(0,c.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,t])}function p(e){let{value:n,tabValues:t}=e;return t.some((e=>e.value===n))}function m(e){let{queryString:n=!1,groupId:t}=e;const r=(0,s.W6)(),a=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,l.aZ)(a),(0,i.useCallback)((e=>{if(!a)return;const n=new URLSearchParams(r.location.search);n.set(a,e),r.replace({...r.location,search:n.toString()})}),[a,r])]}function g(e){const{defaultValue:n,queryString:t=!1,groupId:r}=e,a=u(e),[s,l]=(0,i.useState)((()=>function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:t}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const i=t.find((e=>e.default))??t[0];if(!i)throw new Error("Unexpected error: 0 tabValues");return i.value}({defaultValue:n,tabValues:a}))),[c,h]=m({queryString:t,groupId:r}),[g,x]=function(e){let{groupId:n}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(n),[r,a]=(0,d.Dv)(t);return[r,(0,i.useCallback)((e=>{t&&a.set(e)}),[t,a])]}({groupId:r}),f=(()=>{const e=c??g;return p({value:e,tabValues:a})?e:null})();(0,o.A)((()=>{f&&l(f)}),[f]);return{selectedValue:s,selectValue:(0,i.useCallback)((e=>{if(!p({value:e,tabValues:a}))throw new Error(`Can't select invalid tab value=${e}`);l(e),h(e),x(e)}),[h,x,a]),tabValues:a}}var x=t(2303);const f={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=t(4848);function j(e){let{className:n,block:t,selectedValue:i,selectValue:s,tabValues:o}=e;const l=[],{blockElementScrollPositionUntilNextRender:c}=(0,a.a_)(),d=e=>{const n=e.currentTarget,t=l.indexOf(n),r=o[t].value;r!==i&&(c(n),s(r))},h=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{const t=l.indexOf(e.currentTarget)+1;n=l[t]??l[0];break}case"ArrowLeft":{const t=l.indexOf(e.currentTarget)-1;n=l[t]??l[l.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":t},n),children:o.map((e=>{let{value:n,label:t,attributes:a}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:i===n?0:-1,"aria-selected":i===n,ref:e=>l.push(e),onKeyDown:h,onClick:d,...a,className:(0,r.A)("tabs__item",f.tabItem,a?.className,{"tabs__item--active":i===n}),children:t??n},n)}))})}function S(e){let{lazy:n,children:t,selectedValue:a}=e;const s=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){const e=s.find((e=>e.props.value===a));return e?(0,i.cloneElement)(e,{className:(0,r.A)("margin-top--md",e.props.className)}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:s.map(((e,n)=>(0,i.cloneElement)(e,{key:n,hidden:e.props.value!==a})))})}function y(e){const n=g(e);return(0,b.jsxs)("div",{className:(0,r.A)("tabs-container",f.tabList),children:[(0,b.jsx)(j,{...n,...e}),(0,b.jsx)(S,{...n,...e})]})}function v(e){const n=(0,x.A)();return(0,b.jsx)(y,{...e,children:h(e.children)},String(n))}},7324:(e,n,t)=>{t.d(n,{$E:()=>x,A3:()=>b,CW:()=>f,Dx:()=>d,F4:()=>u,Fi:()=>c,J_:()=>v,LQ:()=>j,Lf:()=>_,OO:()=>r,Q7:()=>S,b:()=>o,cy:()=>l,gg:()=>m,kl:()=>p,os:()=>h,pW:()=>a,ux:()=>g,vf:()=>i,xj:()=>s,xt:()=>y});const i="shell",r="database",a="application",s="bash",o="pwsh",l="zsh",c="maria",d="mysql",h="postgres",u="sqlite",p="application",m="bash",g="pwsh",x="zsh",f="MariaDB",b="MySQL",j="PostgreSQL",S="SQLite",y="tinyorm.org",v="$HOME/Code/c/",_="$env:USERPROFILE\\Code\\c\\"},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>o});var i=t(6540);const r={},a=i.createContext(r);function s(e){const n=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),i.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/ba3d4959.ef27b442.js b/assets/js/ba3d4959.ef27b442.js deleted file mode 100644 index 17e5a98b6..000000000 --- a/assets/js/ba3d4959.ef27b442.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[170],{2512:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>Q,contentTitle:()=>_,default:()=>q,frontMatter:()=>v,metadata:()=>T,toc:()=>D});var i=t(4848),r=t(8453),a=t(8774),s=t(9365),o=t(1470),l=t(6540);let c=null,d=null;function h(){const[e,n]=(0,l.useState)(!1),[t,r]=(0,l.useState)(!1);return(0,l.useEffect)((()=>(u(),()=>{u()})),[]),(0,i.jsxs)("form",{children:[(0,i.jsxs)("div",{className:"tinyorm-configuration-row",children:[(0,i.jsx)("label",{htmlFor:"tinyorm-toggle-full",children:"Full configuration"}),(0,i.jsx)("input",{id:"tinyorm-toggle-full",type:"checkbox",checked:e,onChange:()=>n(p),title:"Show full configuration example"})]}),(0,i.jsxs)("div",{className:"tinyorm-configuration-row",children:[(0,i.jsx)("label",{htmlFor:"tinyorm-toggle-prefix",children:"Prefix environment"}),(0,i.jsx)("input",{id:"tinyorm-toggle-prefix",type:"checkbox",checked:t,onChange:()=>r(S),title:"Prefix all environment variables by the database type"})]})]})}function u(){c=null,d=null}function p(e){const n=c||(c=document.getElementById("tinyorm-configuration")?.querySelectorAll(".tabs-container")),t=!e;if(!n)return e;if(2!==n.length)throw new Error(`Wrong number of .tabs-container (!== 2) found in the toggle configuration feature, found ${n.length}.`);return t?(n[0].style.display="none",n[1].style.display="block"):(n[0].style.display="block",n[1].style.display="none"),!e}const m='"DB_',g="MARIA",x="MYSQL",f="PGSQL",b="SQLITE",j=[x,f,b,g,x,f,b,g];function S(e){const n=function(){if(d)return d;const e=document.getElementById("tinyorm-configuration")?.querySelectorAll(".prism-code > code");if(!e)return e;if(8!==e.length)throw new Error(`Wrong number of .prism-code > code (!== 8) found in the prefix env. feature, found ${e.length}.`);return d=new Array(e.length),e.forEach(((e,n)=>{d[n]=Array.from(e.querySelectorAll(".token.string")).filter((e=>e?.textContent.startsWith(m)))})),d}(),t=!e;return n?(n.forEach(((e,n)=>{e.forEach((e=>{const i=e.textContent,r=`${m}${j[n]}_`;if(t)e.textContent=`${r}${i.substring(4)}`;else{if(!i.startsWith(r))throw new Error(`Token doesn't start with the '${r}' prefix.`);e.textContent=`${m}${i.substring(r.length)}`}}))})),!e):e}var y=t(7324);const v={sidebar_position:0,sidebar_label:"Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",keywords:["c++ orm","database","getting started","tinyorm"]},_="Database: Getting Started",T={id:"database/getting-started",title:"Database: Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",source:"@site/docs/database/getting-started.mdx",sourceDirName:"database",slug:"/database/getting-started",permalink:"/database/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:"TinyORM makes interacting with a database extremely simple using raw SQL, a fluent query builder, and the TinyORM. It provides first-party support for four databases MySQL/MariaDB, PostgreSQL, and SQLite.",keywords:["c++ orm","database","getting started","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\ude80 Supported Compilers",permalink:"/supported-compilers"},next:{title:"Query Builder",permalink:"/database/query-builder"}},Q={},D=[{value:"Introduction",id:"introduction",level:2},{value:"Configuration",id:"configuration",level:3},{value:"SQLite Configuration",id:"sqlite-configuration",level:4},{value:"SSL Connections",id:"ssl-connections",level:3},{value:"MySQL",id:"mysql",level:5},{value:"PostgreSQL",id:"postgresql",level:5},{value:"Running SQL Queries",id:"running-sql-queries",level:2},{value:"Running A Select Query",id:"running-a-select-query",level:4},{value:"Selecting Scalar Values",id:"selecting-scalar-values",level:4},{value:"Running An Insert Statement",id:"running-an-insert-statement",level:4},{value:"Running An Update Statement",id:"running-an-update-statement",level:4},{value:"Running A Delete Statement",id:"running-a-delete-statement",level:4},{value:"Running A General Statement",id:"running-a-general-statement",level:4},{value:"Running An Unprepared Statement",id:"running-an-unprepared-statement",level:4},{value:"Implicit Commits",id:"implicit-commits",level:4},{value:"Using Multiple Database Connections",id:"using-multiple-database-connections",level:3},{value:"Database Transactions",id:"database-transactions",level:2},{value:"Manually Using Transactions",id:"manually-using-transactions",level:4},{value:"Multi-threading support",id:"multi-threading-support",level:2}];function L(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"database-getting-started",children:"Database: Getting Started"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#configuration",children:"Configuration"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#ssl-connections",children:"SSL Connections"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#running-sql-queries",children:"Running SQL Queries"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-multiple-database-connections",children:"Using Multiple Database Connections"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#database-transactions",children:"Database Transactions"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#multi-threading-support",children:"Multi-threading support"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{class:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(n.p,{children:["Almost every modern application interacts with a database. TinyORM makes interacting with a database extremely simple using raw SQL, a ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"fluent query builder"}),", and the ",(0,i.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),". Currently, TinyORM provides first-party support for four databases:"]}),"\n",(0,i.jsx)("div",{id:"databases-supported-versions",children:(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["MySQL ",(0,i.jsx)(n.code,{children:">=5.7"})," (",(0,i.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/MySQL#Release_history",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["MariaDB ",(0,i.jsx)(n.code,{children:">=10.3"})," (",(0,i.jsx)(n.a,{href:"https://mariadb.org/about/#maintenance-policy",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["PostgreSQL ",(0,i.jsx)(n.code,{children:">=11"})," (",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/support/versioning/",children:"Version Policy"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["SQLite ",(0,i.jsx)(n.code,{children:">=3.8.8"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["native rename column ",(0,i.jsx)(n.code,{children:">=3.25.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/lang_altertable.html#alter_table_rename_column",children:"docs"})," , ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_25_0.html",children:"release notes"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["native drop column ",(0,i.jsx)(n.code,{children:">=3.35.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/lang_altertable.html#alter_table_drop_column",children:"docs"}),", ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_35_0.html",children:"release notes"}),")"]}),"\n",(0,i.jsxs)(n.li,{children:["generated columns ",(0,i.jsx)(n.code,{children:">=3.31.0"})," (",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/gencol.html",children:"docs"}),", ",(0,i.jsx)(n.a,{href:"https://www.sqlite.org/releaselog/3_31_0.html",children:"release notes"}),")"]}),"\n"]}),"\n"]}),"\n"]})}),"\n",(0,i.jsxs)(n.p,{children:["TinyORM internally uses ",(0,i.jsx)(n.code,{children:"QtSql"})," module, you can look for ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/sql-driver.html#supported-databases",children:"supported databases"}),"."]}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsx)(n.p,{children:"TinyORM's code is ready and designed to simply add support for the SQL Server."})}),"\n",(0,i.jsx)(n.h3,{id:"configuration",children:"Configuration"}),"\n",(0,i.jsxs)(n.p,{children:["You can create and configure a new database connection using the ",(0,i.jsx)(n.code,{children:"create"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsxs)("div",{id:"tinyorm-configuration",children:[(0,i.jsx)(h,{}),(0,i.jsxs)(o.A,{className:"tinyorm-configuration-basic",groupId:y.OO,children:[(0,i.jsx)(s.A,{value:y.Dx,label:y.A3,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_COLLATION", "utf8mb4_0900_ai_ci")},\n {"timezone", "+00:00"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"strict", true},\n {"engine", "InnoDB"},\n {"options", QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.os,label:y.LQ,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "5432")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"search_path", qEnvironmentVariable("DB_SEARCHPATH", "public")},\n {"username", qEnvironmentVariable("DB_USERNAME", "postgres")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8")},\n {"timezone", "UTC"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"options", QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.F4,label:y.Q7,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_DATABASE", "/example/example.sqlite3")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n /* Return a QDateTime/QDate with the correct time zone instead of the QString,\n only works when the qt_timezone isn\'t set to the DontConvert. */\n {"return_qdatetime", true},\n {"prefix", ""},\n {"prefix_indexes", false},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.Fi,label:y.CW,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_COLLATION", "utf8mb4_unicode_520_ci")},\n {"timezone", "+00:00"},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {"qt_timezone", QVariant::fromValue(QTimeZone::UTC)},\n {"prefix", ""},\n {"prefix_indexes", false},\n {"strict", true},\n {"engine", "InnoDB"},\n {"options", QVariantHash()},\n});\n'})})})]}),(0,i.jsxs)(o.A,{className:"tinyorm-configuration-full",groupId:y.OO,children:[(0,i.jsx)(s.A,{value:y.Dx,label:y.A3,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_USERNAME", ROOT)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_COLLATION", UTF8MB40900aici)},\n // SSL-related\n {ssl_ca, QStringLiteral("C:/mysql/data/ca.pem")},\n {ssl_cert, QStringLiteral("C:/mysql/data/client-cert.pem")},\n {ssl_key, QStringLiteral("C:/mysql/data/client-key.pem")},\n {ssl_mode, VerifyCA},\n // Or\n// {options, ConfigUtils::mysqlSslOptions()},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n {strict_, true},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // MySQL default is REPEATABLE READ for InnoDB\n {engine_, InnoDB},\n {Version, {}}, // Autodetect\n {options_, QVariantHash()},\n // Examples\n// {options_, QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT = 1 ; MYSQL_OPT_READ_TIMEOUT=1")},\n// {options_, QVariantHash {{QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT"), 1},\n// {QStringLiteral("MYSQL_OPT_READ_TIMEOUT"), 1}}},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.os,label:y.LQ,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QPSQL},\n {application_name, QStringLiteral("Example application")},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P5432)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {search_path, qEnvironmentVariable("DB_SEARCHPATH", PUBLIC)},\n {username_, qEnvironmentVariable("DB_USERNAME", postgres_)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8)},\n // SSL-related\n {sslmode_, QStringLiteral("verify-full")},\n {sslcert, QStringLiteral("C:/example/postgres.crt")},\n {sslkey, QStringLiteral("C:/example/postgres.key")},\n {sslrootcert, QStringLiteral("C:/example/root.crt")},\n // Or\n// {options_, ConfigUtils::postgresSslOptions()},\n {timezone_, UTC},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // Postgres default is READ COMMITTED\n// {synchronous_commit, QStringLiteral("off")}, // Postgres default is on\n // ConnectionFactory provides a default value for this, this is only for reference\n// {dont_drop, QStringList {spatial_ref_sys}},\n {options_, QVariantHash()},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.F4,label:y.Q7,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QSQLITE},\n {database_, qEnvironmentVariable("DB_DATABASE", "C:/SQLite/example.sqlite3")},\n {foreign_key_constraints, qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {check_database_exists, true},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n /* Return a QDateTime/QDate with the correct time zone instead of the QString,\n only works when the qt_timezone isn\'t set to the DontConvert. */\n {return_qdatetime, true},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n});\n'})})}),(0,i.jsx)(s.A,{value:y.Fi,label:y.CW,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\nusing namespace Orm::Constants; // NOLINT(google-build-using-namespace)\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {driver_, QMYSQL},\n {host_, qEnvironmentVariable("DB_HOST", H127001)},\n {port_, qEnvironmentVariable("DB_PORT", P3306)},\n {database_, qEnvironmentVariable("DB_DATABASE", EMPTY)},\n {username_, qEnvironmentVariable("DB_USERNAME", ROOT)},\n {password_, qEnvironmentVariable("DB_PASSWORD", EMPTY)},\n {charset_, qEnvironmentVariable("DB_CHARSET", UTF8MB4)},\n {collation_, qEnvironmentVariable("DB_COLLATION", UTF8MB4Unicode520ci)},\n // SSL-related\n {ssl_ca, QStringLiteral("C:/maria/data/ca.pem")},\n {ssl_cert, QStringLiteral("C:/maria/data/client-cert.pem")},\n {ssl_key, QStringLiteral("C:/maria/data/client-key.pem")},\n // Or\n// {options, ConfigUtils::mariaSslOptions()},\n {timezone_, TZ00},\n /* Specifies what time zone all QDateTime-s will have, the overridden default is\n the QTimeZone::UTC, set to the QTimeZone::LocalTime or\n QtTimeZoneType::DontConvert to use the system local time. */\n {qt_timezone, QVariant::fromValue(QTimeZone::UTC)},\n {prefix_, EMPTY},\n {prefix_indexes, false},\n {strict_, true},\n// {isolation_level, QStringLiteral("REPEATABLE READ")}, // MariaDB default is REPEATABLE READ for InnoDB\n {engine_, InnoDB},\n {Version, {}}, // Autodetect\n {options_, QVariantHash()},\n // Examples\n// {options_, QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT = 1 ; MYSQL_OPT_READ_TIMEOUT=1")},\n// {options_, QVariantHash {{QStringLiteral("MYSQL_OPT_CONNECT_TIMEOUT"), 1},\n// {QStringLiteral("MYSQL_OPT_READ_TIMEOUT"), 1}}},\n});\n'})})})]})]}),"\n",(0,i.jsxs)(n.p,{children:["The first argument is configuration hash which is of type ",(0,i.jsx)(n.code,{children:"QVariantHash"})," and the second argument specifies the name of the ",(0,i.jsx)(n.em,{children:"connection"}),", this connection will also be a ",(0,i.jsx)(n.em,{children:"default connection"}),". You can configure multiple database connections at once and choose the needed one before executing SQL query, section ",(0,i.jsx)(n.a,{href:"#using-multiple-database-connections",children:"Using Multiple Database Connections"})," describes how to create and use multiple database connections."]}),"\n",(0,i.jsxs)(n.p,{children:["You may also configure connection options by ",(0,i.jsx)(n.code,{children:"options"})," key as ",(0,i.jsx)(n.code,{children:"QVariantHash"})," or ",(0,i.jsx)(n.code,{children:"QString"}),", you can pass any ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/qsqldatabase.html#setConnectOptions",children:"connection options"})," supported by ",(0,i.jsx)(n.code,{children:"QSqlDatabase"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You can also configure ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/innodb-transaction-isolation-levels.html",children:"Transaction Isolation Levels"})," for MySQL connection with the ",(0,i.jsx)(n.code,{children:"isolation_level"})," configuration option."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"version"})," option is relevant only for the MySQL connections and you can save/avoid one database query (select version()) if you provide it manually. Based on this version will be decided which ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/src/orm/connectors/mysqlconnector.cpp#L182",children:"session variables"})," will be set if strict mode is enabled and whether to use an ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/src/orm/query/grammars/mysqlgrammar.cpp#L36",children:"alias"})," during the ",(0,i.jsx)(n.code,{children:"upsert"})," method call."]}),"\n",(0,i.jsxs)(n.p,{children:["Breaking values are as follows; use an upsert alias on the MySQL >=8.0.19 and remove the ",(0,i.jsx)(n.code,{children:"NO_AUTO_CREATE_USER"})," sql mode on the MySQL >=8.0.11 if the strict mode is enabled."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["A database connection is resolved lazily, which means that the connection configuration is only saved after the ",(0,i.jsx)(n.code,{children:"DB::create"})," method call. The connection will be resolved after you run some query or you can create it using the ",(0,i.jsx)(n.code,{children:"DB::connection"})," method."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can also use predefined string constants to avoid unnecessary ",(0,i.jsx)(n.code,{children:"QString"})," instantiations, as used in the ",(0,i.jsx)(n.code,{children:"tom"})," migrations ",(0,i.jsx)(n.a,{href:"/building/migrations#string-constants-example",children:"example"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["See ",(0,i.jsx)(n.a,{href:"/tinyorm/casts#date-casting-serialization-and-timezones",children:"Date Casting, Serialization & Timezones"})," if you have problems with ",(0,i.jsx)(n.code,{children:"qt_timezone"})," configuration option and ",(0,i.jsx)(n.code,{children:"QTimeZone"})," value on older ",(0,i.jsx)(n.code,{children:"Qt <6.5"})," versions."]})}),"\n",(0,i.jsx)(n.h4,{id:"sqlite-configuration",children:"SQLite Configuration"}),"\n",(0,i.jsxs)(n.p,{children:["SQLite databases are contained within a single file on your filesystem. You can create a new SQLite database using the ",(0,i.jsx)(n.code,{children:"touch"})," command in your terminal: ",(0,i.jsx)(n.code,{children:"touch database.sqlite3"}),". After the database has been created, you may configure SQLite database connection:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_DATABASE", "/absolute/path/to/database.sqlite3")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n {"prefix", ""},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"database"})," configuration value is the absolute path to the database. To enable foreign key constraints for SQLite connections, you should set the ",(0,i.jsx)(n.code,{children:"foreign_key_constraints"})," configuration value to ",(0,i.jsx)(n.code,{children:"true"}),", if this configuration value is not set, then the default of the SQLite driver will be used (currently the default is ",(0,i.jsx)(n.strong,{children:"disabled"}),")."]}),"\n",(0,i.jsxs)(n.p,{children:["If the ",(0,i.jsx)(n.code,{children:"check_database_exists"})," configuration value is set to the ",(0,i.jsx)(n.code,{children:"true"})," value, then the database connection throws an ",(0,i.jsx)(n.code,{children:"Orm::InvalidArgumentError"})," exception, when the SQLite database file doesn't exist. If it is set to the ",(0,i.jsx)(n.code,{children:"false"})," value and the SQLite database file doesn't exist, then it will be created for you by SQLite driver. The default value is ",(0,i.jsx)(n.code,{children:"true"}),"."]}),"\n",(0,i.jsx)(n.h3,{id:"ssl-connections",children:"SSL Connections"}),"\n",(0,i.jsxs)(n.p,{children:["SSL connections are supported for the ",(0,i.jsx)(n.code,{children:"MySQL"})," and ",(0,i.jsx)(n.code,{children:"PostgreSQL"})," databases. They can be set using the ",(0,i.jsx)(n.code,{children:"options"})," configuration option."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["This feature is heavily dependent on the underlying ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," module. What means that you can pass the same ",(0,i.jsx)(n.a,{href:"https://doc.qt.io/qt/qsqldatabase.html#setConnectOptions",children:"connection options"})," to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," that the ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," accepts."]})}),"\n",(0,i.jsx)(n.h5,{id:"mysql",children:"MySQL"}),"\n",(0,i.jsxs)(n.p,{children:["You have to pass the ",(0,i.jsx)(n.code,{children:"SSL_CA"}),", ",(0,i.jsx)(n.code,{children:"SSL_CERT"}),", ",(0,i.jsx)(n.code,{children:"SSL_KEY"}),", and ",(0,i.jsx)(n.code,{children:"MYSQL_OPT_SSL_MODE"})," options."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"options", QVariantHash({{"SSL_CA", "C:/mysql/data/ca.pem"},\n {"SSL_CERT", "C:/mysql/data/client-cert.pem"},\n {"SSL_KEY", "C:/mysql/data/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"}})},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"options", QVariantHash({{"SSL_CA", "~/.local/share/TinyORM/ssl/ca.pem"},\n {"SSL_CERT", "~/.local/share/TinyORM/ssl/client-cert.pem"},\n {"SSL_KEY", "~/.local/share/TinyORM/ssl/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"}})},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"ConfigUtils::mysqlSslOptions()"})," or the ",(0,i.jsx)(n.code,{children:"ConfigUtils::insertMySqlSslOptions()"})," methods to insert these options for you and define them using the ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_CA"}),", ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_CERT"}),", ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_KEY"}),", and ",(0,i.jsx)(n.code,{children:"DB_MYSQL_SSL_MODE"})," environment variables."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", ConfigUtils::mysqlSslOptions()},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You can define these SSL-related options in the top-level configuration, they will be copied to the ",(0,i.jsx)(n.code,{children:"options"})," option hash during configuration parsing. The top-level configuration takes precedence and overwrites the options in the ",(0,i.jsx)(n.code,{children:"options"})," hash."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"SSL_CA", "C:/mysql/data/ca.pem"},\n {"SSL_CERT", "C:/mysql/data/client-cert.pem"},\n {"SSL_KEY", "C:/mysql/data/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"SSL_CA", "~/.local/share/TinyORM/ssl/ca.pem"},\n {"SSL_CERT", "~/.local/share/TinyORM/ssl/client-cert.pem"},\n {"SSL_KEY", "~/.local/share/TinyORM/ssl/client-key.pem"},\n {"MYSQL_OPT_SSL_MODE", "VERIFY_CA"},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can take a look at the GitHub actions how the ",(0,i.jsx)(n.code,{children:"MySQL"})," certificates are generated in the CI pipeline for ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/msvc2022-qt6.yml",children:"Windows"})," and ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/linux-qt6.yml",children:"Linux"}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can also pass the ",(0,i.jsx)(n.code,{children:"QString"})," to the ",(0,i.jsx)(n.code,{children:"options"})," configuration separated by the ",(0,i.jsx)(n.code,{children:";"})," semicolon character and use the ",(0,i.jsx)(n.code,{children:"="})," to assign values."]})}),"\n",(0,i.jsx)(n.h5,{id:"postgresql",children:"PostgreSQL"}),"\n",(0,i.jsxs)(n.p,{children:["You have to pass the ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS",children:(0,i.jsx)(n.code,{children:"sslmode"})})," or the deprecated ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-REQUIRESSL",children:(0,i.jsx)(n.code,{children:"requiressl"})})," options."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"}})},\n});\n'})}),"\n",(0,i.jsxs)(n.p,{children:["And place your ",(0,i.jsx)(n.strong,{children:"client"})," certificates to the ",(0,i.jsx)(n.code,{children:"~/.postgres/"})," on ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-FILE-USAGE",children:"Linux"})," and ",(0,i.jsx)(n.code,{children:"$env:APPDATA/postgres/"})," on Windows. Everything is described in the PostgreSQL's ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-ssl.html",children:"libpq client"})," and ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/15/ssl-tcp.html#SSL-FILE-USAGE",children:"server"})," documentation."]}),"\n",(0,i.jsxs)(n.p,{children:["If you want to keep your ",(0,i.jsx)(n.strong,{children:"client"})," certificates in your own location, you can set the ",(0,i.jsx)(n.code,{children:"sslcert"}),", ",(0,i.jsx)(n.code,{children:"sslkey"}),", and ",(0,i.jsx)(n.code,{children:"sslrootcert"})," options."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"},\n // highlight-start\n {"sslcert", "C:/example/postgres.crt"},\n {"sslkey", "C:/example/postgres.key"},\n {"sslrootcert", "C:/example/root.crt"}})},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", QVariantHash({{"sslmode", "verify-full"},\n // highlight-start\n {"sslcert", "/example/postgres.crt"},\n {"sslkey", "/example/postgres.key"},\n {"sslrootcert", "/example/root.crt"}})},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You can define these SSL-related options in the top-level configuration, they will be copied to the ",(0,i.jsx)(n.code,{children:"options"})," option hash during a configuration parsing. The top-level configuration takes precedence and overwrites the options in the ",(0,i.jsx)(n.code,{children:"options"})," hash."]}),"\n",(0,i.jsxs)(o.A,{groupId:y.vf,children:[(0,i.jsx)(s.A,{value:y.b,label:y.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"sslmode", "verify-full"},\n {"sslcert", "C:/example/postgres.crt"},\n {"sslkey", "C:/example/postgres.key"},\n {"sslrootcert", "C:/example/root.crt"},\n // highlight-end\n});\n'})})}),(0,i.jsx)(s.A,{value:y.xj,label:y.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nusing Orm::DB;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-start\n {"sslmode", "verify-full"},\n {"sslcert", "/example/postgres.crt"},\n {"sslkey", "/example/postgres.key"},\n {"sslrootcert", "/example/root.crt"},\n // highlight-end\n});\n'})})})]}),"\n",(0,i.jsxs)(n.p,{children:["You may also use the ",(0,i.jsx)(n.code,{children:"ConfigUtils::postgresSslOptions()"})," or the ",(0,i.jsx)(n.code,{children:"ConfigUtils::insertPostgresSslOptions()"})," methods to insert the ",(0,i.jsx)(n.code,{children:"sslmode"}),", ",(0,i.jsx)(n.code,{children:"sslcert"}),", ",(0,i.jsx)(n.code,{children:"sslkey"}),", and ",(0,i.jsx)(n.code,{children:"sslrootcert"})," options for you and define them using the ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLMODE"}),", ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLCERT"}),", ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLKEY"}),", and ",(0,i.jsx)(n.code,{children:"DB_PGSQL_SSLROOTCERT"})," environment variable."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nusing Orm::DB;\n\nusing ConfigUtils = Orm::Utils::Configuration;\n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"driver", "QPSQL"},\n {"host", qEnvironmentVariable("DB_PGSQL_HOST", "127.0.0.1")},\n ...\n // highlight-next-line\n {"options", ConfigUtils::postgresSslOptions()},\n});\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["The PostgreSQL's libpq client library provides the ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.13.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLMODE"})}),", ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.16.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLCERT"})}),", ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.17.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLKEY"})}),", and ",(0,i.jsx)(n.a,{href:"https://www.postgresql.org/docs/current/libpq-envars.html#id-1.7.3.22.3.4.18.1.1",children:(0,i.jsx)(n.code,{children:"PGSSLROOTCERT"})})," environment variables, so you don't have to use TinyORM's ",(0,i.jsx)(n.code,{children:"options"})," configuration and may use these environment variables instead."]})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can take a look at the GitHub actions how the ",(0,i.jsx)(n.code,{children:"PostgreSQL"})," certificates are generated in the CI pipeline for ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/msvc2022-qt6.yml",children:"Windows"})," and ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/blob/main/.github/workflows/linux-qt6.yml",children:"Linux"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"running-sql-queries",children:"Running SQL Queries"}),"\n",(0,i.jsxs)(n.p,{children:["Once you have configured your database connection, you may run queries using the ",(0,i.jsx)(n.code,{children:"DB"})," facade. The ",(0,i.jsx)(n.code,{children:"DB"})," facade provides methods for each type of query: ",(0,i.jsx)(n.code,{children:"select"}),", ",(0,i.jsx)(n.code,{children:"update"}),", ",(0,i.jsx)(n.code,{children:"insert"}),", ",(0,i.jsx)(n.code,{children:"delete"}),", and ",(0,i.jsx)(n.code,{children:"statement"}),"."]}),"\n",(0,i.jsx)(n.h4,{id:"running-a-select-query",children:"Running A Select Query"}),"\n",(0,i.jsxs)(n.p,{children:["To run a basic SELECT query, you may use the ",(0,i.jsx)(n.code,{children:"select"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsxs)(n.p,{children:['auto users = DB::select("select * from users where active = ?", ',1,");"]}),"\n",(0,i.jsxs)(n.p,{children:["The first argument passed to the ",(0,i.jsx)(n.code,{children:"select"})," method is the SQL query, while the second argument is any parameter bindings that need to be bound to the query. Typically, these are the values of the ",(0,i.jsx)(n.code,{children:"where"})," clause constraints. Parameter binding provides protection against SQL injection."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"select"})," method returns a ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," containing the results of the query, where each result can be accessed by ",(0,i.jsx)(n.code,{children:"QSqlQuery::next"})," method. Look into the ",(0,i.jsx)(n.code,{children:"QSqlQuery"}),' documentation on how to obtain results from the "query". You may access each column\'s value by ',(0,i.jsx)(n.code,{children:"QSqlQuery::value"})," method. The first ",(0,i.jsx)(n.code,{children:"bool"})," return value is the value returned from ",(0,i.jsx)(n.code,{children:"QSqlQuery::exec"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto users = DB::select("select * from users");\n\nwhile(users.next())\n qDebug() << users.value("name").toString();\n'})}),"\n",(0,i.jsx)(n.h4,{id:"selecting-scalar-values",children:"Selecting Scalar Values"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes your database query may result in a single, scalar value. Instead of being required to retrieve the query's scalar result from a record instance, TinyORM allows you to retrieve this value directly using the ",(0,i.jsx)(n.code,{children:"scalar"})," shortcut method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto states = DB::scalar(\n "select count(case when state = \'pending\' then 1 end) as states "\n "from comments"\n);\n\n// With binding\nauto states = DB::scalar(\n "select count(case when state = ? then 1 end) as states from comments",\n {"pending"}\n);\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-insert-statement",children:"Running An Insert Statement"}),"\n",(0,i.jsxs)(n.p,{children:["To execute an ",(0,i.jsx)(n.code,{children:"insert"})," statement, you may use the ",(0,i.jsx)(n.code,{children:"insert"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade. Like ",(0,i.jsx)(n.code,{children:"select"}),", this method accepts the SQL query as its first argument and bindings as its second argument and returns ",(0,i.jsx)(n.code,{children:"QSqlQuery"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nDB::insert("insert into users (id, name) values (?, ?)", {1, "Marc"});\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-update-statement",children:"Running An Update Statement"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"update"})," method should be used to update existing records in the database. The number of rows affected by the statement and ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," is returned by the method as ",(0,i.jsx)(n.code,{children:"std::tuple"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto [affected, query] = DB::update(\n "update users set updated_at = ? where name = ?",\n {QDateTime::currentDateTimeUtc(), "Anita"}\n);\n\nif (!affected)\n qDebug() << "Any record was updated.";\n'})}),"\n",(0,i.jsx)(n.h4,{id:"running-a-delete-statement",children:"Running A Delete Statement"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"remove"})," method should be used to delete records from the database. Like ",(0,i.jsx)(n.code,{children:"update"}),", the number of affected rows and ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," will be returned by the method as ",(0,i.jsx)(n.code,{children:"std::tuple"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto [affected, query] = DB::remove("delete from users");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"delete"})," can not be used as the method name because it is the reserved word."]})}),"\n",(0,i.jsx)(n.h4,{id:"running-a-general-statement",children:"Running A General Statement"}),"\n",(0,i.jsxs)(n.p,{children:["Some database statements do not return any value. For these types of operations, you may use the ",(0,i.jsx)(n.code,{children:"statement"})," method on the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::statement("drop table users");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"DB::statement"})," method should be used for ",(0,i.jsx)(n.a,{href:"https://en.wikipedia.org/wiki/Data_definition_language",children:"DDL"}),' queries, don\'t use it for "select" queries because it internally calls ',(0,i.jsx)(n.code,{children:"recordsHaveBeenModified"})," method."]})}),"\n",(0,i.jsx)(n.h4,{id:"running-an-unprepared-statement",children:"Running An Unprepared Statement"}),"\n",(0,i.jsxs)(n.p,{children:["Sometimes you may want to execute an SQL statement without binding any values. You may use the ",(0,i.jsx)(n.code,{children:"DB"})," facade's ",(0,i.jsx)(n.code,{children:"unprepared"})," method to accomplish this:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::unprepared(\"update users set votes = 100 where name = 'Dries'\");\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsx)(n.p,{children:"Since unprepared statements do not bind parameters, they may be vulnerable to SQL injection. You should never allow user controlled values within an unprepared statement."})}),"\n",(0,i.jsx)(n.h4,{id:"implicit-commits",children:"Implicit Commits"}),"\n",(0,i.jsxs)(n.p,{children:["When using the ",(0,i.jsx)(n.code,{children:"DB"})," facade's ",(0,i.jsx)(n.code,{children:"statement"})," methods within transactions, you must be careful to avoid statements that cause ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html",children:"implicit commits"}),". These statements will cause the database engine to indirectly commit the entire transaction, leaving TinyORM unaware of the database's transaction level. An example of such a statement is creating a database table:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::statement("create table users (name varchar(255) null)");\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Please refer to the MySQL manual for ",(0,i.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/implicit-commit.html",children:"a list of all statements"})," that trigger implicit commits."]}),"\n",(0,i.jsx)(n.h3,{id:"using-multiple-database-connections",children:"Using Multiple Database Connections"}),"\n",(0,i.jsxs)(n.p,{children:["You can configure multiple database connections at once during ",(0,i.jsx)(n.code,{children:"DatabaseManager"})," instantiation using the ",(0,i.jsx)(n.code,{children:"DB::create"})," overload, where the first argument is a hash of multiple connections and is of type ",(0,i.jsx)(n.code,{children:"QHash"})," and the second argument is the name of the default connection:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Ownership of a shared_ptr()\nauto manager = DB::create({\n {"mysql", {\n {"driver", "QMYSQL"},\n {"host", qEnvironmentVariable("DB_MYSQL_HOST", "127.0.0.1")},\n {"port", qEnvironmentVariable("DB_MYSQL_PORT", "3306")},\n {"database", qEnvironmentVariable("DB_MYSQL_DATABASE", "")},\n {"username", qEnvironmentVariable("DB_MYSQL_USERNAME", "root")},\n {"password", qEnvironmentVariable("DB_MYSQL_PASSWORD", "")},\n {"charset", qEnvironmentVariable("DB_MYSQL_CHARSET", "utf8mb4")},\n {"collation", qEnvironmentVariable("DB_MYSQL_COLLATION", "utf8mb4_0900_ai_ci")},\n {"strict", true},\n {"options", QVariantHash()},\n }},\n {"sqlite", {\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("DB_SQLITE_DATABASE", "")},\n {"foreign_key_constraints", qEnvironmentVariable("DB_SQLITE_FOREIGN_KEYS", "true")},\n {"check_database_exists", true},\n {"prefix", ""},\n }},\n}, "mysql");\n'})}),"\n",(0,i.jsxs)(n.p,{children:["If your application needs to use multiple connections, you may access each connection via the ",(0,i.jsx)(n.code,{children:"connection"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade. The connection name passed to the ",(0,i.jsx)(n.code,{children:"connection"})," method should correspond to one of the connections key listed in your configuration:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto query = DB::connection("mysql_test").select(...);\n'})}),"\n",(0,i.jsxs)(n.p,{children:["You may access the raw underlying ",(0,i.jsx)(n.code,{children:"QSqlQuery"})," instance of a connection using the ",(0,i.jsx)(n.code,{children:"getSqlQuery"})," method on a connection instance:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto query = DB::connection().getSqlQuery();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Or you can use the shortcut method ",(0,i.jsx)(n.code,{children:"sqlQuery"})," provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"auto query = DB::sqlQuery();\n"})}),"\n",(0,i.jsx)(n.h2,{id:"database-transactions",children:"Database Transactions"}),"\n",(0,i.jsx)(n.h4,{id:"manually-using-transactions",children:"Manually Using Transactions"}),"\n",(0,i.jsxs)(n.p,{children:["If you would like to begin a transaction manually and have complete control over rollbacks and commits, you may use the ",(0,i.jsx)(n.code,{children:"beginTransaction"})," method provided by the ",(0,i.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"#include \n\nDB::beginTransaction();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["You can rollback the transaction via the ",(0,i.jsx)(n.code,{children:"rollBack"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::rollBack();\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Lastly, you can commit a transaction via the ",(0,i.jsx)(n.code,{children:"commit"})," method:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:"DB::commit();\n"})}),"\n",(0,i.jsx)(n.p,{children:"All transaction methods accept a connection name as the optional argument:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",children:'DB::beginTransaction("mysql_test");\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"DB"})," facade's transaction methods control the transactions for both the ",(0,i.jsx)(n.a,{href:"/database/query-builder",children:"query builder"})," and ",(0,i.jsx)(n.a,{href:"/tinyorm/getting-started",children:"TinyORM"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"multi-threading-support",children:"Multi-threading support"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"TinyORM"})," supports multi-threading for the ",(0,i.jsx)(n.code,{children:"MSVC"})," and ",(0,i.jsx)(n.code,{children:"GCC"})," on Linux compilers. Multi-threading is disabled for the ",(0,i.jsx)(n.code,{children:"Clang <14.0.3"})," compiler on MSYS2, ",(0,i.jsx)(n.code,{children:"Clang <14.0.4"})," on Linux and for the ",(0,i.jsx)(n.code,{children:"GCC"})," compiler on MSYS2. The reason are bugs in the ",(0,i.jsx)(n.code,{children:"TLS"})," wrapper that is generated by the ",(0,i.jsx)(n.a,{href:"https://en.cppreference.com/w/cpp/keyword/thread_local",children:(0,i.jsx)(n.code,{children:"thread_local"})})," keyword."]}),"\n",(0,i.jsx)(n.p,{children:"A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread where the connection was created is not supported."}),"\n",(0,i.jsxs)(n.p,{children:["In addition, the third party libraries used by the ",(0,i.jsx)(n.code,{children:"QSqlDrivers"})," can impose further restrictions on using the SQL Module in a multithreaded program."]}),"\n",(0,i.jsxs)(n.p,{children:["In short, if you create a ",(0,i.jsx)(n.code,{children:"DB::connection"})," in some thread then you have to use this connection only from this particular thread and of course all queries that will be executed on this connection."]}),"\n",(0,i.jsx)(n.p,{children:"If you want to execute some query from another thread for the same connection then you have to create a new connection first and if you have a new connection you can send a query from this new thread to the database."}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.a,{href:"/database/migrations#tables",children:(0,i.jsx)(n.code,{children:"schema builder"})})," and ",(0,i.jsx)(n.a,{href:"/database/migrations",children:(0,i.jsx)(n.code,{children:"migrations"})})," don't support multi-threading."]})})]})}function q(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(L,{...e})}):L(e)}},9365:(e,n,t)=>{t.d(n,{A:()=>s});t(6540);var i=t(4164);const r={tabItem:"tabItem_Ymn6"};var a=t(4848);function s(e){let{children:n,hidden:t,className:s}=e;return(0,a.jsx)("div",{role:"tabpanel",className:(0,i.A)(r.tabItem,s),hidden:t,children:n})}},1470:(e,n,t)=>{t.d(n,{A:()=>v});var i=t(6540),r=t(4164),a=t(3104),s=t(6347),o=t(205),l=t(7485),c=t(1682),d=t(679);function h(e){return i.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,i.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:t}=e;return(0,i.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:t,attributes:i,default:r}}=e;return{value:n,label:t,attributes:i,default:r}}))}(t);return function(e){const n=(0,c.X)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,t])}function p(e){let{value:n,tabValues:t}=e;return t.some((e=>e.value===n))}function m(e){let{queryString:n=!1,groupId:t}=e;const r=(0,s.W6)(),a=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,l.aZ)(a),(0,i.useCallback)((e=>{if(!a)return;const n=new URLSearchParams(r.location.search);n.set(a,e),r.replace({...r.location,search:n.toString()})}),[a,r])]}function g(e){const{defaultValue:n,queryString:t=!1,groupId:r}=e,a=u(e),[s,l]=(0,i.useState)((()=>function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:t}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const i=t.find((e=>e.default))??t[0];if(!i)throw new Error("Unexpected error: 0 tabValues");return i.value}({defaultValue:n,tabValues:a}))),[c,h]=m({queryString:t,groupId:r}),[g,x]=function(e){let{groupId:n}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(n),[r,a]=(0,d.Dv)(t);return[r,(0,i.useCallback)((e=>{t&&a.set(e)}),[t,a])]}({groupId:r}),f=(()=>{const e=c??g;return p({value:e,tabValues:a})?e:null})();(0,o.A)((()=>{f&&l(f)}),[f]);return{selectedValue:s,selectValue:(0,i.useCallback)((e=>{if(!p({value:e,tabValues:a}))throw new Error(`Can't select invalid tab value=${e}`);l(e),h(e),x(e)}),[h,x,a]),tabValues:a}}var x=t(2303);const f={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=t(4848);function j(e){let{className:n,block:t,selectedValue:i,selectValue:s,tabValues:o}=e;const l=[],{blockElementScrollPositionUntilNextRender:c}=(0,a.a_)(),d=e=>{const n=e.currentTarget,t=l.indexOf(n),r=o[t].value;r!==i&&(c(n),s(r))},h=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{const t=l.indexOf(e.currentTarget)+1;n=l[t]??l[0];break}case"ArrowLeft":{const t=l.indexOf(e.currentTarget)-1;n=l[t]??l[l.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":t},n),children:o.map((e=>{let{value:n,label:t,attributes:a}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:i===n?0:-1,"aria-selected":i===n,ref:e=>l.push(e),onKeyDown:h,onClick:d,...a,className:(0,r.A)("tabs__item",f.tabItem,a?.className,{"tabs__item--active":i===n}),children:t??n},n)}))})}function S(e){let{lazy:n,children:t,selectedValue:r}=e;const a=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){const e=a.find((e=>e.props.value===r));return e?(0,i.cloneElement)(e,{className:"margin-top--md"}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:a.map(((e,n)=>(0,i.cloneElement)(e,{key:n,hidden:e.props.value!==r})))})}function y(e){const n=g(e);return(0,b.jsxs)("div",{className:(0,r.A)("tabs-container",f.tabList),children:[(0,b.jsx)(j,{...n,...e}),(0,b.jsx)(S,{...n,...e})]})}function v(e){const n=(0,x.A)();return(0,b.jsx)(y,{...e,children:h(e.children)},String(n))}},7324:(e,n,t)=>{t.d(n,{$E:()=>x,A3:()=>b,CW:()=>f,Dx:()=>d,F4:()=>u,Fi:()=>c,J_:()=>v,LQ:()=>j,Lf:()=>_,OO:()=>r,Q7:()=>S,b:()=>o,cy:()=>l,gg:()=>m,kl:()=>p,os:()=>h,pW:()=>a,ux:()=>g,vf:()=>i,xj:()=>s,xt:()=>y});const i="shell",r="database",a="application",s="bash",o="pwsh",l="zsh",c="maria",d="mysql",h="postgres",u="sqlite",p="application",m="bash",g="pwsh",x="zsh",f="MariaDB",b="MySQL",j="PostgreSQL",S="SQLite",y="tinyorm.org",v="$HOME/Code/c/",_="$env:USERPROFILE\\Code\\c\\"},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>o});var i=t(6540);const r={},a=i.createContext(r);function s(e){const n=i.useContext(a);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),i.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/cb1e72f9.206d093e.js b/assets/js/cb1e72f9.206d093e.js deleted file mode 100644 index 96f4202e9..000000000 --- a/assets/js/cb1e72f9.206d093e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[258],{6349:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>t,metadata:()=>a,toc:()=>o});var r=n(4848),s=n(8453),d=n(8774);const t={sidebar_position:0,sidebar_label:"Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",keywords:["c++ orm","database","getting started","tinydrivers","sql drivers"]},l="TinyDrivers: Getting Started",a={id:"tinydrivers/getting-started",title:"TinyDrivers: Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",source:"@site/docs/tinydrivers/getting-started.mdx",sourceDirName:"tinydrivers",slug:"/tinydrivers/getting-started",permalink:"/tinydrivers/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",keywords:["c++ orm","database","getting started","tinydrivers","sql drivers"]},sidebar:"tinyormSidebar",previous:{title:"Serialization",permalink:"/tinyorm/serialization"},next:{title:"TinyORM",permalink:"/building/tinyorm"}},c={},o=[{value:"Introduction",id:"introduction",level:2},{value:"Features summary",id:"features-summary",level:5},{value:"Differences from QtSql",id:"differences-from-qtsql",level:2},{value:"Naming conventions",id:"naming-conventions",level:5},{value:"MySQL driver",id:"mysql-driver",level:5},{value:"Removed features",id:"removed-features",level:5},{value:"Missing features",id:"missing-features",level:5},{value:"Build system",id:"build-system",level:3},{value:"The Shared library build",id:"the-shared-library-build",level:5},{value:"The Static build",id:"the-static-build",level:5},{value:"The Loadable SQL drivers build",id:"the-loadable-sql-drivers-build",level:5},{value:"CMake/qmake build options",id:"cmakeqmake-build-options",level:4},{value:"For CMake",id:"for-cmake",level:5},{value:"For qmake",id:"for-qmake",level:5},{value:"Performance",id:"performance",level:3},{value:"Internals",id:"internals",level:2},{value:"SqlDatabase",id:"sqldatabase",level:5},{value:"Namespaces",id:"namespaces",level:5},{value:"Documentation",id:"documentation",level:5}];function h(e){const i={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.h1,{id:"tinydrivers-getting-started",children:"TinyDrivers: Getting Started"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.a,{href:"#differences-from-qtsql",children:"Differences from QtSql"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#build-system",children:"Build system"})}),"\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#performance",children:"Performance"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#internals",children:"Internals"})}),"\n"]}),"\n",(0,r.jsx)(i.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)("div",{class:"api-stability alert alert--success",children:(0,r.jsxs)(i.p,{children:[(0,r.jsx)(d.A,{to:"/stability#stability-indexes",children:(0,r.jsx)(i.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," library is an underlying SQL database layer for ",(0,r.jsx)(i.code,{children:"TinyORM"}),". It can be used instead of the ",(0,r.jsx)(i.code,{children:"QtSql"})," module, can be ",(0,r.jsx)("u",{children:(0,r.jsx)(i.strong,{children:"swapped"})})," at compile time, and has ",(0,r.jsx)(i.strong,{children:"1:1"})," API as the ",(0,r.jsx)(i.code,{children:"QtSql"})," module. \ud83d\ude2e Swapping is controlled by the ",(0,r.jsx)(i.code,{children:"qmake"})," and ",(0,r.jsx)(i.code,{children:"CMake"})," build system options."]}),"\n",(0,r.jsxs)(i.p,{children:["It was designed to drop the ",(0,r.jsx)(i.code,{children:"QtSql"})," dependency while maintaining backward compatibility and without the need for any code changes after the swap."]}),"\n",(0,r.jsx)(i.h5,{id:"features-summary",children:"Features summary"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:"both, normal and prepared statements are supported"}),"\n",(0,r.jsxs)(i.li,{children:["TLS/SSL connections using ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:(0,r.jsx)(i.code,{children:"MYSQL_OPT_SSL_MODE"})})," (verify_ca, verify_identity) \ud83d\udd25"]}),"\n",(0,r.jsxs)(i.li,{children:["setting many other connection options (see ",(0,r.jsx)(i.a,{href:"https://github.com/silverqx/TinyORM/blob/main/drivers/mysql/src/orm/drivers/mysql/mysqldriver_p.cpp",children:(0,r.jsx)(i.code,{children:"mysqldriver_p.cpp"})}),")"]}),"\n",(0,r.jsxs)(i.li,{children:["building and linking against the ",(0,r.jsx)(i.a,{href:"https://mariadb.com/kb/en/mariadb-connector-c/",children:(0,r.jsx)(i.code,{children:"MariaDB Connector/C"})})]}),"\n",(0,r.jsx)(i.li,{children:"transactions"}),"\n",(0,r.jsxs)(i.li,{children:["re-using the current ",(0,r.jsx)(i.code,{children:"SqlQuery"})," instance to re-execute the same or another query"]}),"\n",(0,r.jsx)(i.li,{children:"detaching from the result set (associated to release memory)"}),"\n",(0,r.jsxs)(i.li,{children:["query size, number of affected rows, last inserted ID, testing ",(0,r.jsx)(i.code,{children:"isNull()"}),", ..."]}),"\n",(0,r.jsxs)(i.li,{children:["all ",(0,r.jsx)(i.strong,{children:"3378 unit tests"})," passed \ud83d\ude2e"]}),"\n"]}),"\n",(0,r.jsx)(i.admonition,{type:"info",children:(0,r.jsxs)(i.p,{children:["Currently, only the ",(0,r.jsx)(i.code,{children:"MySQL"})," database driver is supported and finished."]})}),"\n",(0,r.jsx)(i.admonition,{type:"note",children:(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," library supports both build systems ",(0,r.jsx)(i.code,{children:"qmake"})," and also ",(0,r.jsx)(i.code,{children:"CMake"}),"."]})}),"\n",(0,r.jsx)(i.h2,{id:"differences-from-qtsql",children:"Differences from QtSql"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," doesn't return errors the the same way as the ",(0,r.jsx)(i.code,{children:"QtSql"})," module, which means return a ",(0,r.jsx)(i.code,{children:"bool"})," and if it's the result ",(0,r.jsx)(i.code,{children:"false"})," then obtain the ",(0,r.jsx)(i.code,{children:"SqlError"})," instance using the ",(0,r.jsx)(i.code,{children:"lastError()"})," method from ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," or ",(0,r.jsx)(i.code,{children:"SqlQuery"})," instances. Instead, it throws exceptions, and methods returning a ",(0,r.jsx)(i.code,{children:"bool"})," type to report an error state always return ",(0,r.jsx)(i.code,{children:"true"}),"."]}),"\n",(0,r.jsx)(i.h5,{id:"naming-conventions",children:"Naming conventions"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"QtSql"})," ",(0,r.jsx)("small",{children:"module"})," -> ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," ",(0,r.jsx)("small",{children:"library"})]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"QMYSQL"})," ",(0,r.jsx)("small",{children:"driver"})," -> ",(0,r.jsx)(i.code,{children:"TinyMySql"})," ",(0,r.jsx)("small",{children:"driver"})]}),"\n"]}),"\n",(0,r.jsx)(i.h5,{id:"mysql-driver",children:"MySQL driver"}),"\n",(0,r.jsxs)(i.p,{children:["The following describes the differences between ",(0,r.jsx)(i.code,{children:"QMYSQL"})," and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," drivers."]}),"\n",(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"QMYSQL"})," driver doesn't support setting ",(0,r.jsx)(i.code,{children:"MySQL"})," non-flag ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:"connection options"})," like ",(0,r.jsx)(i.code,{children:"MYSQL_OPT_RECONNECT"})," without the value, it needs to be defined with value like ",(0,r.jsx)(i.code,{children:"=1"})," or ",(0,r.jsx)(i.code,{children:"=TRUE"})," (case-sensitive), only real flag options like ",(0,r.jsx)(i.code,{children:"CLIENT_INTERACTIVE"})," can be set without the value and ",(0,r.jsx)(i.code,{children:"="})," character."]}),"\n",(0,r.jsxs)(i.p,{children:["On the other hand, the ",(0,r.jsx)(i.code,{children:"TinyMySql"})," driver allows setting non-flag ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:"connection options"})," options without the value and ",(0,r.jsx)(i.code,{children:"="})," character, which are considered enabled (ON or TRUE)."]}),"\n",(0,r.jsx)(i.h5,{id:"removed-features",children:"Removed features"}),"\n",(0,r.jsxs)(i.p,{children:["Simulation of prepared statements while calling ",(0,r.jsx)(i.code,{children:"SqlQuery::exec(QString)"}),", this functionality is useless because you can call regular prepared statements using ",(0,r.jsx)(i.code,{children:"SqlQuery::prepare(QString)"})," and then ",(0,r.jsx)(i.code,{children:"SqlQuery::exec()"}),"."]}),"\n",(0,r.jsx)(i.h5,{id:"missing-features",children:"Missing features"}),"\n",(0,r.jsxs)(i.p,{children:["Fetching multiple result sets using ",(0,r.jsx)(i.code,{children:"SqlQuery::nextResult()"}),". Multiple statement queries are supported they will be executed correctly (they can return multiple result sets), but only the first result set can be fetched currently. However, destroying multiple result sets is handled correctly."]}),"\n",(0,r.jsx)(i.h3,{id:"build-system",children:"Build system"}),"\n",(0,r.jsxs)(i.p,{children:["Another difference is that you can build the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," and its SQL drivers (",(0,r.jsx)(i.code,{children:"TinyMySql"}),") in 3 different ways; ",(0,r.jsx)(i.code,{children:"Shared"}),", ",(0,r.jsx)(i.code,{children:"Static"}),", and as a ",(0,r.jsx)(i.code,{children:"Loadable"})," library at runtime using ",(0,r.jsx)(i.code,{children:"LoadLibrary()"})," on Windows or ",(0,r.jsx)(i.code,{children:"dlopen()"})," on Linux."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-shared-library-build",children:["The ",(0,r.jsx)(i.code,{children:"Shared"})," library build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds two shared libraries, the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library that contains the core/common code and the ",(0,r.jsx)(i.code,{children:"TinyMySql"})," shared library that contains ",(0,r.jsx)(i.code,{children:"MySQL"})," implementation. The ",(0,r.jsx)(i.code,{children:"TinyOrm"})," links only against the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," is a private implementation."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-static-build",children:["The ",(0,r.jsx)(i.code,{children:"Static"})," build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds one ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," static archive that contains the core/common code and SQL drivers (",(0,r.jsx)(i.code,{children:"TinyMySql"}),"). This static library is linked or merged into the ",(0,r.jsx)(i.code,{children:"TinyOrm"})," shared or static library (both variants are supported)."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-loadable-sql-drivers-build",children:["The ",(0,r.jsx)(i.code,{children:"Loadable"})," SQL drivers build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds two shared libraries, the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library that contains the core/common code and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," shared library (module) that contains ",(0,r.jsx)(i.code,{children:"MySQL"})," implementation that is loaded at runtime using ",(0,r.jsx)(i.code,{children:"LoadLibrary()"})," on Windows or ",(0,r.jsx)(i.code,{children:"dlopen()"})," on Linux. The SQL driver library loader throws an exception if it cannot find this library at runtime."]}),"\n",(0,r.jsx)(i.admonition,{type:"info",children:(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"TinyMySql"})," links directly against the ",(0,r.jsx)(i.code,{children:"MySQL C connector"})," (",(0,r.jsx)(i.code,{children:"libmysql"})," or ",(0,r.jsx)(i.code,{children:"mysqlclient"})," library)."]})}),"\n",(0,r.jsxs)(i.h4,{id:"cmakeqmake-build-options",children:[(0,r.jsx)(i.code,{children:"CMake"}),"/",(0,r.jsx)(i.code,{children:"qmake"})," build options"]}),"\n",(0,r.jsxs)(i.h5,{id:"for-cmake",children:["For ",(0,r.jsx)(i.code,{children:"CMake"})]}),"\n",(0,r.jsxs)(i.p,{children:["See ",(0,r.jsx)(i.a,{href:"/building/tinyorm#cmake-build-options",children:"CMake build options"}),", related ",(0,r.jsx)(i.code,{children:"CMake"})," build options are:",(0,r.jsx)("br",{}),(0,r.jsx)(i.a,{href:"/building/tinyorm#BUILD_DRIVERS",children:(0,r.jsx)(i.code,{children:"BUILD_DRIVERS"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#BUILD_MYSQL_DRIVER",children:(0,r.jsx)(i.code,{children:"BUILD_MYSQL_DRIVER"})}),", and ",(0,r.jsx)(i.a,{href:"/building/tinyorm#DRIVERS_TYPE",children:(0,r.jsx)(i.code,{children:"DRIVERS_TYPE"})})]}),"\n",(0,r.jsxs)(i.p,{children:["To control shared and static build use ",(0,r.jsx)(i.a,{href:"https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html",children:(0,r.jsx)(i.code,{children:"BUILD_SHARED_LIBS"})})," ",(0,r.jsx)(i.code,{children:"CMake"})," configuration option."]}),"\n",(0,r.jsxs)(i.h5,{id:"for-qmake",children:["For ",(0,r.jsx)(i.code,{children:"qmake"})]}),"\n",(0,r.jsxs)(i.p,{children:["See ",(0,r.jsx)(i.a,{href:"/building/tinyorm#qmake-build-options",children:"qmake build options"}),", related ",(0,r.jsx)(i.code,{children:"qmake"})," configuration options are:",(0,r.jsx)("br",{}),(0,r.jsx)(i.a,{href:"/building/tinyorm#build_loadable_drivers",children:(0,r.jsx)(i.code,{children:"build_loadable_drivers"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_mysql_driver",children:(0,r.jsx)(i.code,{children:"build_mysql_driver"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_shared_drivers",children:(0,r.jsx)(i.code,{children:"build_shared_drivers"})}),", and ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_static_drivers",children:(0,r.jsx)(i.code,{children:"build_static_drivers"})})]}),"\n",(0,r.jsxs)(i.p,{children:["To control shared and static build use ",(0,r.jsx)(i.a,{href:"/building/tinyorm#qmake-static",children:(0,r.jsx)(i.code,{children:"static"})})," ",(0,r.jsx)(i.code,{children:"qmake"})," ",(0,r.jsx)(i.a,{href:"https://doc.qt.io/qt/qmake-variable-reference.html#config",children:"configuration option"}),"."]}),"\n",(0,r.jsx)(i.h3,{id:"performance",children:"Performance"}),"\n",(0,r.jsxs)(i.p,{children:["Performance is several milliseconds faster compared to ",(0,r.jsx)(i.code,{children:"QtSql"})," with the ",(0,r.jsx)(i.code,{children:"QMYSQL"})," driver. It was tuned using the ",(0,r.jsx)(i.code,{children:"KCacheGrind"})," to be so. It's ~40ms faster on ",(0,r.jsx)(i.a,{href:"https://github.com/silverqx/TinyOrmPlayground",children:(0,r.jsx)(i.code,{children:"TinyOrmPlayground"})})," project with ",(0,r.jsx)(i.strong,{children:"620"})," database queries compiled using ",(0,r.jsx)(i.code,{children:"GCC v13.2.1"})," Debug build on Linux. Similar results can be expected on other platforms but it's not guaranteed."]}),"\n",(0,r.jsxs)(i.p,{children:["This means performance is very similar to ",(0,r.jsx)(i.code,{children:"QtSql"}),". There is not much to speed up because ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," code is swift and 90% of the time is spent inside the ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/",children:(0,r.jsx)(i.code,{children:"MySQL C API"})})," because we always have to wait for the database server, especially when creating database connections using eg. ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-real-connect.html",children:(0,r.jsx)(i.code,{children:"mysql_real_connect()"})})," (this function is king among the slowest functions \ud83d\ude0e, which is understandable of course)."]}),"\n",(0,r.jsx)(i.h2,{id:"internals",children:"Internals"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," internal design can be divided into 3 different layers:"]}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:"Driver layer"}),"\n",(0,r.jsx)(i.li,{children:"SQL API layer"}),"\n",(0,r.jsx)(i.li,{children:"Public API layer"}),"\n"]}),"\n",(0,r.jsxs)(i.p,{children:["The Driver layer is eg. ",(0,r.jsx)(i.code,{children:"TinyMySql"})," library which is responsible for communicating with the underlying database driver (eg. ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/",children:(0,r.jsx)(i.code,{children:"MySQL C API"})}),")."]}),"\n",(0,r.jsx)(i.p,{children:"The SQL API layer is a semi-layer that glues everything up and sits between the Public interface API and the Driver layer."}),"\n",(0,r.jsxs)(i.p,{children:["The Public interface API layer are the end classes like ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," and ",(0,r.jsx)(i.code,{children:"SqlQuery"})," which are exposed to the end user."]}),"\n",(0,r.jsx)(i.h5,{id:"sqldatabase",children:"SqlDatabase"}),"\n",(0,r.jsxs)(i.p,{children:["One more thing worth mentioning is the ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," API. It's one class that has two responsibilities! All static methods act as the database connection manager and an instance of the ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," represents a physical database connection. It's not a good design because it breaks the ",(0,r.jsx)(i.a,{href:"https://en.wikipedia.org/wiki/Single_responsibility_principle",children:"Single Responsibility principle"}),", but it's what it is."]}),"\n",(0,r.jsx)(i.h5,{id:"namespaces",children:"Namespaces"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," classes are defined in the ",(0,r.jsx)(i.code,{children:"Orm::Drivers"})," namespace and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," classes in the ",(0,r.jsx)(i.code,{children:"Orm::Drivers::MySql"})," namespace."]}),"\n",(0,r.jsx)(i.h5,{id:"documentation",children:"Documentation"}),"\n",(0,r.jsxs)(i.p,{children:["For all other APIs you can follow the ",(0,r.jsx)(i.a,{href:"https://doc.qt.io/qt/qtsql-index.html",children:"QtSql documentation"})," as the API is 1:1. The exception is of course the build system, ",(0,r.jsx)(i.code,{children:"TinyOrm"})," has its own build system that doesn't follow the ",(0,r.jsx)(i.code,{children:"QtSql"})," module."]})]})}function u(e={}){const{wrapper:i}={...(0,s.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,i,n)=>{n.d(i,{R:()=>t,x:()=>l});var r=n(6540);const s={},d=r.createContext(s);function t(e){const i=r.useContext(d);return r.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),r.createElement(d.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/cb1e72f9.c32b3e2f.js b/assets/js/cb1e72f9.c32b3e2f.js new file mode 100644 index 000000000..e40e1de59 --- /dev/null +++ b/assets/js/cb1e72f9.c32b3e2f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[258],{6349:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>t,metadata:()=>a,toc:()=>o});var r=n(4848),s=n(8453),d=n(8774);const t={sidebar_position:0,sidebar_label:"Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",keywords:["c++ orm","database","getting started","tinydrivers","sql drivers"]},l="TinyDrivers: Getting Started",a={id:"tinydrivers/getting-started",title:"TinyDrivers: Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",source:"@site/docs/tinydrivers/getting-started.mdx",sourceDirName:"tinydrivers",slug:"/tinydrivers/getting-started",permalink:"/tinydrivers/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:0,frontMatter:{sidebar_position:0,sidebar_label:"Getting Started",description:"The TinyDrivers library is an underlying SQL database layer for TinyORM. It can be used instead of the QtSql module, can be swapped at compile time, and has 1:1 API as the QtSql module. Swapping is controlled by the qmake and CMake build system options. It was designed to drop the QtSql dependency while maintaining backward compatibility and without the need for any code changes after the swap.",keywords:["c++ orm","database","getting started","tinydrivers","sql drivers"]},sidebar:"tinyormSidebar",previous:{title:"Serialization",permalink:"/tinyorm/serialization"},next:{title:"TinyORM",permalink:"/building/tinyorm"}},c={},o=[{value:"Introduction",id:"introduction",level:2},{value:"Features summary",id:"features-summary",level:5},{value:"Differences from QtSql",id:"differences-from-qtsql",level:2},{value:"Naming conventions",id:"naming-conventions",level:5},{value:"MySQL driver",id:"mysql-driver",level:5},{value:"Removed features",id:"removed-features",level:5},{value:"Missing features",id:"missing-features",level:5},{value:"Build system",id:"build-system",level:3},{value:"The Shared library build",id:"the-shared-library-build",level:5},{value:"The Static build",id:"the-static-build",level:5},{value:"The Loadable SQL drivers build",id:"the-loadable-sql-drivers-build",level:5},{value:"CMake/qmake build options",id:"cmakeqmake-build-options",level:4},{value:"For CMake",id:"for-cmake",level:5},{value:"For qmake",id:"for-qmake",level:5},{value:"Performance",id:"performance",level:3},{value:"Internals",id:"internals",level:2},{value:"SqlDatabase",id:"sqldatabase",level:5},{value:"Namespaces",id:"namespaces",level:5},{value:"Documentation",id:"documentation",level:5}];function h(e){const i={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.header,{children:(0,r.jsx)(i.h1,{id:"tinydrivers-getting-started",children:"TinyDrivers: Getting Started"})}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.a,{href:"#differences-from-qtsql",children:"Differences from QtSql"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#build-system",children:"Build system"})}),"\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#performance",children:"Performance"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"#internals",children:"Internals"})}),"\n"]}),"\n",(0,r.jsx)(i.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)("div",{className:"api-stability alert alert--success",children:(0,r.jsxs)(i.p,{children:[(0,r.jsx)(d.A,{to:"/stability#stability-indexes",children:(0,r.jsx)(i.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," library is an underlying SQL database layer for ",(0,r.jsx)(i.code,{children:"TinyORM"}),". It can be used instead of the ",(0,r.jsx)(i.code,{children:"QtSql"})," module, can be ",(0,r.jsx)("u",{children:(0,r.jsx)(i.strong,{children:"swapped"})})," at compile time, and has ",(0,r.jsx)(i.strong,{children:"1:1"})," API as the ",(0,r.jsx)(i.code,{children:"QtSql"})," module. \ud83d\ude2e Swapping is controlled by the ",(0,r.jsx)(i.code,{children:"qmake"})," and ",(0,r.jsx)(i.code,{children:"CMake"})," build system options."]}),"\n",(0,r.jsxs)(i.p,{children:["It was designed to drop the ",(0,r.jsx)(i.code,{children:"QtSql"})," dependency while maintaining backward compatibility and without the need for any code changes after the swap."]}),"\n",(0,r.jsx)(i.h5,{id:"features-summary",children:"Features summary"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:"both, normal and prepared statements are supported"}),"\n",(0,r.jsxs)(i.li,{children:["TLS/SSL connections using ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:(0,r.jsx)(i.code,{children:"MYSQL_OPT_SSL_MODE"})})," (verify_ca, verify_identity) \ud83d\udd25"]}),"\n",(0,r.jsxs)(i.li,{children:["setting many other connection options (see ",(0,r.jsx)(i.a,{href:"https://github.com/silverqx/TinyORM/blob/main/drivers/mysql/src/orm/drivers/mysql/mysqldriver_p.cpp",children:(0,r.jsx)(i.code,{children:"mysqldriver_p.cpp"})}),")"]}),"\n",(0,r.jsxs)(i.li,{children:["building and linking against the ",(0,r.jsx)(i.a,{href:"https://mariadb.com/kb/en/mariadb-connector-c/",children:(0,r.jsx)(i.code,{children:"MariaDB Connector/C"})})]}),"\n",(0,r.jsx)(i.li,{children:"transactions"}),"\n",(0,r.jsxs)(i.li,{children:["re-using the current ",(0,r.jsx)(i.code,{children:"SqlQuery"})," instance to re-execute the same or another query"]}),"\n",(0,r.jsx)(i.li,{children:"detaching from the result set (associated to release memory)"}),"\n",(0,r.jsxs)(i.li,{children:["query size, number of affected rows, last inserted ID, testing ",(0,r.jsx)(i.code,{children:"isNull()"}),", ..."]}),"\n",(0,r.jsxs)(i.li,{children:["all ",(0,r.jsx)(i.strong,{children:"3378 unit tests"})," passed \ud83d\ude2e"]}),"\n"]}),"\n",(0,r.jsx)(i.admonition,{type:"info",children:(0,r.jsxs)(i.p,{children:["Currently, only the ",(0,r.jsx)(i.code,{children:"MySQL"})," database driver is supported and finished."]})}),"\n",(0,r.jsx)(i.admonition,{type:"note",children:(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," library supports both build systems ",(0,r.jsx)(i.code,{children:"qmake"})," and also ",(0,r.jsx)(i.code,{children:"CMake"}),"."]})}),"\n",(0,r.jsx)(i.h2,{id:"differences-from-qtsql",children:"Differences from QtSql"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," doesn't return errors the the same way as the ",(0,r.jsx)(i.code,{children:"QtSql"})," module, which means return a ",(0,r.jsx)(i.code,{children:"bool"})," and if it's the result ",(0,r.jsx)(i.code,{children:"false"})," then obtain the ",(0,r.jsx)(i.code,{children:"SqlError"})," instance using the ",(0,r.jsx)(i.code,{children:"lastError()"})," method from ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," or ",(0,r.jsx)(i.code,{children:"SqlQuery"})," instances. Instead, it throws exceptions, and methods returning a ",(0,r.jsx)(i.code,{children:"bool"})," type to report an error state always return ",(0,r.jsx)(i.code,{children:"true"}),"."]}),"\n",(0,r.jsx)(i.h5,{id:"naming-conventions",children:"Naming conventions"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"QtSql"})," ",(0,r.jsx)("small",{children:"module"})," -> ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," ",(0,r.jsx)("small",{children:"library"})]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"QMYSQL"})," ",(0,r.jsx)("small",{children:"driver"})," -> ",(0,r.jsx)(i.code,{children:"TinyMySql"})," ",(0,r.jsx)("small",{children:"driver"})]}),"\n"]}),"\n",(0,r.jsx)(i.h5,{id:"mysql-driver",children:"MySQL driver"}),"\n",(0,r.jsxs)(i.p,{children:["The following describes the differences between ",(0,r.jsx)(i.code,{children:"QMYSQL"})," and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," drivers."]}),"\n",(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"QMYSQL"})," driver doesn't support setting ",(0,r.jsx)(i.code,{children:"MySQL"})," non-flag ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:"connection options"})," like ",(0,r.jsx)(i.code,{children:"MYSQL_OPT_RECONNECT"})," without the value, it needs to be defined with value like ",(0,r.jsx)(i.code,{children:"=1"})," or ",(0,r.jsx)(i.code,{children:"=TRUE"})," (case-sensitive), only real flag options like ",(0,r.jsx)(i.code,{children:"CLIENT_INTERACTIVE"})," can be set without the value and ",(0,r.jsx)(i.code,{children:"="})," character."]}),"\n",(0,r.jsxs)(i.p,{children:["On the other hand, the ",(0,r.jsx)(i.code,{children:"TinyMySql"})," driver allows setting non-flag ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-options.html",children:"connection options"})," options without the value and ",(0,r.jsx)(i.code,{children:"="})," character, which are considered enabled (ON or TRUE)."]}),"\n",(0,r.jsx)(i.h5,{id:"removed-features",children:"Removed features"}),"\n",(0,r.jsxs)(i.p,{children:["Simulation of prepared statements while calling ",(0,r.jsx)(i.code,{children:"SqlQuery::exec(QString)"}),", this functionality is useless because you can call regular prepared statements using ",(0,r.jsx)(i.code,{children:"SqlQuery::prepare(QString)"})," and then ",(0,r.jsx)(i.code,{children:"SqlQuery::exec()"}),"."]}),"\n",(0,r.jsx)(i.h5,{id:"missing-features",children:"Missing features"}),"\n",(0,r.jsxs)(i.p,{children:["Fetching multiple result sets using ",(0,r.jsx)(i.code,{children:"SqlQuery::nextResult()"}),". Multiple statement queries are supported they will be executed correctly (they can return multiple result sets), but only the first result set can be fetched currently. However, destroying multiple result sets is handled correctly."]}),"\n",(0,r.jsx)(i.h3,{id:"build-system",children:"Build system"}),"\n",(0,r.jsxs)(i.p,{children:["Another difference is that you can build the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," and its SQL drivers (",(0,r.jsx)(i.code,{children:"TinyMySql"}),") in 3 different ways; ",(0,r.jsx)(i.code,{children:"Shared"}),", ",(0,r.jsx)(i.code,{children:"Static"}),", and as a ",(0,r.jsx)(i.code,{children:"Loadable"})," library at runtime using ",(0,r.jsx)(i.code,{children:"LoadLibrary()"})," on Windows or ",(0,r.jsx)(i.code,{children:"dlopen()"})," on Linux."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-shared-library-build",children:["The ",(0,r.jsx)(i.code,{children:"Shared"})," library build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds two shared libraries, the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library that contains the core/common code and the ",(0,r.jsx)(i.code,{children:"TinyMySql"})," shared library that contains ",(0,r.jsx)(i.code,{children:"MySQL"})," implementation. The ",(0,r.jsx)(i.code,{children:"TinyOrm"})," links only against the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," is a private implementation."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-static-build",children:["The ",(0,r.jsx)(i.code,{children:"Static"})," build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds one ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," static archive that contains the core/common code and SQL drivers (",(0,r.jsx)(i.code,{children:"TinyMySql"}),"). This static library is linked or merged into the ",(0,r.jsx)(i.code,{children:"TinyOrm"})," shared or static library (both variants are supported)."]}),"\n",(0,r.jsxs)(i.h5,{id:"the-loadable-sql-drivers-build",children:["The ",(0,r.jsx)(i.code,{children:"Loadable"})," SQL drivers build"]}),"\n",(0,r.jsxs)(i.p,{children:["It builds two shared libraries, the ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," shared library that contains the core/common code and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," shared library (module) that contains ",(0,r.jsx)(i.code,{children:"MySQL"})," implementation that is loaded at runtime using ",(0,r.jsx)(i.code,{children:"LoadLibrary()"})," on Windows or ",(0,r.jsx)(i.code,{children:"dlopen()"})," on Linux. The SQL driver library loader throws an exception if it cannot find this library at runtime."]}),"\n",(0,r.jsx)(i.admonition,{type:"info",children:(0,r.jsxs)(i.p,{children:["The ",(0,r.jsx)(i.code,{children:"TinyMySql"})," links directly against the ",(0,r.jsx)(i.code,{children:"MySQL C connector"})," (",(0,r.jsx)(i.code,{children:"libmysql"})," or ",(0,r.jsx)(i.code,{children:"mysqlclient"})," library)."]})}),"\n",(0,r.jsxs)(i.h4,{id:"cmakeqmake-build-options",children:[(0,r.jsx)(i.code,{children:"CMake"}),"/",(0,r.jsx)(i.code,{children:"qmake"})," build options"]}),"\n",(0,r.jsxs)(i.h5,{id:"for-cmake",children:["For ",(0,r.jsx)(i.code,{children:"CMake"})]}),"\n",(0,r.jsxs)(i.p,{children:["See ",(0,r.jsx)(i.a,{href:"/building/tinyorm#cmake-build-options",children:"CMake build options"}),", related ",(0,r.jsx)(i.code,{children:"CMake"})," build options are:",(0,r.jsx)("br",{}),(0,r.jsx)(i.a,{href:"/building/tinyorm#BUILD_DRIVERS",children:(0,r.jsx)(i.code,{children:"BUILD_DRIVERS"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#BUILD_MYSQL_DRIVER",children:(0,r.jsx)(i.code,{children:"BUILD_MYSQL_DRIVER"})}),", and ",(0,r.jsx)(i.a,{href:"/building/tinyorm#DRIVERS_TYPE",children:(0,r.jsx)(i.code,{children:"DRIVERS_TYPE"})})]}),"\n",(0,r.jsxs)(i.p,{children:["To control shared and static build use ",(0,r.jsx)(i.a,{href:"https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html",children:(0,r.jsx)(i.code,{children:"BUILD_SHARED_LIBS"})})," ",(0,r.jsx)(i.code,{children:"CMake"})," configuration option."]}),"\n",(0,r.jsxs)(i.h5,{id:"for-qmake",children:["For ",(0,r.jsx)(i.code,{children:"qmake"})]}),"\n",(0,r.jsxs)(i.p,{children:["See ",(0,r.jsx)(i.a,{href:"/building/tinyorm#qmake-build-options",children:"qmake build options"}),", related ",(0,r.jsx)(i.code,{children:"qmake"})," configuration options are:",(0,r.jsx)("br",{}),(0,r.jsx)(i.a,{href:"/building/tinyorm#build_loadable_drivers",children:(0,r.jsx)(i.code,{children:"build_loadable_drivers"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_mysql_driver",children:(0,r.jsx)(i.code,{children:"build_mysql_driver"})}),", ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_shared_drivers",children:(0,r.jsx)(i.code,{children:"build_shared_drivers"})}),", and ",(0,r.jsx)(i.a,{href:"/building/tinyorm#build_static_drivers",children:(0,r.jsx)(i.code,{children:"build_static_drivers"})})]}),"\n",(0,r.jsxs)(i.p,{children:["To control shared and static build use ",(0,r.jsx)(i.a,{href:"/building/tinyorm#qmake-static",children:(0,r.jsx)(i.code,{children:"static"})})," ",(0,r.jsx)(i.code,{children:"qmake"})," ",(0,r.jsx)(i.a,{href:"https://doc.qt.io/qt/qmake-variable-reference.html#config",children:"configuration option"}),"."]}),"\n",(0,r.jsx)(i.h3,{id:"performance",children:"Performance"}),"\n",(0,r.jsxs)(i.p,{children:["Performance is several milliseconds faster compared to ",(0,r.jsx)(i.code,{children:"QtSql"})," with the ",(0,r.jsx)(i.code,{children:"QMYSQL"})," driver. It was tuned using the ",(0,r.jsx)(i.code,{children:"KCacheGrind"})," to be so. It's ~40ms faster on ",(0,r.jsx)(i.a,{href:"https://github.com/silverqx/TinyOrmPlayground",children:(0,r.jsx)(i.code,{children:"TinyOrmPlayground"})})," project with ",(0,r.jsx)(i.strong,{children:"620"})," database queries compiled using ",(0,r.jsx)(i.code,{children:"GCC v13.2.1"})," Debug build on Linux. Similar results can be expected on other platforms but it's not guaranteed."]}),"\n",(0,r.jsxs)(i.p,{children:["This means performance is very similar to ",(0,r.jsx)(i.code,{children:"QtSql"}),". There is not much to speed up because ",(0,r.jsx)(i.code,{children:"TinyDrivers"})," code is swift and 90% of the time is spent inside the ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/",children:(0,r.jsx)(i.code,{children:"MySQL C API"})})," because we always have to wait for the database server, especially when creating database connections using eg. ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-real-connect.html",children:(0,r.jsx)(i.code,{children:"mysql_real_connect()"})})," (this function is king among the slowest functions \ud83d\ude0e, which is understandable of course)."]}),"\n",(0,r.jsx)(i.h2,{id:"internals",children:"Internals"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," internal design can be divided into 3 different layers:"]}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:"Driver layer"}),"\n",(0,r.jsx)(i.li,{children:"SQL API layer"}),"\n",(0,r.jsx)(i.li,{children:"Public API layer"}),"\n"]}),"\n",(0,r.jsxs)(i.p,{children:["The Driver layer is eg. ",(0,r.jsx)(i.code,{children:"TinyMySql"})," library which is responsible for communicating with the underlying database driver (eg. ",(0,r.jsx)(i.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/",children:(0,r.jsx)(i.code,{children:"MySQL C API"})}),")."]}),"\n",(0,r.jsx)(i.p,{children:"The SQL API layer is a semi-layer that glues everything up and sits between the Public interface API and the Driver layer."}),"\n",(0,r.jsxs)(i.p,{children:["The Public interface API layer are the end classes like ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," and ",(0,r.jsx)(i.code,{children:"SqlQuery"})," which are exposed to the end user."]}),"\n",(0,r.jsx)(i.h5,{id:"sqldatabase",children:"SqlDatabase"}),"\n",(0,r.jsxs)(i.p,{children:["One more thing worth mentioning is the ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," API. It's one class that has two responsibilities! All static methods act as the database connection manager and an instance of the ",(0,r.jsx)(i.code,{children:"SqlDatabase"})," represents a physical database connection. It's not a good design because it breaks the ",(0,r.jsx)(i.a,{href:"https://en.wikipedia.org/wiki/Single_responsibility_principle",children:"Single Responsibility principle"}),", but it's what it is."]}),"\n",(0,r.jsx)(i.h5,{id:"namespaces",children:"Namespaces"}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"TinyDrivers"})," classes are defined in the ",(0,r.jsx)(i.code,{children:"Orm::Drivers"})," namespace and ",(0,r.jsx)(i.code,{children:"TinyMySql"})," classes in the ",(0,r.jsx)(i.code,{children:"Orm::Drivers::MySql"})," namespace."]}),"\n",(0,r.jsx)(i.h5,{id:"documentation",children:"Documentation"}),"\n",(0,r.jsxs)(i.p,{children:["For all other APIs you can follow the ",(0,r.jsx)(i.a,{href:"https://doc.qt.io/qt/qtsql-index.html",children:"QtSql documentation"})," as the API is 1:1. The exception is of course the build system, ",(0,r.jsx)(i.code,{children:"TinyOrm"})," has its own build system that doesn't follow the ",(0,r.jsx)(i.code,{children:"QtSql"})," module."]})]})}function u(e={}){const{wrapper:i}={...(0,s.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,i,n)=>{n.d(i,{R:()=>t,x:()=>l});var r=n(6540);const s={},d=r.createContext(s);function t(e){const i=r.useContext(d);return r.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),r.createElement(d.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/cbe663fe.81a87eec.js b/assets/js/cbe663fe.81a87eec.js deleted file mode 100644 index 8cd7ea021..000000000 --- a/assets/js/cbe663fe.81a87eec.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[995],{4583:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>d,toc:()=>c});var r=s(4848),t=s(8453),a=s(8774);const i={sidebar_position:1,sidebar_label:"Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",keywords:["c++ orm","sql","c++ sql","c++ query builder","database","query builder","tinyorm"]},o="Database: Query Builder",d={id:"database/query-builder",title:"Database: Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",source:"@site/docs/database/query-builder.mdx",sourceDirName:"database",slug:"/database/query-builder",permalink:"/database/query-builder",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",keywords:["c++ orm","sql","c++ sql","c++ query builder","database","query builder","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/database/getting-started"},next:{title:"Migrations",permalink:"/database/migrations"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Running Database Queries",id:"running-database-queries",level:2},{value:"Retrieving All Rows From A Table",id:"retrieving-all-rows-from-a-table",level:4},{value:"Retrieving A Single Row / Column From A Table",id:"retrieving-a-single-row--column-from-a-table",level:4},{value:"Retrieving A List Of Column Values",id:"retrieving-a-list-of-column-values",level:4},{value:"Concatenate column values",id:"concatenate-column-values",level:4},{value:"Chunking Results",id:"chunking-results",level:3},{value:"Aggregates",id:"aggregates",level:3},{value:"Determining If Records Exist",id:"determining-if-records-exist",level:4},{value:"Select Statements",id:"select-statements",level:2},{value:"Specifying A Select Clause",id:"specifying-a-select-clause",level:4},{value:"Raw Expressions",id:"raw-expressions",level:2},{value:"Raw Methods",id:"raw-methods",level:3},{value:"selectRaw",id:"selectraw",level:4},{value:"fromRaw",id:"fromraw",level:4},{value:"whereRaw / orWhereRaw",id:"whereraw--orwhereraw",level:4},{value:"groupByRaw",id:"groupbyraw",level:3},{value:"havingRaw / orHavingRaw",id:"havingraw--orhavingraw",level:4},{value:"orderByRaw",id:"orderbyraw",level:4},{value:"Joins",id:"joins",level:2},{value:"Inner Join Clause",id:"inner-join-clause",level:4},{value:"Left Join / Right Join Clause",id:"left-join--right-join-clause",level:4},{value:"Cross Join Clause",id:"cross-join-clause",level:4},{value:"Advanced Join Clauses",id:"advanced-join-clauses",level:4},{value:"Subquery Joins",id:"subquery-joins",level:4},{value:"Basic Where Clauses",id:"basic-where-clauses",level:2},{value:"Where Clauses",id:"where-clauses",level:3},{value:"Or Where Clauses",id:"or-where-clauses",level:3},{value:"Condition Operator Overriding",id:"condition-operator-overriding",level:3},{value:"Where Not Clauses",id:"where-not-clauses",level:3},{value:"Additional Where Clauses",id:"additional-where-clauses",level:3},{value:"Logical Grouping",id:"logical-grouping",level:3},{value:"Advanced Where Clauses",id:"advanced-where-clauses",level:2},{value:"Where Exists Clauses",id:"where-exists-clauses",level:3},{value:"Subquery Where Clauses",id:"subquery-where-clauses",level:3},{value:"Ordering, Grouping, Limit & Offset",id:"ordering-grouping-limit-and-offset",level:2},{value:"Ordering",id:"ordering",level:3},{value:"The orderBy Method",id:"the-orderby-method",level:4},{value:"The latest & oldest Methods",id:"the-latest--oldest-methods",level:4},{value:"Random Ordering",id:"random-ordering",level:4},{value:"Removing Existing Orderings",id:"removing-existing-orderings",level:4},{value:"Grouping",id:"grouping",level:3},{value:"The groupBy & having Methods",id:"the-groupby--having-methods",level:4},{value:"Limit & Offset",id:"limit-and-offset",level:3},{value:"The skip & take Methods",id:"the-skip--take-methods",level:4},{value:"Insert Statements",id:"insert-statements",level:2},{value:"Auto-Incrementing IDs",id:"auto-incrementing-ids",level:4},{value:"Upserts",id:"upserts",level:3},{value:"Update Statements",id:"update-statements",level:2},{value:"Update Or Insert",id:"update-or-insert",level:4},{value:"Increment & Decrement",id:"increment-and-decrement",level:3},{value:"Delete Statements",id:"delete-statements",level:2},{value:"Truncate Statement",id:"truncate-statement",level:3},{value:"Table Truncation & PostgreSQL",id:"table-truncation--postgresql",level:4},{value:"Pessimistic Locking",id:"pessimistic-locking",level:2},{value:"Debugging",id:"debugging",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"database-query-builder",children:"Database: Query Builder"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#running-database-queries",children:"Running Database Queries"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#chunking-results",children:"Chunking Results"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#aggregates",children:"Aggregates"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#select-statements",children:"Select Statements"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#raw-expressions",children:"Raw Expressions"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#joins",children:"Joins"})}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#basic-where-clauses",children:"Basic Where Clauses"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-clauses",children:"Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#or-where-clauses",children:"Or Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-not-clauses",children:"Where Not Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#additional-where-clauses",children:"Additional Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#condition-operator-overriding",children:"Condition Operator Overriding"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#logical-grouping",children:"Logical Grouping"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#advanced-where-clauses",children:"Advanced Where Clauses"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-exists-clauses",children:"Where Exists Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#subquery-where-clauses",children:"Subquery Where Clauses"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#ordering-grouping-limit-and-offset",children:"Ordering, Grouping, Limit & Offset"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#ordering",children:"Ordering"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#grouping",children:"Grouping"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#limit-and-offset",children:"Limit & Offset"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#insert-statements",children:"Insert Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#upserts",children:"Upserts"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#update-statements",children:"Update Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#increment-and-decrement",children:"Increment & Decrement"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#delete-statements",children:"Delete Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#truncate-statement",children:"Truncate Statement"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#pessimistic-locking",children:"Pessimistic Locking"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#debugging",children:"Debugging"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)("div",{class:"api-stability alert alert--success",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,r.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,r.jsx)(n.p,{children:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application."}),"\n",(0,r.jsxs)(n.p,{children:["The TinyORM query builder uses ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings."]}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"QSqlQuery"}),' does not support binding column names. Therefore, you should never allow user input to dictate the column names referenced by your queries, including "order by" columns.']})}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"QMYSQL"})," Qt driver contains a bug, if your table contains a ",(0,r.jsx)(n.code,{children:"json"})," column type, then you must explicitly name columns other than ",(0,r.jsx)(n.code,{children:"json"})," columns instead of the ",(0,r.jsx)(n.code,{children:"*"})," shorthand, otherwise, you will get an empty result, or all column values will be invalid QVariant-s, or it may even return half of the columns. The ",(0,r.jsx)(n.code,{children:"QPSQL"})," driver returns correct results and doesn't have problem with ",(0,r.jsx)(n.code,{children:"json"})," columns. It was fixed in the Qt ",(0,r.jsx)(n.del,{children:"5.15.12"}),", 6.2.7, 6.5.0 ",(0,r.jsx)(n.a,{href:"https://bugreports.qt.io/browse/QTBUG-101680",children:"QTBUG-101680"}),"."]})}),"\n",(0,r.jsx)(n.h2,{id:"running-database-queries",children:"Running Database Queries"}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-all-rows-from-a-table",children:"Retrieving All Rows From A Table"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"table"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade to begin a query. The ",(0,r.jsx)(n.code,{children:"table"})," method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the query and then finally retrieve the results of the query using the ",(0,r.jsx)(n.code,{children:"get"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Log a list of all of the application\'s users\nauto query = DB::table("users")->get();\n\nwhile (query.next())\n qDebug() << "id :" << query.value("id").toULongLong() << ";"\n << "name :" << query.value("name").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"get"})," method returns a ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," containing the results of the query where each result can be accessed by ",(0,r.jsx)(n.code,{children:"QSqlQuery::next"})," method, look into the ",(0,r.jsx)(n.code,{children:"QSqlQuery"}),' documentation how to obtain results from the "query". You may access each column\'s value by ',(0,r.jsx)(n.code,{children:"QSqlQuery::value"})," method. The first ",(0,r.jsx)(n.code,{children:"bool"})," return value is the value returned from ",(0,r.jsx)(n.code,{children:"QSqlQuery::exec"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto users = DB::table("users")->get();\n\nwhile(users.next())\n qDebug() << users.value("name").toString();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-a-single-row--column-from-a-table",children:"Retrieving A Single Row / Column From A Table"}),"\n",(0,r.jsxs)(n.p,{children:["If you just need to retrieve a single row from a database table, you may use the ",(0,r.jsx)(n.code,{children:"QueryBuilder::first"})," method. This method will return a ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," object, on which was internally called ",(0,r.jsx)(n.code,{children:"QSqlQuery::first"})," method. This method retrieves the first record in the result, if available, and positions the query on the retrieved record:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")->whereEq("name", "John").first();\n\nuser.value("email").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you don't need an entire row, you may extract a single value from a record using the ",(0,r.jsx)(n.code,{children:"value"})," method. This method will return the value of the column directly as ",(0,r.jsx)(n.code,{children:"QVariant"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto email = DB::table("users")->whereEq("name", "John").value("email").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["To retrieve a single row by its ",(0,r.jsx)(n.code,{children:"id"})," column value, use the ",(0,r.jsx)(n.code,{children:"find"})," method. This method retrieves the first record in the result, if available, and positions the query on the retrieved record:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")->find(3);\n\nuser.value("email").toString();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-a-list-of-column-values",children:"Retrieving A List Of Column Values"}),"\n",(0,r.jsxs)(n.p,{children:["If you would like to retrieve the ",(0,r.jsx)(n.code,{children:"QList"})," instance containing the values of a single column, you may use the ",(0,r.jsx)(n.code,{children:"pluck"})," method. In this example, we'll retrieve a collection of user titles:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nconst auto titles = DB::table("users")->pluck("title");\n\nfor (const auto &title : titles)\n qDebug() << title.value();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may specify the column that the resulting collection should use as its keys by providing a second argument to the ",(0,r.jsx)(n.code,{children:"pluck"})," method, following example returns the ",(0,r.jsx)(n.code,{children:"std::map"}),' of "titles" keyed by "names":']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto titles = DB::table("users")->pluck("title", "name");\n\nfor (auto &&[name, title] : titles)\n qDebug() << name << ":" << title.value();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also use ",(0,r.jsx)(n.code,{children:'pluck("name", "id")'}),", it returns the ",(0,r.jsx)(n.code,{children:"std::map"}),' of "names" keyed by its "ids".']}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["This second ",(0,r.jsx)(n.code,{children:"pluck"})," overload returns ",(0,r.jsx)(n.code,{children:"std::map"})," so you have to provide a template argument for the key type."]})}),"\n",(0,r.jsx)(n.h4,{id:"concatenate-column-values",children:"Concatenate column values"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"implode"})," method can be used to join column values. For example, you may use this method to concatenate prices with the ",(0,r.jsx)(n.code,{children:", "})," character as the glue:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("orders")->where("price", ">", 100).implode("price", ", ");\n'})}),"\n",(0,r.jsx)(n.h3,{id:"chunking-results",children:"Chunking Results"}),"\n",(0,r.jsxs)(n.p,{children:["If you need to work with thousands of database records, consider using the ",(0,r.jsx)(n.code,{children:"chunk"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade. This method retrieves a small chunk of results at a time and feeds each chunk into a lambda expression for processing. For example, let's retrieve the entire ",(0,r.jsx)(n.code,{children:"users"})," table in chunks of 100 records at a time:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->orderBy("id").chunk(100, [](QSqlQuery &users, const int page)\n{\n while (users.next()) {\n //\n }\n\n return true;\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may stop further chunks from being processed by returning ",(0,r.jsx)(n.code,{children:"false"})," from the closure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->orderBy("id").chunk(100, [](QSqlQuery &users, const int page)\n{\n // Process the records...\n\n return false;\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you are updating database records while chunking results, your chunk results could change in unexpected ways. If you plan to update the retrieved records while chunking, it is always best to use the ",(0,r.jsx)(n.code,{children:"chunkById"})," method instead. This method will automatically paginate the results based on the record's primary key:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->whereEq("active", false)\n .orderBy("id")\n .chunkById(100, [](QSqlQuery &users, const int /*unused*/)\n {\n while (users.next())\n DB::table("users")\n ->whereEq("id", users.value("id"))\n .update({{"active", true}});\n\n return true;\n });\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"caution",children:(0,r.jsxs)(n.p,{children:["When updating or deleting records inside the chunk lambda expression, any changes to the primary key or foreign keys could affect the chunk query. This could potentially result in records not being included in the chunked results, it can be avoided using the ",(0,r.jsx)(n.code,{children:"chunkById"})," method."]})}),"\n",(0,r.jsx)(n.h3,{id:"aggregates",children:"Aggregates"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder also provides a variety of methods for retrieving aggregate values like ",(0,r.jsx)(n.code,{children:"count"}),", ",(0,r.jsx)(n.code,{children:"max"}),", ",(0,r.jsx)(n.code,{children:"min"}),", ",(0,r.jsx)(n.code,{children:"avg"}),", and ",(0,r.jsx)(n.code,{children:"sum"}),". You may call any of these methods after constructing your query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")->count();\n\nauto price = DB::table("orders")->max("price");\n'})}),"\n",(0,r.jsx)(n.p,{children:"Of course, you may combine these methods with other clauses to fine-tune how your aggregate value is calculated:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto price = DB::table("orders")\n ->whereEq("finalized", 1)\n .avg("price");\n'})}),"\n",(0,r.jsx)(n.h4,{id:"determining-if-records-exist",children:"Determining If Records Exist"}),"\n",(0,r.jsxs)(n.p,{children:["Instead of using the ",(0,r.jsx)(n.code,{children:"count"})," method to determine if any records exist that match your query's constraints, you may use the ",(0,r.jsx)(n.code,{children:"exists"})," and ",(0,r.jsx)(n.code,{children:"doesntExist"})," methods:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'if (DB::table("orders")->whereEq("finalized", 1).exists()) {\n // ...\n}\n\nif (DB::table("orders")->whereEq("finalized", 1).doesntExist()) {\n // ...\n}\n'})}),"\n",(0,r.jsx)(n.h2,{id:"select-statements",children:"Select Statements"}),"\n",(0,r.jsx)(n.h4,{id:"specifying-a-select-clause",children:"Specifying A Select Clause"}),"\n",(0,r.jsxs)(n.p,{children:["You may not always want to select all columns from a database table. Using the ",(0,r.jsx)(n.code,{children:"select"}),' method, you can specify a custom "select" clause for the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")\n ->select({"name", "email as user_email"})\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"distinct"})," method allows you to force the query to return distinct results:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->distinct().get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you already have a query builder instance and you wish to add a column to its existing select clause, you may use the ",(0,r.jsx)(n.code,{children:"addSelect"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto query = DB::table("users")->select("name");\n\nauto users = query.addSelect("age").get();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["You can also pass subqueries to the ",(0,r.jsx)(n.code,{children:"select"})," and ",(0,r.jsx)(n.code,{children:"addSelect"})," methods. A subquery can be a lambda expression, raw string, or the ",(0,r.jsx)(n.code,{children:"QueryBuilder"})," instance."]})}),"\n",(0,r.jsx)(n.h2,{id:"raw-expressions",children:"Raw Expressions"}),"\n",(0,r.jsxs)(n.p,{children:["Sometimes you may need to insert an arbitrary string into a query. To create a raw string expression, you may use the ",(0,r.jsx)(n.code,{children:"raw"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->select(DB::raw("count(*) as user_count, status"))\n .where("status", "<>", 1)\n .groupBy("status")\n .get();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsx)(n.p,{children:"Raw statements will be injected into the query as strings, so you should be extremely careful to avoid creating SQL injection vulnerabilities."})}),"\n",(0,r.jsx)(n.h3,{id:"raw-methods",children:"Raw Methods"}),"\n",(0,r.jsxs)(n.p,{children:["Instead of using the ",(0,r.jsx)(n.code,{children:"DB::raw"})," method, you may also use the following methods to insert a raw expression into various parts of your query. ",(0,r.jsx)(n.strong,{children:"Remember, TinyORM can not guarantee that any query using raw expressions is protected against SQL injection vulnerabilities."})]}),"\n",(0,r.jsx)(n.h4,{id:"selectraw",children:(0,r.jsx)(n.code,{children:"selectRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"selectRaw"})," method can be used in place of ",(0,r.jsx)(n.code,{children:"addSelect(DB::raw(...))"}),". This method accepts an optional vector of bindings as its second argument:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->selectRaw("price * ? as price_with_tax", {1.0825})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"fromraw",children:(0,r.jsx)(n.code,{children:"fromRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"fromRaw"}),' method may be used to provide a raw string as the value of the "from" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::connection("postgres").query()\n ->fromRaw("(select id, name from users where id < ?) as u", {5})\n .where("id", "<", 3)\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"whereraw--orwhereraw",children:(0,r.jsx)(n.code,{children:"whereRaw / orWhereRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereRaw"})," and ",(0,r.jsx)(n.code,{children:"orWhereRaw"}),' methods can be used to inject a raw "where" clause into your query. These methods accept an optional vector of bindings as their second argument:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->whereRaw("price > IF(state = \\"TX\\", ?, 100)", {200})\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"groupbyraw",children:(0,r.jsx)(n.code,{children:"groupByRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"groupByRaw"})," method may be used to provide a raw string as the value of the ",(0,r.jsx)(n.code,{children:"group by"})," clause:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->select({"city", "state"})\n .groupByRaw("city, state")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"havingraw--orhavingraw",children:(0,r.jsx)(n.code,{children:"havingRaw / orHavingRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"havingRaw"})," and ",(0,r.jsx)(n.code,{children:"orHavingRaw"}),' methods may be used to provide a raw string as the value of the "having" clause. These methods accept an optional vector of bindings as their second argument:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->select({"department", DB::raw("SUM(price) as total_sales")})\n .groupBy("department")\n .havingRaw("SUM(price) > ?", {2500})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"orderbyraw",children:(0,r.jsx)(n.code,{children:"orderByRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"orderByRaw"}),' method may be used to provide a raw string as the value of the "order by" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->orderByRaw("updated_at - created_at DESC")\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"joins",children:"Joins"}),"\n",(0,r.jsx)(n.h4,{id:"inner-join-clause",children:"Inner Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:['The query builder may also be used to add join clauses to your queries. To perform a basic "inner join", you may use the ',(0,r.jsx)(n.code,{children:"join"})," method on a query builder instance. The first argument passed to the ",(0,r.jsx)(n.code,{children:"join"})," method is the name of the table you need to join to, while the remaining arguments specify the column constraints for the join. You may even join multiple tables in a single query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")\n ->join("contacts", "users.id", "=", "contacts.user_id")\n .join("orders", "users.id", "=", "orders.user_id")\n .select({"users.*", "contacts.phone", "orders.price"})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"left-join--right-join-clause",children:"Left Join / Right Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:['If you would like to perform a "left join" or "right join" instead of an "inner join", use the ',(0,r.jsx)(n.code,{children:"leftJoin"})," or ",(0,r.jsx)(n.code,{children:"rightJoin"})," methods. These methods have the same signature as the ",(0,r.jsx)(n.code,{children:"join"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->leftJoin("posts", "users.id", "=", "posts.user_id")\n .get();\n\nauto users = DB::table("users")\n ->rightJoin("posts", "users.id", "=", "posts.user_id")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"cross-join-clause",children:"Cross Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"crossJoin"}),' method to perform a "cross join". Cross joins generate a cartesian product between the first table and the joined table:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto sizes = DB::table("sizes")\n ->crossJoin("colors")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"advanced-join-clauses",children:"Advanced Join Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["You may also specify more advanced join clauses. To get started, pass a lambda expression as the second argument to the ",(0,r.jsx)(n.code,{children:"join"})," method. The lambda expression will receive a ",(0,r.jsx)(n.code,{children:"Orm::Query::JoinClause"}),' instance which allows you to specify constraints on the "join" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nDB::table("users")\n ->join("contacts", [](auto &join)\n {\n join.on("users.id", "=", "contacts.user_id")\n .orOn(...);\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['If you would like to use a "where" clause on your joins, you may use the ',(0,r.jsx)(n.code,{children:"where"})," and ",(0,r.jsx)(n.code,{children:"orWhere"})," methods provided by the ",(0,r.jsx)(n.code,{children:"Orm::Query::JoinClause"})," instance. Instead of comparing two columns, these methods will compare the column against a value:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->join("contacts", [](auto &join)\n {\n join.on("users.id", "=", "contacts.user_id")\n .where("contacts.user_id", ">", 5);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"subquery-joins",children:"Subquery Joins"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"joinSub"}),", ",(0,r.jsx)(n.code,{children:"leftJoinSub"}),", and ",(0,r.jsx)(n.code,{children:"rightJoinSub"})," methods to join a query to a subquery. Each of these methods receives three arguments: the subquery, its table alias, and a lambda expression that defines the related columns. In this example, we will retrieve a collection of users where each user record also contains the ",(0,r.jsx)(n.code,{children:"created_at"})," timestamp of the user's most recently published blog post:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto latestPosts = DB::table("posts")\n ->select({"user_id", DB::raw("MAX(created_at) as last_post_created_at")})\n .whereEq("is_published", true)\n .groupBy("user_id");\n\nauto users = DB::table("users")\n ->joinSub(latestPosts, "latest_posts", [](auto &join)\n {\n join.on("users.id", "=", "latest_posts.user_id");\n }).get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"basic-where-clauses",children:"Basic Where Clauses"}),"\n",(0,r.jsx)(n.h3,{id:"where-clauses",children:"Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the query builder's ",(0,r.jsx)(n.code,{children:"where"}),' method to add "where" clauses to the query. The most basic call to the ',(0,r.jsx)(n.code,{children:"where"})," method requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. The third argument is the value to compare against the column's value."]}),"\n",(0,r.jsxs)(n.p,{children:["For example, the following query retrieves users where the value of the ",(0,r.jsx)(n.code,{children:"votes"})," column is equal to ",(0,r.jsx)(n.code,{children:"100"})," and the value of the ",(0,r.jsx)(n.code,{children:"age"})," column is greater than ",(0,r.jsx)(n.code,{children:"35"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", "=", 100)\n .where("age", ">", 35)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["For convenience, if you want to verify that a column is ",(0,r.jsx)(n.code,{children:"="})," to a given value, you may call ",(0,r.jsx)(n.code,{children:"whereEq"})," method. Similar ",(0,r.jsx)(n.code,{children:"XxxEq"})," methods are also defined for other commands:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->whereEq("votes", 100).get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"As previously mentioned, you may use any operator that is supported by your database system:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">=", 100)\n .get();\n\nauto users = DB::table("users")\n ->where("votes", "<>", 100)\n .get();\n\nauto users = DB::table("users")\n ->where("name", "like", "T%")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a ",(0,r.jsx)(n.code,{children:"QList"})," of conditions to the ",(0,r.jsx)(n.code,{children:"where"})," function. Each ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure should contain the four arguments typically passed to the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"status", 1}, // "=" by default\n {"subscribed", 1, "<>"},\n }).get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"or-where-clauses",children:"Or Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["When chaining together calls to the query builder's ",(0,r.jsx)(n.code,{children:"where"}),' method, the "where" clauses will be joined together using the ',(0,r.jsx)(n.code,{children:"and"})," operator. However, you may use the ",(0,r.jsx)(n.code,{children:"orWhere"})," or ",(0,r.jsx)(n.code,{children:"orWhereEq"})," method to join a clause to the query using the ",(0,r.jsx)(n.code,{children:"or"})," operator. The ",(0,r.jsx)(n.code,{children:"orWhere"})," method accepts the same arguments as the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">", 100)\n .orWhere("name", "=", "John")\n .orWhereEq("name", "Jack")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['If you need to group an "or" condition within parentheses, you may pass a lambda expression as the first argument to the ',(0,r.jsx)(n.code,{children:"orWhere"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">", 100)\n .orWhere([](auto &query)\n {\n query.whereEq("name", "Abigail")\n .where("votes", ">", 50);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"The example above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where votes > 100 or (name = "Abigail" and votes > 50)\n'})}),"\n",(0,r.jsx)(n.h3,{id:"condition-operator-overriding",children:"Condition Operator Overriding"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"where"})," method overload with a ",(0,r.jsx)(n.code,{children:"QList"})," as the first argument joins conditions using the ",(0,r.jsx)(n.code,{children:"and"})," operator by default:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"votes", 50, ">"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Conditions operator can be overridden by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"votes", 50, ">", "or"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Or by the second ",(0,r.jsx)(n.code,{children:"where"})," argument, in this case all conditions will be joined by this condition, but it is still possible to override them by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"last_name", "Smith"},\n {"votes", 50, ">", "and"},\n }, "or")\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"The example above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where (first_name = "John" or last_name = "Smith" and votes > 50)\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["Still, it is a better idea to use ",(0,r.jsx)(n.a,{href:"#logical-grouping",children:"Logical Grouping"})," described few lines below, which allows better control of the parentheses."]})}),"\n",(0,r.jsx)(n.h3,{id:"where-not-clauses",children:"Where Not Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNot"})," and ",(0,r.jsx)(n.code,{children:"orWhereNot"})," methods may be used to negate a given group of query constraints. For example, the following query excludes products that are on clearance or which have a price that is less than ten:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto products = DB::table("products")\n ->whereNot([](auto &query) {\n query.whereEq("clearance", true)\n .orWhere("price", "<", 10);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"additional-where-clauses",children:"Additional Where Clauses"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereBetween / orWhereBetween"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereBetween"})," method verifies that a column's value is between two values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereBetween("votes", {1, 100})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNotBetween / orWhereNotBetween"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotBetween"})," method verifies that a column's value lies outside of two values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotBetween("votes", {1, 100})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereBetweenColumns / orWhereBetweenColumns"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereBetweenColumns"})," method verifies that a column's value is between two values in given columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto files = DB::table("files")\n ->whereBetweenColumns("quota", {"min_allowed_quota", "max_allowed_quota"})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNotBetweenColumns / orWhereNotBetweenColumns"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotBetweenColumns"})," method verifies that a column's value lies outside of two values in given columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto files = DB::table("files")\n ->whereNotBetweenColumns("quota", {"min_allowed_quota", "max_allowed_quota"})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereIn / whereNotIn / orWhereIn / orWhereNotIn"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereIn"})," method verifies that a given column's value is contained within the given ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereIn("id", {1, 2, 3})\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotIn"})," method verifies that the given column's value is not contained in the given ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotIn("id", {1, 2, 3})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNull / whereNotNull / orWhereNull / orWhereNotNull"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNull"})," method verifies that the value of the given column is ",(0,r.jsx)(n.code,{children:"NULL"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNull("updated_at")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotNull"})," method verifies that the column's value is not ",(0,r.jsx)(n.code,{children:"NULL"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotNull("updated_at")\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereDate / whereTime / whereDay / whereMonth / whereYear"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDate"})," method may be used to compare a column's value against a date:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereDate("created_at", EQ, QDate(2022, 11, 18))\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereTime"})," method may be used to compare a column's value against a specific time:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereTime("created_at", "=", QTime(11, 14, 23))\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDay"})," method may be used to compare a column's value against a specific day of the month:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereDay("created_at", "<=", 15)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereMonth"})," method may be used to compare a column's value against a specific month:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereEqMonth("created_at", 12)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereYear"})," method may be used to compare a column's value against a specific year:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereEqYear("created_at", 2016)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDate"})," and ",(0,r.jsx)(n.code,{children:"whereTime"})," methods also accept a ",(0,r.jsx)(n.code,{children:"QDateTime"})," instance or you can pass values as a ",(0,r.jsx)(n.code,{children:"QString"})," in ",(0,r.jsx)(n.code,{children:"2022-12-31"})," or ",(0,r.jsx)(n.code,{children:"09:15:11"})," formats."]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDay"}),", ",(0,r.jsx)(n.code,{children:"whereMoth"}),", and ",(0,r.jsx)(n.code,{children:"whereYear"})," accept ",(0,r.jsx)(n.code,{children:"QDate"})," or ",(0,r.jsx)(n.code,{children:"QDateTime"})," instances, an integral number or a ",(0,r.jsx)(n.code,{children:"QString"})," that contains an integral number."]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["All the above methods offer ",(0,r.jsx)(n.code,{children:"whereEqXyz"})," and ",(0,r.jsx)(n.code,{children:"orWhereXyz"})," shortcut methods."]})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereColumn / orWhereColumn"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereColumnEq"})," method may be used to verify that two columns are equal:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumnEq("first_name", "last_name")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a comparison operator to the ",(0,r.jsx)(n.code,{children:"whereColumn"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn("updated_at", ">", "created_at")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a ",(0,r.jsx)(n.code,{children:"QList"})," of column comparisons to the ",(0,r.jsx)(n.code,{children:"whereColumn"})," method. These conditions will be joined using the ",(0,r.jsx)(n.code,{children:"and"})," operator:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Conditions operator can also be overridden by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereColumnItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">", "or"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Or by the second ",(0,r.jsx)(n.code,{children:"whereColumn"})," argument:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">"},\n }, "or")\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"logical-grouping",children:"Logical Grouping"}),"\n",(0,r.jsxs)(n.p,{children:['Sometimes you may need to group several "where" clauses within parentheses in order to achieve your query\'s desired logical grouping. In fact, you should generally always group calls to the ',(0,r.jsx)(n.code,{children:"orWhere"})," method in parentheses in order to avoid unexpected query behavior. To accomplish this, you may pass a lambda expression to the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("name", "=", "John")\n .where([](auto &query)\n {\n query.where("votes", ">", 100)\n .orWhere("title", "=", "Admin");\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["As you can see, passing a lambda expression into the ",(0,r.jsx)(n.code,{children:"where"})," method instructs the query builder to begin a constraint group. The lambda expression will receive a query builder instance which you can use to set the constraints that should be contained within the parenthesis group. The example above will produce the following SQL:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where name = "John" and (votes > 100 or title = "Admin")\n'})}),"\n",(0,r.jsx)(n.h2,{id:"advanced-where-clauses",children:"Advanced Where Clauses"}),"\n",(0,r.jsx)(n.h3,{id:"where-exists-clauses",children:"Where Exists Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereExists"}),' method allows you to write "where exists" SQL clauses. The ',(0,r.jsx)(n.code,{children:"whereExists"}),' method accepts a lambda expression which will receive a query builder instance, allowing you to define the query that should be placed inside of the "exists" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereExists([](auto &query)\n {\n query.select(DB::raw(1))\n .from("orders")\n .whereColumnEq("orders.user_id", "users.id");\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may provide a query object to the ",(0,r.jsx)(n.code,{children:"whereExists"})," method instead of a lambda expression:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'// Ownership of the std::shared_ptr\nauto builder = DB::table("orders");\nauto orders = builder->select(DB::raw(1))\n .whereColumnEq("orders.user_id", "users.id");\n\nauto users = DB::table("users")\n ->whereExists(orders)\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"Or directly:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereExists(DB::table("orders")\n ->select(DB::raw(1))\n .whereColumnEq("orders.user_id", "users.id"))\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"All of the examples above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:"select * from users\nwhere exists (\n select 1\n from orders\n where orders.user_id = users.id\n)\n"})}),"\n",(0,r.jsx)(n.h3,{id:"subquery-where-clauses",children:"Subquery Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:['Sometimes you may need to construct a "where" clause that compares the results of a subquery to a given value. You may accomplish this by passing a lambda expression and a value to the ',(0,r.jsx)(n.code,{children:"where"}),' method. For example, the following query will retrieve all users who have a recent "membership" of a given type:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto users = User::whereEq([](auto &query)\n{\n query.select("type")\n .from("membership")\n .whereColumnEq("membership.user_id", "users.id")\n .orderByDesc("membership.start_date")\n .limit(1);\n}, "Pro")->get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['Or, you may need to construct a "where" clause that compares a column to the results of a subquery. You may accomplish this by passing a column, operator, and lambda expression to the ',(0,r.jsx)(n.code,{children:"where"})," method. For example, the following query will retrieve all income records where the amount is less than average;"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include "models/income.hpp"\n\nauto incomes = Income::where("amount", "<", [](auto &query)\n{\n query.selectRaw("avg(i.amount)").from("incomes as i");\n})->get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"ordering-grouping-limit-and-offset",children:"Ordering, Grouping, Limit & Offset"}),"\n",(0,r.jsx)(n.h3,{id:"ordering",children:"Ordering"}),"\n",(0,r.jsxs)(n.h4,{id:"the-orderby-method",children:["The ",(0,r.jsx)(n.code,{children:"orderBy"})," Method"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"orderBy"})," method allows you to sort the results of the query by a given column. The first argument accepted by the ",(0,r.jsx)(n.code,{children:"orderBy"})," method should be the column you wish to sort by, while the second argument determines the direction of the sort and may be either ",(0,r.jsx)(n.code,{children:"asc"})," or ",(0,r.jsx)(n.code,{children:"desc"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->orderBy("name", "desc")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["To sort by multiple columns, you may simply invoke ",(0,r.jsx)(n.code,{children:"orderBy"})," as many times as necessary:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->orderBy("name", "desc")\n .orderBy("email", "asc")\n .get();\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"the-latest--oldest-methods",children:["The ",(0,r.jsx)(n.code,{children:"latest"})," & ",(0,r.jsx)(n.code,{children:"oldest"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"latest"})," and ",(0,r.jsx)(n.code,{children:"oldest"})," methods allow you to easily order results by date. By default, the result will be ordered by the table's ",(0,r.jsx)(n.code,{children:"created_at"})," column. Or, you may pass the column name that you wish to sort by:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")\n ->latest()\n .first();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"random-ordering",children:"Random Ordering"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"inRandomOrder"})," method may be used to sort the query results randomly. For example, you may use this method to fetch a random user:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto randomUser = DB::table("users")\n ->inRandomOrder()\n .first();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"removing-existing-orderings",children:"Removing Existing Orderings"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"reorder"}),' method removes all of the "order by" clauses that have previously been applied to the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto &query = DB::table("users")->orderBy("name");\n\nauto unorderedUsers = query.reorder().get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may pass a column and direction when calling the ",(0,r.jsx)(n.code,{children:"reorder"}),' method in order to remove all existing "order by" clauses and apply an entirely new order to the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto &query = DB::table("users")->orderBy("name");\n\nauto usersOrderedByEmail = query.reorder("email", "desc").get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"grouping",children:"Grouping"}),"\n",(0,r.jsxs)(n.h4,{id:"the-groupby--having-methods",children:["The ",(0,r.jsx)(n.code,{children:"groupBy"})," & ",(0,r.jsx)(n.code,{children:"having"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["As you might expect, the ",(0,r.jsx)(n.code,{children:"groupBy"})," and ",(0,r.jsx)(n.code,{children:"having"})," methods may be used to group the query results. The ",(0,r.jsx)(n.code,{children:"having"})," method's signature is similar to that of the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->groupBy("account_id")\n .having("account_id", ">", 100)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may pass multiple items to the ",(0,r.jsx)(n.code,{children:"groupBy"})," method to group by multiple columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->groupBy({"first_name", "status"})\n .having("account_id", ">", 100)\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"limit-and-offset",children:"Limit & Offset"}),"\n",(0,r.jsxs)(n.h4,{id:"the-skip--take-methods",children:["The ",(0,r.jsx)(n.code,{children:"skip"})," & ",(0,r.jsx)(n.code,{children:"take"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"skip"})," and ",(0,r.jsx)(n.code,{children:"take"})," methods to limit the number of results returned from the query or to skip a given number of results in the query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->skip(10).take(5).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,r.jsx)(n.code,{children:"limit"})," and ",(0,r.jsx)(n.code,{children:"offset"})," methods. These methods are functionally equivalent to the ",(0,r.jsx)(n.code,{children:"take"})," and ",(0,r.jsx)(n.code,{children:"skip"})," methods, respectively:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->offset(10)\n .limit(5)\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"insert-statements",children:"Insert Statements"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder also provides an ",(0,r.jsx)(n.code,{children:"insert"})," method that may be used to insert records into the database table. The ",(0,r.jsx)(n.code,{children:"insert"})," method accepts the ",(0,r.jsx)(n.code,{children:"QVariantMap"})," of column names and values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({\n {"email", "kayla@example.com"},\n {"votes", 0},\n});\n'})}),"\n",(0,r.jsx)(a.A,{id:"multi-insert-overload"}),"\n",(0,r.jsxs)(n.p,{children:["You may insert several records at once by passing a ",(0,r.jsx)(n.code,{children:"QList"})," for column names as the first argument and ",(0,r.jsx)(n.code,{children:"QList>"})," for values as the second argument. Each ",(0,r.jsx)(n.code,{children:"QList"})," represents a record that should be inserted into the table. This overload is useful for multi-insert and allows to specify column names only once:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({"email", "votes"},\n{\n {"picard@example.com", 0},\n {"janeway@example.com", 0},\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also insert several records at once by passing a ",(0,r.jsx)(n.code,{children:"QList"}),". Each ",(0,r.jsx)(n.code,{children:"QVariantMap"})," represents a record that should be inserted into the table:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({\n {{"email", "picard@example.com"}, {"votes", 0}},\n {{"email", "janeway@example.com"}, {"votes", 0}},\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"insertOrIgnore"})," method will ignore duplicate record errors while inserting records into the database and also provides the same overloads like the ",(0,r.jsx)(n.code,{children:"insert"})," method. When using this method, you should be aware that duplicate record errors will be ignored and other types of errors may also be ignored depending on the database engine. For example, ",(0,r.jsx)(n.code,{children:"insertOrIgnore"})," will ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/en/sql-mode.html#ignore-effect-on-execution",children:"bypass MySQL's strict mode"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insertOrIgnore({"id", "email"},\n{\n {1, "sisko@example.com"},\n {2, "archer@example.com"},\n});\n\nDB::table("users")->insertOrIgnore({\n {{"id", 1}, {"email", "sisko@example.com"}},\n {{"id", 2}, {"email", "archer@example.com"}},\n});\n'})}),"\n",(0,r.jsx)(n.h4,{id:"auto-incrementing-ids",children:"Auto-Incrementing IDs"}),"\n",(0,r.jsxs)(n.p,{children:["If the table has an auto-incrementing id, use the ",(0,r.jsx)(n.code,{children:"insertGetId"})," method to insert a record and then retrieve the ID:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto id = DB::table("users")->insertGetId({\n {"email", "john@example.com"},\n {"votes", 0},\n});\n'})}),"\n",(0,r.jsx)(n.h3,{id:"upserts",children:"Upserts"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"upsert"})," method will insert records that do not exist and update the records that already exist with new values that you may specify. The method's first argument consists of the values to insert or update, while the second argument lists the column(s) that uniquely identify records within the associated table. The method's third and final argument is a vector of columns that should be updated if a matching record already exists in the database:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("flights")->upsert(\n {{{"departure", "Oakland"}, {"destination", "San Diego"}, {"price", 99}},\n {{"departure", "Chicago"}, {"destination", "New York"}, {"price", 150}}},\n {"departure", "destination"},\n {"price"}\n);\n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, TinyORM will attempt to insert two records. If a record already exists with the same ",(0,r.jsx)(n.code,{children:"departure"})," and ",(0,r.jsx)(n.code,{children:"destination"})," column values, TinyORM will update that record's ",(0,r.jsx)(n.code,{children:"price"})," column."]}),"\n",(0,r.jsx)(n.admonition,{type:"caution",children:(0,r.jsxs)(n.p,{children:["All databases except SQL Server require the columns in the second argument of the ",(0,r.jsx)(n.code,{children:"upsert"}),' method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the ',(0,r.jsx)(n.code,{children:"upsert"}),' method and always uses the "primary" and "unique" indexes of the table to detect existing records.']})}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html",children:"documentation"}),". The MySQL server version is auto-detected and can be overridden in the ",(0,r.jsx)(n.a,{href:"/database/getting-started#configuration",children:"configuration"}),"."]})}),"\n",(0,r.jsx)(n.h2,{id:"update-statements",children:"Update Statements"}),"\n",(0,r.jsxs)(n.p,{children:["In addition to inserting records into the database, the query builder can also update existing records using the ",(0,r.jsx)(n.code,{children:"update"})," method. The ",(0,r.jsx)(n.code,{children:"update"})," method, accepts a ",(0,r.jsx)(n.code,{children:"QList"})," of column and value pairs, indicating the columns to be updated and returns a ",(0,r.jsx)(n.code,{children:"std::tuple"})," . You may constrain the ",(0,r.jsx)(n.code,{children:"update"})," query using ",(0,r.jsx)(n.code,{children:"where"})," clauses:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto [affected, query] = DB::table("users")\n ->whereEq("id", 1)\n .update({{"votes", 1}});\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["An ",(0,r.jsx)(n.code,{children:"update"})," and ",(0,r.jsx)(n.code,{children:"delete"})," are affecting statements, so they return ",(0,r.jsx)(n.code,{children:"std::tuple"}),"."]})}),"\n",(0,r.jsx)(n.h4,{id:"update-or-insert",children:"Update Or Insert"}),"\n",(0,r.jsxs)(n.p,{children:["Sometimes you may want to update an existing record in the database or create it if no matching record exists. In this scenario, the ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method may be used. The ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method accepts two arguments: a vector of conditions by which to find the record, and a vector of column and value pairs indicating the columns to be updated."]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method will attempt to locate a matching database record using the first argument's column and value pairs. If the record exists, it will be updated with the values in the second argument. If the record can not be found, a new record will be inserted with the merged attributes of both arguments:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->updateOrInsert(\n {{"email", "john@example.com"}, {"name", "John"}},\n {{"votes", 2}}\n );\n'})}),"\n",(0,r.jsx)(n.h3,{id:"increment-and-decrement",children:"Increment & Decrement"}),"\n",(0,r.jsx)(n.p,{children:"The query builder also provides convenient methods for incrementing or decrementing the value of a given column. Both of these methods accept at least one argument: the column to modify. A second argument may be provided to specify the amount by which the column should be incremented or decremented:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->increment("votes");\n\nDB::table("users")->increment("votes", 5);\n\nDB::table("users")->decrement("votes");\n\nDB::table("users")->decrement("votes", 5.2); // float or double type\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also specify additional columns to update during the operation as a ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->increment("votes", 1, {{"name", "John"}});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You should constrain ",(0,r.jsx)(n.code,{children:"increment"}),", ",(0,r.jsx)(n.code,{children:"decrement"})," by ",(0,r.jsx)(n.code,{children:"where"})," to update only specific record in the database, otherwise a column in all records will be modified."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->whereEq("id", 1).increment("votes", 5);\n'})}),"\n",(0,r.jsx)(n.h2,{id:"delete-statements",children:"Delete Statements"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder's ",(0,r.jsx)(n.code,{children:"remove"}),", or an alias ",(0,r.jsx)(n.code,{children:"deleteRow"})," method may be used to delete records from the table. You may constrain ",(0,r.jsx)(n.code,{children:"delete"}),' statements by adding "where" clauses before calling the ',(0,r.jsx)(n.code,{children:"delete"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->remove();\n\nDB::table("users")->where("votes", ">", 100).remove();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"delete"})," can not be used as the method name because it is the reserved word."]})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass record ",(0,r.jsx)(n.code,{children:"id"})," to the ",(0,r.jsx)(n.code,{children:"remove"})," method as the first argument, it is the shortcut method, which internally calls ",(0,r.jsx)(n.code,{children:"where"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->remove(2);\n'})}),"\n",(0,r.jsx)(n.h3,{id:"truncate-statement",children:"Truncate Statement"}),"\n",(0,r.jsxs)(n.p,{children:["If you wish to truncate an entire table, which will remove all records from the table and reset the auto-incrementing ID to zero, you may use the ",(0,r.jsx)(n.code,{children:"truncate"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->truncate();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"table-truncation--postgresql",children:"Table Truncation & PostgreSQL"}),"\n",(0,r.jsxs)(n.p,{children:["When truncating a PostgreSQL database, the ",(0,r.jsx)(n.code,{children:"CASCADE"})," behavior will be applied. This means that all foreign key related records in other tables will be deleted as well."]}),"\n",(0,r.jsx)(n.h2,{id:"pessimistic-locking",children:"Pessimistic Locking"}),"\n",(0,r.jsxs)(n.p,{children:['The query builder also includes a few functions to help you achieve "pessimistic locking" when executing your ',(0,r.jsx)(n.code,{children:"select"}),' statements. To execute a statement with a "shared lock", you may call the ',(0,r.jsx)(n.code,{children:"sharedLock"})," method. A shared lock prevents the selected rows from being modified until your transaction is committed:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->where("votes", ">", 100)\n .sharedLock()\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,r.jsx)(n.code,{children:"lockForUpdate"}),' method. A "for update" lock prevents the selected records from being modified or from being selected with another shared lock:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->where("votes", ">", 100)\n .lockForUpdate()\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"dd"})," and ",(0,r.jsx)(n.code,{children:"dump"})," methods while building a query to dump the current query bindings and SQL. The ",(0,r.jsx)(n.code,{children:"dd"})," method will display the debug information and then stop executing using the ",(0,r.jsx)(n.code,{children:"exit(1)"}),". The ",(0,r.jsx)(n.code,{children:"dump"})," method will display the debug information and continue executing:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->where("votes", ">", 100).dd();\n\nDB::table("users")->where("votes", ">", 100).dump();\n'})})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>o});var r=s(6540);const t={},a=r.createContext(t);function i(e){const n=r.useContext(a);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/cbe663fe.bedb7f84.js b/assets/js/cbe663fe.bedb7f84.js new file mode 100644 index 000000000..d840926dc --- /dev/null +++ b/assets/js/cbe663fe.bedb7f84.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[995],{4583:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>d,toc:()=>c});var r=s(4848),t=s(8453),a=s(8774);const i={sidebar_position:1,sidebar_label:"Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",keywords:["c++ orm","sql","c++ sql","c++ query builder","database","query builder","tinyorm"]},o="Database: Query Builder",d={id:"database/query-builder",title:"Database: Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",source:"@site/docs/database/query-builder.mdx",sourceDirName:"database",slug:"/database/query-builder",permalink:"/database/query-builder",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Query Builder",description:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application. The query builder uses QSqlQuery parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings.",keywords:["c++ orm","sql","c++ sql","c++ query builder","database","query builder","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"Getting Started",permalink:"/database/getting-started"},next:{title:"Migrations",permalink:"/database/migrations"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Running Database Queries",id:"running-database-queries",level:2},{value:"Retrieving All Rows From A Table",id:"retrieving-all-rows-from-a-table",level:4},{value:"Retrieving A Single Row / Column From A Table",id:"retrieving-a-single-row--column-from-a-table",level:4},{value:"Retrieving A List Of Column Values",id:"retrieving-a-list-of-column-values",level:4},{value:"Concatenate column values",id:"concatenate-column-values",level:4},{value:"Chunking Results",id:"chunking-results",level:3},{value:"Aggregates",id:"aggregates",level:3},{value:"Determining If Records Exist",id:"determining-if-records-exist",level:4},{value:"Select Statements",id:"select-statements",level:2},{value:"Specifying A Select Clause",id:"specifying-a-select-clause",level:4},{value:"Raw Expressions",id:"raw-expressions",level:2},{value:"Raw Methods",id:"raw-methods",level:3},{value:"selectRaw",id:"selectraw",level:4},{value:"fromRaw",id:"fromraw",level:4},{value:"whereRaw / orWhereRaw",id:"whereraw--orwhereraw",level:4},{value:"groupByRaw",id:"groupbyraw",level:3},{value:"havingRaw / orHavingRaw",id:"havingraw--orhavingraw",level:4},{value:"orderByRaw",id:"orderbyraw",level:4},{value:"Joins",id:"joins",level:2},{value:"Inner Join Clause",id:"inner-join-clause",level:4},{value:"Left Join / Right Join Clause",id:"left-join--right-join-clause",level:4},{value:"Cross Join Clause",id:"cross-join-clause",level:4},{value:"Advanced Join Clauses",id:"advanced-join-clauses",level:4},{value:"Subquery Joins",id:"subquery-joins",level:4},{value:"Basic Where Clauses",id:"basic-where-clauses",level:2},{value:"Where Clauses",id:"where-clauses",level:3},{value:"Or Where Clauses",id:"or-where-clauses",level:3},{value:"Condition Operator Overriding",id:"condition-operator-overriding",level:3},{value:"Where Not Clauses",id:"where-not-clauses",level:3},{value:"Additional Where Clauses",id:"additional-where-clauses",level:3},{value:"Logical Grouping",id:"logical-grouping",level:3},{value:"Advanced Where Clauses",id:"advanced-where-clauses",level:2},{value:"Where Exists Clauses",id:"where-exists-clauses",level:3},{value:"Subquery Where Clauses",id:"subquery-where-clauses",level:3},{value:"Ordering, Grouping, Limit & Offset",id:"ordering-grouping-limit-and-offset",level:2},{value:"Ordering",id:"ordering",level:3},{value:"The orderBy Method",id:"the-orderby-method",level:4},{value:"The latest & oldest Methods",id:"the-latest--oldest-methods",level:4},{value:"Random Ordering",id:"random-ordering",level:4},{value:"Removing Existing Orderings",id:"removing-existing-orderings",level:4},{value:"Grouping",id:"grouping",level:3},{value:"The groupBy & having Methods",id:"the-groupby--having-methods",level:4},{value:"Limit & Offset",id:"limit-and-offset",level:3},{value:"The skip & take Methods",id:"the-skip--take-methods",level:4},{value:"Insert Statements",id:"insert-statements",level:2},{value:"Auto-Incrementing IDs",id:"auto-incrementing-ids",level:4},{value:"Upserts",id:"upserts",level:3},{value:"Update Statements",id:"update-statements",level:2},{value:"Update Or Insert",id:"update-or-insert",level:4},{value:"Increment & Decrement",id:"increment-and-decrement",level:3},{value:"Delete Statements",id:"delete-statements",level:2},{value:"Truncate Statement",id:"truncate-statement",level:3},{value:"Table Truncation & PostgreSQL",id:"table-truncation--postgresql",level:4},{value:"Pessimistic Locking",id:"pessimistic-locking",level:2},{value:"Debugging",id:"debugging",level:2}];function h(e){const n={a:"a",admonition:"admonition",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,t.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"database-query-builder",children:"Database: Query Builder"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#running-database-queries",children:"Running Database Queries"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#chunking-results",children:"Chunking Results"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#aggregates",children:"Aggregates"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#select-statements",children:"Select Statements"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#raw-expressions",children:"Raw Expressions"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#joins",children:"Joins"})}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#basic-where-clauses",children:"Basic Where Clauses"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-clauses",children:"Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#or-where-clauses",children:"Or Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-not-clauses",children:"Where Not Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#additional-where-clauses",children:"Additional Where Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#condition-operator-overriding",children:"Condition Operator Overriding"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#logical-grouping",children:"Logical Grouping"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#advanced-where-clauses",children:"Advanced Where Clauses"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#where-exists-clauses",children:"Where Exists Clauses"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#subquery-where-clauses",children:"Subquery Where Clauses"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#ordering-grouping-limit-and-offset",children:"Ordering, Grouping, Limit & Offset"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#ordering",children:"Ordering"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#grouping",children:"Grouping"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#limit-and-offset",children:"Limit & Offset"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#insert-statements",children:"Insert Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#upserts",children:"Upserts"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#update-statements",children:"Update Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#increment-and-decrement",children:"Increment & Decrement"})}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"#delete-statements",children:"Delete Statements"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#truncate-statement",children:"Truncate Statement"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#pessimistic-locking",children:"Pessimistic Locking"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"#debugging",children:"Debugging"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)("div",{className:"api-stability alert alert--success",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(a.A,{to:"/stability#stability-indexes",children:(0,r.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,r.jsx)(n.p,{children:"TinyORM's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application."}),"\n",(0,r.jsxs)(n.p,{children:["The TinyORM query builder uses ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," parameter binding to protect your application against SQL injection attacks. There is no need to clean or sanitize strings passed to the query builder as query bindings."]}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"QSqlQuery"}),' does not support binding column names. Therefore, you should never allow user input to dictate the column names referenced by your queries, including "order by" columns.']})}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"QMYSQL"})," Qt driver contains a bug, if your table contains a ",(0,r.jsx)(n.code,{children:"json"})," column type, then you must explicitly name columns other than ",(0,r.jsx)(n.code,{children:"json"})," columns instead of the ",(0,r.jsx)(n.code,{children:"*"})," shorthand, otherwise, you will get an empty result, or all column values will be invalid QVariant-s, or it may even return half of the columns. The ",(0,r.jsx)(n.code,{children:"QPSQL"})," driver returns correct results and doesn't have problem with ",(0,r.jsx)(n.code,{children:"json"})," columns. It was fixed in the Qt ",(0,r.jsx)(n.del,{children:"5.15.12"}),", 6.2.7, 6.5.0 ",(0,r.jsx)(n.a,{href:"https://bugreports.qt.io/browse/QTBUG-101680",children:"QTBUG-101680"}),"."]})}),"\n",(0,r.jsx)(n.h2,{id:"running-database-queries",children:"Running Database Queries"}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-all-rows-from-a-table",children:"Retrieving All Rows From A Table"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"table"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade to begin a query. The ",(0,r.jsx)(n.code,{children:"table"})," method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the query and then finally retrieve the results of the query using the ",(0,r.jsx)(n.code,{children:"get"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n// Log a list of all of the application\'s users\nauto query = DB::table("users")->get();\n\nwhile (query.next())\n qDebug() << "id :" << query.value("id").toULongLong() << ";"\n << "name :" << query.value("name").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"get"})," method returns a ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," containing the results of the query where each result can be accessed by ",(0,r.jsx)(n.code,{children:"QSqlQuery::next"})," method, look into the ",(0,r.jsx)(n.code,{children:"QSqlQuery"}),' documentation how to obtain results from the "query". You may access each column\'s value by ',(0,r.jsx)(n.code,{children:"QSqlQuery::value"})," method. The first ",(0,r.jsx)(n.code,{children:"bool"})," return value is the value returned from ",(0,r.jsx)(n.code,{children:"QSqlQuery::exec"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nauto users = DB::table("users")->get();\n\nwhile(users.next())\n qDebug() << users.value("name").toString();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-a-single-row--column-from-a-table",children:"Retrieving A Single Row / Column From A Table"}),"\n",(0,r.jsxs)(n.p,{children:["If you just need to retrieve a single row from a database table, you may use the ",(0,r.jsx)(n.code,{children:"QueryBuilder::first"})," method. This method will return a ",(0,r.jsx)(n.code,{children:"QSqlQuery"})," object, on which was internally called ",(0,r.jsx)(n.code,{children:"QSqlQuery::first"})," method. This method retrieves the first record in the result, if available, and positions the query on the retrieved record:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")->whereEq("name", "John").first();\n\nuser.value("email").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you don't need an entire row, you may extract a single value from a record using the ",(0,r.jsx)(n.code,{children:"value"})," method. This method will return the value of the column directly as ",(0,r.jsx)(n.code,{children:"QVariant"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto email = DB::table("users")->whereEq("name", "John").value("email").toString();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["To retrieve a single row by its ",(0,r.jsx)(n.code,{children:"id"})," column value, use the ",(0,r.jsx)(n.code,{children:"find"})," method. This method retrieves the first record in the result, if available, and positions the query on the retrieved record:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")->find(3);\n\nuser.value("email").toString();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"retrieving-a-list-of-column-values",children:"Retrieving A List Of Column Values"}),"\n",(0,r.jsxs)(n.p,{children:["If you would like to retrieve the ",(0,r.jsx)(n.code,{children:"QList"})," instance containing the values of a single column, you may use the ",(0,r.jsx)(n.code,{children:"pluck"})," method. In this example, we'll retrieve a collection of user titles:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\n#include \n\nconst auto titles = DB::table("users")->pluck("title");\n\nfor (const auto &title : titles)\n qDebug() << title.value();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may specify the column that the resulting collection should use as its keys by providing a second argument to the ",(0,r.jsx)(n.code,{children:"pluck"})," method, following example returns the ",(0,r.jsx)(n.code,{children:"std::map"}),' of "titles" keyed by "names":']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto titles = DB::table("users")->pluck("title", "name");\n\nfor (auto &&[name, title] : titles)\n qDebug() << name << ":" << title.value();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also use ",(0,r.jsx)(n.code,{children:'pluck("name", "id")'}),", it returns the ",(0,r.jsx)(n.code,{children:"std::map"}),' of "names" keyed by its "ids".']}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["This second ",(0,r.jsx)(n.code,{children:"pluck"})," overload returns ",(0,r.jsx)(n.code,{children:"std::map"})," so you have to provide a template argument for the key type."]})}),"\n",(0,r.jsx)(n.h4,{id:"concatenate-column-values",children:"Concatenate column values"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"implode"})," method can be used to join column values. For example, you may use this method to concatenate prices with the ",(0,r.jsx)(n.code,{children:", "})," character as the glue:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("orders")->where("price", ">", 100).implode("price", ", ");\n'})}),"\n",(0,r.jsx)(n.h3,{id:"chunking-results",children:"Chunking Results"}),"\n",(0,r.jsxs)(n.p,{children:["If you need to work with thousands of database records, consider using the ",(0,r.jsx)(n.code,{children:"chunk"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade. This method retrieves a small chunk of results at a time and feeds each chunk into a lambda expression for processing. For example, let's retrieve the entire ",(0,r.jsx)(n.code,{children:"users"})," table in chunks of 100 records at a time:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->orderBy("id").chunk(100, [](QSqlQuery &users, const int page)\n{\n while (users.next()) {\n //\n }\n\n return true;\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may stop further chunks from being processed by returning ",(0,r.jsx)(n.code,{children:"false"})," from the closure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->orderBy("id").chunk(100, [](QSqlQuery &users, const int page)\n{\n // Process the records...\n\n return false;\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you are updating database records while chunking results, your chunk results could change in unexpected ways. If you plan to update the retrieved records while chunking, it is always best to use the ",(0,r.jsx)(n.code,{children:"chunkById"})," method instead. This method will automatically paginate the results based on the record's primary key:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->whereEq("active", false)\n .orderBy("id")\n .chunkById(100, [](QSqlQuery &users, const int /*unused*/)\n {\n while (users.next())\n DB::table("users")\n ->whereEq("id", users.value("id"))\n .update({{"active", true}});\n\n return true;\n });\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"caution",children:(0,r.jsxs)(n.p,{children:["When updating or deleting records inside the chunk lambda expression, any changes to the primary key or foreign keys could affect the chunk query. This could potentially result in records not being included in the chunked results, it can be avoided using the ",(0,r.jsx)(n.code,{children:"chunkById"})," method."]})}),"\n",(0,r.jsx)(n.h3,{id:"aggregates",children:"Aggregates"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder also provides a variety of methods for retrieving aggregate values like ",(0,r.jsx)(n.code,{children:"count"}),", ",(0,r.jsx)(n.code,{children:"max"}),", ",(0,r.jsx)(n.code,{children:"min"}),", ",(0,r.jsx)(n.code,{children:"avg"}),", and ",(0,r.jsx)(n.code,{children:"sum"}),". You may call any of these methods after constructing your query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")->count();\n\nauto price = DB::table("orders")->max("price");\n'})}),"\n",(0,r.jsx)(n.p,{children:"Of course, you may combine these methods with other clauses to fine-tune how your aggregate value is calculated:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto price = DB::table("orders")\n ->whereEq("finalized", 1)\n .avg("price");\n'})}),"\n",(0,r.jsx)(n.h4,{id:"determining-if-records-exist",children:"Determining If Records Exist"}),"\n",(0,r.jsxs)(n.p,{children:["Instead of using the ",(0,r.jsx)(n.code,{children:"count"})," method to determine if any records exist that match your query's constraints, you may use the ",(0,r.jsx)(n.code,{children:"exists"})," and ",(0,r.jsx)(n.code,{children:"doesntExist"})," methods:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'if (DB::table("orders")->whereEq("finalized", 1).exists()) {\n // ...\n}\n\nif (DB::table("orders")->whereEq("finalized", 1).doesntExist()) {\n // ...\n}\n'})}),"\n",(0,r.jsx)(n.h2,{id:"select-statements",children:"Select Statements"}),"\n",(0,r.jsx)(n.h4,{id:"specifying-a-select-clause",children:"Specifying A Select Clause"}),"\n",(0,r.jsxs)(n.p,{children:["You may not always want to select all columns from a database table. Using the ",(0,r.jsx)(n.code,{children:"select"}),' method, you can specify a custom "select" clause for the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")\n ->select({"name", "email as user_email"})\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"distinct"})," method allows you to force the query to return distinct results:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->distinct().get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["If you already have a query builder instance and you wish to add a column to its existing select clause, you may use the ",(0,r.jsx)(n.code,{children:"addSelect"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto query = DB::table("users")->select("name");\n\nauto users = query.addSelect("age").get();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["You can also pass subqueries to the ",(0,r.jsx)(n.code,{children:"select"})," and ",(0,r.jsx)(n.code,{children:"addSelect"})," methods. A subquery can be a lambda expression, raw string, or the ",(0,r.jsx)(n.code,{children:"QueryBuilder"})," instance."]})}),"\n",(0,r.jsx)(n.h2,{id:"raw-expressions",children:"Raw Expressions"}),"\n",(0,r.jsxs)(n.p,{children:["Sometimes you may need to insert an arbitrary string into a query. To create a raw string expression, you may use the ",(0,r.jsx)(n.code,{children:"raw"})," method provided by the ",(0,r.jsx)(n.code,{children:"DB"})," facade:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->select(DB::raw("count(*) as user_count, status"))\n .where("status", "<>", 1)\n .groupBy("status")\n .get();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsx)(n.p,{children:"Raw statements will be injected into the query as strings, so you should be extremely careful to avoid creating SQL injection vulnerabilities."})}),"\n",(0,r.jsx)(n.h3,{id:"raw-methods",children:"Raw Methods"}),"\n",(0,r.jsxs)(n.p,{children:["Instead of using the ",(0,r.jsx)(n.code,{children:"DB::raw"})," method, you may also use the following methods to insert a raw expression into various parts of your query. ",(0,r.jsx)(n.strong,{children:"Remember, TinyORM can not guarantee that any query using raw expressions is protected against SQL injection vulnerabilities."})]}),"\n",(0,r.jsx)(n.h4,{id:"selectraw",children:(0,r.jsx)(n.code,{children:"selectRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"selectRaw"})," method can be used in place of ",(0,r.jsx)(n.code,{children:"addSelect(DB::raw(...))"}),". This method accepts an optional vector of bindings as its second argument:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->selectRaw("price * ? as price_with_tax", {1.0825})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"fromraw",children:(0,r.jsx)(n.code,{children:"fromRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"fromRaw"}),' method may be used to provide a raw string as the value of the "from" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::connection("postgres").query()\n ->fromRaw("(select id, name from users where id < ?) as u", {5})\n .where("id", "<", 3)\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"whereraw--orwhereraw",children:(0,r.jsx)(n.code,{children:"whereRaw / orWhereRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereRaw"})," and ",(0,r.jsx)(n.code,{children:"orWhereRaw"}),' methods can be used to inject a raw "where" clause into your query. These methods accept an optional vector of bindings as their second argument:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->whereRaw("price > IF(state = \\"TX\\", ?, 100)", {200})\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"groupbyraw",children:(0,r.jsx)(n.code,{children:"groupByRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"groupByRaw"})," method may be used to provide a raw string as the value of the ",(0,r.jsx)(n.code,{children:"group by"})," clause:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->select({"city", "state"})\n .groupByRaw("city, state")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"havingraw--orhavingraw",children:(0,r.jsx)(n.code,{children:"havingRaw / orHavingRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"havingRaw"})," and ",(0,r.jsx)(n.code,{children:"orHavingRaw"}),' methods may be used to provide a raw string as the value of the "having" clause. These methods accept an optional vector of bindings as their second argument:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->select({"department", DB::raw("SUM(price) as total_sales")})\n .groupBy("department")\n .havingRaw("SUM(price) > ?", {2500})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"orderbyraw",children:(0,r.jsx)(n.code,{children:"orderByRaw"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"orderByRaw"}),' method may be used to provide a raw string as the value of the "order by" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto orders = DB::table("orders")\n ->orderByRaw("updated_at - created_at DESC")\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"joins",children:"Joins"}),"\n",(0,r.jsx)(n.h4,{id:"inner-join-clause",children:"Inner Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:['The query builder may also be used to add join clauses to your queries. To perform a basic "inner join", you may use the ',(0,r.jsx)(n.code,{children:"join"})," method on a query builder instance. The first argument passed to the ",(0,r.jsx)(n.code,{children:"join"})," method is the name of the table you need to join to, while the remaining arguments specify the column constraints for the join. You may even join multiple tables in a single query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n\nauto users = DB::table("users")\n ->join("contacts", "users.id", "=", "contacts.user_id")\n .join("orders", "users.id", "=", "orders.user_id")\n .select({"users.*", "contacts.phone", "orders.price"})\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"left-join--right-join-clause",children:"Left Join / Right Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:['If you would like to perform a "left join" or "right join" instead of an "inner join", use the ',(0,r.jsx)(n.code,{children:"leftJoin"})," or ",(0,r.jsx)(n.code,{children:"rightJoin"})," methods. These methods have the same signature as the ",(0,r.jsx)(n.code,{children:"join"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->leftJoin("posts", "users.id", "=", "posts.user_id")\n .get();\n\nauto users = DB::table("users")\n ->rightJoin("posts", "users.id", "=", "posts.user_id")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"cross-join-clause",children:"Cross Join Clause"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"crossJoin"}),' method to perform a "cross join". Cross joins generate a cartesian product between the first table and the joined table:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto sizes = DB::table("sizes")\n ->crossJoin("colors")\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"advanced-join-clauses",children:"Advanced Join Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["You may also specify more advanced join clauses. To get started, pass a lambda expression as the second argument to the ",(0,r.jsx)(n.code,{children:"join"})," method. The lambda expression will receive a ",(0,r.jsx)(n.code,{children:"Orm::Query::JoinClause"}),' instance which allows you to specify constraints on the "join" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include \n#include \n\nDB::table("users")\n ->join("contacts", [](auto &join)\n {\n join.on("users.id", "=", "contacts.user_id")\n .orOn(...);\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['If you would like to use a "where" clause on your joins, you may use the ',(0,r.jsx)(n.code,{children:"where"})," and ",(0,r.jsx)(n.code,{children:"orWhere"})," methods provided by the ",(0,r.jsx)(n.code,{children:"Orm::Query::JoinClause"})," instance. Instead of comparing two columns, these methods will compare the column against a value:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->join("contacts", [](auto &join)\n {\n join.on("users.id", "=", "contacts.user_id")\n .where("contacts.user_id", ">", 5);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"subquery-joins",children:"Subquery Joins"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"joinSub"}),", ",(0,r.jsx)(n.code,{children:"leftJoinSub"}),", and ",(0,r.jsx)(n.code,{children:"rightJoinSub"})," methods to join a query to a subquery. Each of these methods receives three arguments: the subquery, its table alias, and a lambda expression that defines the related columns. In this example, we will retrieve a collection of users where each user record also contains the ",(0,r.jsx)(n.code,{children:"created_at"})," timestamp of the user's most recently published blog post:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto latestPosts = DB::table("posts")\n ->select({"user_id", DB::raw("MAX(created_at) as last_post_created_at")})\n .whereEq("is_published", true)\n .groupBy("user_id");\n\nauto users = DB::table("users")\n ->joinSub(latestPosts, "latest_posts", [](auto &join)\n {\n join.on("users.id", "=", "latest_posts.user_id");\n }).get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"basic-where-clauses",children:"Basic Where Clauses"}),"\n",(0,r.jsx)(n.h3,{id:"where-clauses",children:"Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the query builder's ",(0,r.jsx)(n.code,{children:"where"}),' method to add "where" clauses to the query. The most basic call to the ',(0,r.jsx)(n.code,{children:"where"})," method requires three arguments. The first argument is the name of the column. The second argument is an operator, which can be any of the database's supported operators. The third argument is the value to compare against the column's value."]}),"\n",(0,r.jsxs)(n.p,{children:["For example, the following query retrieves users where the value of the ",(0,r.jsx)(n.code,{children:"votes"})," column is equal to ",(0,r.jsx)(n.code,{children:"100"})," and the value of the ",(0,r.jsx)(n.code,{children:"age"})," column is greater than ",(0,r.jsx)(n.code,{children:"35"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", "=", 100)\n .where("age", ">", 35)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["For convenience, if you want to verify that a column is ",(0,r.jsx)(n.code,{children:"="})," to a given value, you may call ",(0,r.jsx)(n.code,{children:"whereEq"})," method. Similar ",(0,r.jsx)(n.code,{children:"XxxEq"})," methods are also defined for other commands:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->whereEq("votes", 100).get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"As previously mentioned, you may use any operator that is supported by your database system:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">=", 100)\n .get();\n\nauto users = DB::table("users")\n ->where("votes", "<>", 100)\n .get();\n\nauto users = DB::table("users")\n ->where("name", "like", "T%")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a ",(0,r.jsx)(n.code,{children:"QList"})," of conditions to the ",(0,r.jsx)(n.code,{children:"where"})," function. Each ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure should contain the four arguments typically passed to the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"status", 1}, // "=" by default\n {"subscribed", 1, "<>"},\n }).get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"or-where-clauses",children:"Or Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["When chaining together calls to the query builder's ",(0,r.jsx)(n.code,{children:"where"}),' method, the "where" clauses will be joined together using the ',(0,r.jsx)(n.code,{children:"and"})," operator. However, you may use the ",(0,r.jsx)(n.code,{children:"orWhere"})," or ",(0,r.jsx)(n.code,{children:"orWhereEq"})," method to join a clause to the query using the ",(0,r.jsx)(n.code,{children:"or"})," operator. The ",(0,r.jsx)(n.code,{children:"orWhere"})," method accepts the same arguments as the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">", 100)\n .orWhere("name", "=", "John")\n .orWhereEq("name", "Jack")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['If you need to group an "or" condition within parentheses, you may pass a lambda expression as the first argument to the ',(0,r.jsx)(n.code,{children:"orWhere"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("votes", ">", 100)\n .orWhere([](auto &query)\n {\n query.whereEq("name", "Abigail")\n .where("votes", ">", 50);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"The example above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where votes > 100 or (name = "Abigail" and votes > 50)\n'})}),"\n",(0,r.jsx)(n.h3,{id:"condition-operator-overriding",children:"Condition Operator Overriding"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"where"})," method overload with a ",(0,r.jsx)(n.code,{children:"QList"})," as the first argument joins conditions using the ",(0,r.jsx)(n.code,{children:"and"})," operator by default:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"votes", 50, ">"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Conditions operator can be overridden by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"votes", 50, ">", "or"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Or by the second ",(0,r.jsx)(n.code,{children:"where"})," argument, in this case all conditions will be joined by this condition, but it is still possible to override them by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where({\n {"first_name", "John"},\n {"last_name", "Smith"},\n {"votes", 50, ">", "and"},\n }, "or")\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"The example above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where (first_name = "John" or last_name = "Smith" and votes > 50)\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["Still, it is a better idea to use ",(0,r.jsx)(n.a,{href:"#logical-grouping",children:"Logical Grouping"})," described few lines below, which allows better control of the parentheses."]})}),"\n",(0,r.jsx)(n.h3,{id:"where-not-clauses",children:"Where Not Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNot"})," and ",(0,r.jsx)(n.code,{children:"orWhereNot"})," methods may be used to negate a given group of query constraints. For example, the following query excludes products that are on clearance or which have a price that is less than ten:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto products = DB::table("products")\n ->whereNot([](auto &query) {\n query.whereEq("clearance", true)\n .orWhere("price", "<", 10);\n })\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"additional-where-clauses",children:"Additional Where Clauses"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereBetween / orWhereBetween"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereBetween"})," method verifies that a column's value is between two values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereBetween("votes", {1, 100})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNotBetween / orWhereNotBetween"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotBetween"})," method verifies that a column's value lies outside of two values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotBetween("votes", {1, 100})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereBetweenColumns / orWhereBetweenColumns"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereBetweenColumns"})," method verifies that a column's value is between two values in given columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto files = DB::table("files")\n ->whereBetweenColumns("quota", {"min_allowed_quota", "max_allowed_quota"})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNotBetweenColumns / orWhereNotBetweenColumns"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotBetweenColumns"})," method verifies that a column's value lies outside of two values in given columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto files = DB::table("files")\n ->whereNotBetweenColumns("quota", {"min_allowed_quota", "max_allowed_quota"})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereIn / whereNotIn / orWhereIn / orWhereNotIn"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereIn"})," method verifies that a given column's value is contained within the given ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereIn("id", {1, 2, 3})\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotIn"})," method verifies that the given column's value is not contained in the given ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotIn("id", {1, 2, 3})\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereNull / whereNotNull / orWhereNull / orWhereNotNull"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNull"})," method verifies that the value of the given column is ",(0,r.jsx)(n.code,{children:"NULL"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNull("updated_at")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereNotNull"})," method verifies that the column's value is not ",(0,r.jsx)(n.code,{children:"NULL"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereNotNull("updated_at")\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereDate / whereTime / whereDay / whereMonth / whereYear"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDate"})," method may be used to compare a column's value against a date:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereDate("created_at", EQ, QDate(2022, 11, 18))\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereTime"})," method may be used to compare a column's value against a specific time:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereTime("created_at", "=", QTime(11, 14, 23))\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDay"})," method may be used to compare a column's value against a specific day of the month:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereDay("created_at", "<=", 15)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereMonth"})," method may be used to compare a column's value against a specific month:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereEqMonth("created_at", 12)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereYear"})," method may be used to compare a column's value against a specific year:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereEqYear("created_at", 2016)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDate"})," and ",(0,r.jsx)(n.code,{children:"whereTime"})," methods also accept a ",(0,r.jsx)(n.code,{children:"QDateTime"})," instance or you can pass values as a ",(0,r.jsx)(n.code,{children:"QString"})," in ",(0,r.jsx)(n.code,{children:"2022-12-31"})," or ",(0,r.jsx)(n.code,{children:"09:15:11"})," formats."]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereDay"}),", ",(0,r.jsx)(n.code,{children:"whereMoth"}),", and ",(0,r.jsx)(n.code,{children:"whereYear"})," accept ",(0,r.jsx)(n.code,{children:"QDate"})," or ",(0,r.jsx)(n.code,{children:"QDateTime"})," instances, an integral number or a ",(0,r.jsx)(n.code,{children:"QString"})," that contains an integral number."]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["All the above methods offer ",(0,r.jsx)(n.code,{children:"whereEqXyz"})," and ",(0,r.jsx)(n.code,{children:"orWhereXyz"})," shortcut methods."]})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"whereColumn / orWhereColumn"})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereColumnEq"})," method may be used to verify that two columns are equal:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumnEq("first_name", "last_name")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a comparison operator to the ",(0,r.jsx)(n.code,{children:"whereColumn"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn("updated_at", ">", "created_at")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass a ",(0,r.jsx)(n.code,{children:"QList"})," of column comparisons to the ",(0,r.jsx)(n.code,{children:"whereColumn"})," method. These conditions will be joined using the ",(0,r.jsx)(n.code,{children:"and"})," operator:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Conditions operator can also be overridden by the fourth argument in the ",(0,r.jsx)(n.code,{children:"Orm::WhereColumnItem"})," structure:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">", "or"},\n }).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Or by the second ",(0,r.jsx)(n.code,{children:"whereColumn"})," argument:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereColumn({\n {"first_name", "last_name"},\n {"updated_at", "created_at", ">"},\n }, "or")\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"logical-grouping",children:"Logical Grouping"}),"\n",(0,r.jsxs)(n.p,{children:['Sometimes you may need to group several "where" clauses within parentheses in order to achieve your query\'s desired logical grouping. In fact, you should generally always group calls to the ',(0,r.jsx)(n.code,{children:"orWhere"})," method in parentheses in order to avoid unexpected query behavior. To accomplish this, you may pass a lambda expression to the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->where("name", "=", "John")\n .where([](auto &query)\n {\n query.where("votes", ">", 100)\n .orWhere("title", "=", "Admin");\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["As you can see, passing a lambda expression into the ",(0,r.jsx)(n.code,{children:"where"})," method instructs the query builder to begin a constraint group. The lambda expression will receive a query builder instance which you can use to set the constraints that should be contained within the parenthesis group. The example above will produce the following SQL:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:'select * from users where name = "John" and (votes > 100 or title = "Admin")\n'})}),"\n",(0,r.jsx)(n.h2,{id:"advanced-where-clauses",children:"Advanced Where Clauses"}),"\n",(0,r.jsx)(n.h3,{id:"where-exists-clauses",children:"Where Exists Clauses"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"whereExists"}),' method allows you to write "where exists" SQL clauses. The ',(0,r.jsx)(n.code,{children:"whereExists"}),' method accepts a lambda expression which will receive a query builder instance, allowing you to define the query that should be placed inside of the "exists" clause:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereExists([](auto &query)\n {\n query.select(DB::raw(1))\n .from("orders")\n .whereColumnEq("orders.user_id", "users.id");\n })\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may provide a query object to the ",(0,r.jsx)(n.code,{children:"whereExists"})," method instead of a lambda expression:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'// Ownership of the std::shared_ptr\nauto builder = DB::table("orders");\nauto orders = builder->select(DB::raw(1))\n .whereColumnEq("orders.user_id", "users.id");\n\nauto users = DB::table("users")\n ->whereExists(orders)\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"Or directly:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->whereExists(DB::table("orders")\n ->select(DB::raw(1))\n .whereColumnEq("orders.user_id", "users.id"))\n .get();\n'})}),"\n",(0,r.jsx)(n.p,{children:"All of the examples above will produce the following SQL:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sql",children:"select * from users\nwhere exists (\n select 1\n from orders\n where orders.user_id = users.id\n)\n"})}),"\n",(0,r.jsx)(n.h3,{id:"subquery-where-clauses",children:"Subquery Where Clauses"}),"\n",(0,r.jsxs)(n.p,{children:['Sometimes you may need to construct a "where" clause that compares the results of a subquery to a given value. You may accomplish this by passing a lambda expression and a value to the ',(0,r.jsx)(n.code,{children:"where"}),' method. For example, the following query will retrieve all users who have a recent "membership" of a given type:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include "models/user.hpp"\n\nauto users = User::whereEq([](auto &query)\n{\n query.select("type")\n .from("membership")\n .whereColumnEq("membership.user_id", "users.id")\n .orderByDesc("membership.start_date")\n .limit(1);\n}, "Pro")->get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:['Or, you may need to construct a "where" clause that compares a column to the results of a subquery. You may accomplish this by passing a column, operator, and lambda expression to the ',(0,r.jsx)(n.code,{children:"where"})," method. For example, the following query will retrieve all income records where the amount is less than average;"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'#include "models/income.hpp"\n\nauto incomes = Income::where("amount", "<", [](auto &query)\n{\n query.selectRaw("avg(i.amount)").from("incomes as i");\n})->get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"ordering-grouping-limit-and-offset",children:"Ordering, Grouping, Limit & Offset"}),"\n",(0,r.jsx)(n.h3,{id:"ordering",children:"Ordering"}),"\n",(0,r.jsxs)(n.h4,{id:"the-orderby-method",children:["The ",(0,r.jsx)(n.code,{children:"orderBy"})," Method"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"orderBy"})," method allows you to sort the results of the query by a given column. The first argument accepted by the ",(0,r.jsx)(n.code,{children:"orderBy"})," method should be the column you wish to sort by, while the second argument determines the direction of the sort and may be either ",(0,r.jsx)(n.code,{children:"asc"})," or ",(0,r.jsx)(n.code,{children:"desc"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->orderBy("name", "desc")\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["To sort by multiple columns, you may simply invoke ",(0,r.jsx)(n.code,{children:"orderBy"})," as many times as necessary:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->orderBy("name", "desc")\n .orderBy("email", "asc")\n .get();\n'})}),"\n",(0,r.jsxs)(n.h4,{id:"the-latest--oldest-methods",children:["The ",(0,r.jsx)(n.code,{children:"latest"})," & ",(0,r.jsx)(n.code,{children:"oldest"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"latest"})," and ",(0,r.jsx)(n.code,{children:"oldest"})," methods allow you to easily order results by date. By default, the result will be ordered by the table's ",(0,r.jsx)(n.code,{children:"created_at"})," column. Or, you may pass the column name that you wish to sort by:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto user = DB::table("users")\n ->latest()\n .first();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"random-ordering",children:"Random Ordering"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"inRandomOrder"})," method may be used to sort the query results randomly. For example, you may use this method to fetch a random user:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto randomUser = DB::table("users")\n ->inRandomOrder()\n .first();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"removing-existing-orderings",children:"Removing Existing Orderings"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"reorder"}),' method removes all of the "order by" clauses that have previously been applied to the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto &query = DB::table("users")->orderBy("name");\n\nauto unorderedUsers = query.reorder().get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may pass a column and direction when calling the ",(0,r.jsx)(n.code,{children:"reorder"}),' method in order to remove all existing "order by" clauses and apply an entirely new order to the query:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto &query = DB::table("users")->orderBy("name");\n\nauto usersOrderedByEmail = query.reorder("email", "desc").get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"grouping",children:"Grouping"}),"\n",(0,r.jsxs)(n.h4,{id:"the-groupby--having-methods",children:["The ",(0,r.jsx)(n.code,{children:"groupBy"})," & ",(0,r.jsx)(n.code,{children:"having"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["As you might expect, the ",(0,r.jsx)(n.code,{children:"groupBy"})," and ",(0,r.jsx)(n.code,{children:"having"})," methods may be used to group the query results. The ",(0,r.jsx)(n.code,{children:"having"})," method's signature is similar to that of the ",(0,r.jsx)(n.code,{children:"where"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->groupBy("account_id")\n .having("account_id", ">", 100)\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may pass multiple items to the ",(0,r.jsx)(n.code,{children:"groupBy"})," method to group by multiple columns:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->groupBy({"first_name", "status"})\n .having("account_id", ">", 100)\n .get();\n'})}),"\n",(0,r.jsx)(n.h3,{id:"limit-and-offset",children:"Limit & Offset"}),"\n",(0,r.jsxs)(n.h4,{id:"the-skip--take-methods",children:["The ",(0,r.jsx)(n.code,{children:"skip"})," & ",(0,r.jsx)(n.code,{children:"take"})," Methods"]}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"skip"})," and ",(0,r.jsx)(n.code,{children:"take"})," methods to limit the number of results returned from the query or to skip a given number of results in the query:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")->skip(10).take(5).get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,r.jsx)(n.code,{children:"limit"})," and ",(0,r.jsx)(n.code,{children:"offset"})," methods. These methods are functionally equivalent to the ",(0,r.jsx)(n.code,{children:"take"})," and ",(0,r.jsx)(n.code,{children:"skip"})," methods, respectively:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto users = DB::table("users")\n ->offset(10)\n .limit(5)\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"insert-statements",children:"Insert Statements"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder also provides an ",(0,r.jsx)(n.code,{children:"insert"})," method that may be used to insert records into the database table. The ",(0,r.jsx)(n.code,{children:"insert"})," method accepts the ",(0,r.jsx)(n.code,{children:"QVariantMap"})," of column names and values:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({\n {"email", "kayla@example.com"},\n {"votes", 0},\n});\n'})}),"\n",(0,r.jsx)(a.A,{id:"multi-insert-overload"}),"\n",(0,r.jsxs)(n.p,{children:["You may insert several records at once by passing a ",(0,r.jsx)(n.code,{children:"QList"})," for column names as the first argument and ",(0,r.jsx)(n.code,{children:"QList>"})," for values as the second argument. Each ",(0,r.jsx)(n.code,{children:"QList"})," represents a record that should be inserted into the table. This overload is useful for multi-insert and allows to specify column names only once:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({"email", "votes"},\n{\n {"picard@example.com", 0},\n {"janeway@example.com", 0},\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also insert several records at once by passing a ",(0,r.jsx)(n.code,{children:"QList"}),". Each ",(0,r.jsx)(n.code,{children:"QVariantMap"})," represents a record that should be inserted into the table:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insert({\n {{"email", "picard@example.com"}, {"votes", 0}},\n {{"email", "janeway@example.com"}, {"votes", 0}},\n});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"insertOrIgnore"})," method will ignore duplicate record errors while inserting records into the database and also provides the same overloads like the ",(0,r.jsx)(n.code,{children:"insert"})," method. When using this method, you should be aware that duplicate record errors will be ignored and other types of errors may also be ignored depending on the database engine. For example, ",(0,r.jsx)(n.code,{children:"insertOrIgnore"})," will ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/en/sql-mode.html#ignore-effect-on-execution",children:"bypass MySQL's strict mode"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->insertOrIgnore({"id", "email"},\n{\n {1, "sisko@example.com"},\n {2, "archer@example.com"},\n});\n\nDB::table("users")->insertOrIgnore({\n {{"id", 1}, {"email", "sisko@example.com"}},\n {{"id", 2}, {"email", "archer@example.com"}},\n});\n'})}),"\n",(0,r.jsx)(n.h4,{id:"auto-incrementing-ids",children:"Auto-Incrementing IDs"}),"\n",(0,r.jsxs)(n.p,{children:["If the table has an auto-incrementing id, use the ",(0,r.jsx)(n.code,{children:"insertGetId"})," method to insert a record and then retrieve the ID:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto id = DB::table("users")->insertGetId({\n {"email", "john@example.com"},\n {"votes", 0},\n});\n'})}),"\n",(0,r.jsx)(n.h3,{id:"upserts",children:"Upserts"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"upsert"})," method will insert records that do not exist and update the records that already exist with new values that you may specify. The method's first argument consists of the values to insert or update, while the second argument lists the column(s) that uniquely identify records within the associated table. The method's third and final argument is a vector of columns that should be updated if a matching record already exists in the database:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("flights")->upsert(\n {{{"departure", "Oakland"}, {"destination", "San Diego"}, {"price", 99}},\n {{"departure", "Chicago"}, {"destination", "New York"}, {"price", 150}}},\n {"departure", "destination"},\n {"price"}\n);\n'})}),"\n",(0,r.jsxs)(n.p,{children:["In the example above, TinyORM will attempt to insert two records. If a record already exists with the same ",(0,r.jsx)(n.code,{children:"departure"})," and ",(0,r.jsx)(n.code,{children:"destination"})," column values, TinyORM will update that record's ",(0,r.jsx)(n.code,{children:"price"})," column."]}),"\n",(0,r.jsx)(n.admonition,{type:"caution",children:(0,r.jsxs)(n.p,{children:["All databases except SQL Server require the columns in the second argument of the ",(0,r.jsx)(n.code,{children:"upsert"}),' method to have a "primary" or "unique" index. In addition, the MySQL database driver ignores the second argument of the ',(0,r.jsx)(n.code,{children:"upsert"}),' method and always uses the "primary" and "unique" indexes of the table to detect existing records.']})}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["Row and column aliases will be used with the MySQL server >=8.0.19 instead of the VALUES() function as is described in the MySQL ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/refman/9.0/en/insert-on-duplicate.html",children:"documentation"}),". The MySQL server version is auto-detected and can be overridden in the ",(0,r.jsx)(n.a,{href:"/database/getting-started#configuration",children:"configuration"}),"."]})}),"\n",(0,r.jsx)(n.h2,{id:"update-statements",children:"Update Statements"}),"\n",(0,r.jsxs)(n.p,{children:["In addition to inserting records into the database, the query builder can also update existing records using the ",(0,r.jsx)(n.code,{children:"update"})," method. The ",(0,r.jsx)(n.code,{children:"update"})," method, accepts a ",(0,r.jsx)(n.code,{children:"QList"})," of column and value pairs, indicating the columns to be updated and returns a ",(0,r.jsx)(n.code,{children:"std::tuple"})," . You may constrain the ",(0,r.jsx)(n.code,{children:"update"})," query using ",(0,r.jsx)(n.code,{children:"where"})," clauses:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'auto [affected, query] = DB::table("users")\n ->whereEq("id", 1)\n .update({{"votes", 1}});\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["An ",(0,r.jsx)(n.code,{children:"update"})," and ",(0,r.jsx)(n.code,{children:"delete"})," are affecting statements, so they return ",(0,r.jsx)(n.code,{children:"std::tuple"}),"."]})}),"\n",(0,r.jsx)(n.h4,{id:"update-or-insert",children:"Update Or Insert"}),"\n",(0,r.jsxs)(n.p,{children:["Sometimes you may want to update an existing record in the database or create it if no matching record exists. In this scenario, the ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method may be used. The ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method accepts two arguments: a vector of conditions by which to find the record, and a vector of column and value pairs indicating the columns to be updated."]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"updateOrInsert"})," method will attempt to locate a matching database record using the first argument's column and value pairs. If the record exists, it will be updated with the values in the second argument. If the record can not be found, a new record will be inserted with the merged attributes of both arguments:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->updateOrInsert(\n {{"email", "john@example.com"}, {"name", "John"}},\n {{"votes", 2}}\n );\n'})}),"\n",(0,r.jsx)(n.h3,{id:"increment-and-decrement",children:"Increment & Decrement"}),"\n",(0,r.jsx)(n.p,{children:"The query builder also provides convenient methods for incrementing or decrementing the value of a given column. Both of these methods accept at least one argument: the column to modify. A second argument may be provided to specify the amount by which the column should be incremented or decremented:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->increment("votes");\n\nDB::table("users")->increment("votes", 5);\n\nDB::table("users")->decrement("votes");\n\nDB::table("users")->decrement("votes", 5.2); // float or double type\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You may also specify additional columns to update during the operation as a ",(0,r.jsx)(n.code,{children:"QList"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->increment("votes", 1, {{"name", "John"}});\n'})}),"\n",(0,r.jsxs)(n.p,{children:["You should constrain ",(0,r.jsx)(n.code,{children:"increment"}),", ",(0,r.jsx)(n.code,{children:"decrement"})," by ",(0,r.jsx)(n.code,{children:"where"})," to update only specific record in the database, otherwise a column in all records will be modified."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->whereEq("id", 1).increment("votes", 5);\n'})}),"\n",(0,r.jsx)(n.h2,{id:"delete-statements",children:"Delete Statements"}),"\n",(0,r.jsxs)(n.p,{children:["The query builder's ",(0,r.jsx)(n.code,{children:"remove"}),", or an alias ",(0,r.jsx)(n.code,{children:"deleteRow"})," method may be used to delete records from the table. You may constrain ",(0,r.jsx)(n.code,{children:"delete"}),' statements by adding "where" clauses before calling the ',(0,r.jsx)(n.code,{children:"delete"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->remove();\n\nDB::table("users")->where("votes", ">", 100).remove();\n'})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"delete"})," can not be used as the method name because it is the reserved word."]})}),"\n",(0,r.jsxs)(n.p,{children:["You may also pass record ",(0,r.jsx)(n.code,{children:"id"})," to the ",(0,r.jsx)(n.code,{children:"remove"})," method as the first argument, it is the shortcut method, which internally calls ",(0,r.jsx)(n.code,{children:"where"}),":"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->remove(2);\n'})}),"\n",(0,r.jsx)(n.h3,{id:"truncate-statement",children:"Truncate Statement"}),"\n",(0,r.jsxs)(n.p,{children:["If you wish to truncate an entire table, which will remove all records from the table and reset the auto-incrementing ID to zero, you may use the ",(0,r.jsx)(n.code,{children:"truncate"})," method:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->truncate();\n'})}),"\n",(0,r.jsx)(n.h4,{id:"table-truncation--postgresql",children:"Table Truncation & PostgreSQL"}),"\n",(0,r.jsxs)(n.p,{children:["When truncating a PostgreSQL database, the ",(0,r.jsx)(n.code,{children:"CASCADE"})," behavior will be applied. This means that all foreign key related records in other tables will be deleted as well."]}),"\n",(0,r.jsx)(n.h2,{id:"pessimistic-locking",children:"Pessimistic Locking"}),"\n",(0,r.jsxs)(n.p,{children:['The query builder also includes a few functions to help you achieve "pessimistic locking" when executing your ',(0,r.jsx)(n.code,{children:"select"}),' statements. To execute a statement with a "shared lock", you may call the ',(0,r.jsx)(n.code,{children:"sharedLock"})," method. A shared lock prevents the selected rows from being modified until your transaction is committed:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->where("votes", ">", 100)\n .sharedLock()\n .get();\n'})}),"\n",(0,r.jsxs)(n.p,{children:["Alternatively, you may use the ",(0,r.jsx)(n.code,{children:"lockForUpdate"}),' method. A "for update" lock prevents the selected records from being modified or from being selected with another shared lock:']}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")\n ->where("votes", ">", 100)\n .lockForUpdate()\n .get();\n'})}),"\n",(0,r.jsx)(n.h2,{id:"debugging",children:"Debugging"}),"\n",(0,r.jsxs)(n.p,{children:["You may use the ",(0,r.jsx)(n.code,{children:"dd"})," and ",(0,r.jsx)(n.code,{children:"dump"})," methods while building a query to dump the current query bindings and SQL. The ",(0,r.jsx)(n.code,{children:"dd"})," method will display the debug information and then stop executing using the ",(0,r.jsx)(n.code,{children:"exit(1)"}),". The ",(0,r.jsx)(n.code,{children:"dump"})," method will display the debug information and continue executing:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-cpp",children:'DB::table("users")->where("votes", ">", 100).dd();\n\nDB::table("users")->where("votes", ">", 100).dump();\n'})})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>o});var r=s(6540);const t={},a=r.createContext(t);function i(e){const n=r.useContext(a);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/d459b1c4.431acd58.js b/assets/js/d459b1c4.431acd58.js deleted file mode 100644 index bf26fa6a9..000000000 --- a/assets/js/d459b1c4.431acd58.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[27],{9120:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>t,contentTitle:()=>o,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>c});var s=n(4848),r=n(8453);const l={sidebar_position:2,sidebar_label:"\ud83d\ude80 Supported Compilers",hide_table_of_contents:!0,description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",keywords:["c++ orm","supported compilers","supported build systems","tinyorm"]},o="Supported Compilers",d={id:"supported-compilers",title:"Supported Compilers",description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",source:"@site/docs/supported-compilers.mdx",sourceDirName:".",slug:"/supported-compilers",permalink:"/supported-compilers",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"\ud83d\ude80 Supported Compilers",hide_table_of_contents:!0,description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",keywords:["c++ orm","supported compilers","supported build systems","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udd27 Dependencies",permalink:"/dependencies"},next:{title:"Getting Started",permalink:"/database/getting-started"}},t={},c=[{value:"Windows >=10",id:"windows-10",level:4},{value:"Linux",id:"linux",level:4},{value:"Supported build systems",id:"supported-build-systems",level:2},{value:"Make tools",id:"make-tools",level:5},{value:"Parallel building",id:"parallel-building",level:5}];function a(e){const i={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h4:"h4",h5:"h5",li:"li",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.h1,{id:"supported-compilers",children:"Supported Compilers"}),"\n",(0,s.jsxs)(i.p,{children:["Following compilers are backed up by the GitHub Action ",(0,s.jsx)(i.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:"workflows"})," (CI pipelines), these workflows also include more then ",(0,s.jsx)(i.strong,{children:"3378 unit tests"})," \ud83d\ude2e\ud83d\udca5."]}),"\n",(0,s.jsxs)("div",{id:"supported-compilers",children:[(0,s.jsx)(i.h4,{id:"windows-10",children:(0,s.jsx)(i.code,{children:"Windows >=10"})}),(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["MSVC 2019 ",(0,s.jsx)(i.code,{children:">=16.9"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSVC 2022 ",(0,s.jsx)(i.code,{children:">=17"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSYS2 UCRT64 GCC ",(0,s.jsx)(i.code,{children:"11.2"})," - ",(0,s.jsx)(i.code,{children:"14.2"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSYS2 UCRT64 Clang ",(0,s.jsx)(i.code,{children:">=15"})]}),"\n",(0,s.jsxs)(i.li,{children:["Clang-cl ",(0,s.jsx)(i.code,{children:">=15"})," with MSVC 2019/2022"]}),"\n"]}),(0,s.jsx)(i.h4,{id:"linux",children:(0,s.jsx)(i.code,{children:"Linux"})}),(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["GCC ",(0,s.jsx)(i.code,{children:"11.2"})," - ",(0,s.jsx)(i.code,{children:"14.2"})]}),"\n",(0,s.jsxs)(i.li,{children:["Clang ",(0,s.jsx)(i.code,{children:">=15"})," ",(0,s.jsx)("small",{className:"darker",children:"(libstdc++ only)"})]}),"\n"]})]}),"\n",(0,s.jsx)(i.admonition,{type:"tip",children:(0,s.jsx)(i.p,{children:"You can compile TinyORM with the MSVC 2022 even if Qt doesn't provide binaries for the MSVC 2022, you can link against Qt MSVC 2019 binaries without any limitations."})}),"\n",(0,s.jsx)(i.admonition,{type:"info",children:(0,s.jsxs)(i.p,{children:["Qt finally provides ",(0,s.jsx)(i.strong,{children:"MSVC 2022"})," binaries from ",(0,s.jsx)(i.strong,{children:"Qt v6.8"})," (after 2.5 years \ud83e\udd14), what are good news. There will be no MSVC 2019 binaries from Qt v6.8. Everything will work normally and ",(0,s.jsx)(i.strong,{children:"no explicit actions"})," are needed."]})}),"\n",(0,s.jsx)(i.admonition,{type:"warning",children:(0,s.jsxs)(i.p,{children:["The ",(0,s.jsx)(i.code,{children:"macOS"})," and Clang with ",(0,s.jsx)(i.code,{children:"libc++"})," are not supported."]})}),"\n",(0,s.jsx)(i.h2,{id:"supported-build-systems",children:"Supported build systems"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"CMake"})," ",(0,s.jsx)(i.code,{children:">=3.22"})," ",(0,s.jsx)("small",{className:"darker",children:"(policies <= CMP0128 default to NEW)"})]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"qmake"})," distributed by the Qt Framework"]}),"\n"]}),"\n",(0,s.jsx)(i.h5,{id:"make-tools",children:"Make tools"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"jom"})," - highly recommended with the ",(0,s.jsx)(i.code,{children:"qmake"})," build system on Windows ",(0,s.jsx)("small",{className:"darker",children:"(replacement for nmake)"})]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"ninja"})," - recommended for ",(0,s.jsx)(i.code,{children:"CMake"})," as the make file generator"]}),"\n"]}),"\n",(0,s.jsx)(i.h5,{id:"parallel-building",children:"Parallel building"}),"\n",(0,s.jsx)(i.p,{children:"You can control parallel building using the following environment variables."}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["CMake - ",(0,s.jsx)(i.code,{children:"CMAKE_BUILD_PARALLEL_LEVEL"})," eg. to ",(0,s.jsx)(i.code,{children:"10"})]}),"\n",(0,s.jsxs)(i.li,{children:["jom - ",(0,s.jsx)(i.code,{children:"JOMFLAGS"})," eg. to ",(0,s.jsx)(i.code,{children:"j11"})]}),"\n",(0,s.jsxs)(i.li,{children:["make - ",(0,s.jsx)(i.code,{children:"MAKEFLAGS"})," eg. to ",(0,s.jsx)(i.code,{children:"-j10"})]}),"\n",(0,s.jsxs)(i.li,{children:["vcpkg - ",(0,s.jsx)(i.code,{children:"VCPKG_MAX_CONCURRENCY"})," eg. to ",(0,s.jsx)(i.code,{children:"10"})]}),"\n"]})]})}function h(e={}){const{wrapper:i}={...(0,r.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},8453:(e,i,n)=>{n.d(i,{R:()=>o,x:()=>d});var s=n(6540);const r={},l=s.createContext(r);function o(e){const i=s.useContext(l);return s.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function d(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(l.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/d459b1c4.ce3bf5fd.js b/assets/js/d459b1c4.ce3bf5fd.js new file mode 100644 index 000000000..a57f89e9b --- /dev/null +++ b/assets/js/d459b1c4.ce3bf5fd.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[27],{9120:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>t,contentTitle:()=>d,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>c});var s=n(4848),r=n(8453);const l={sidebar_position:2,sidebar_label:"\ud83d\ude80 Supported Compilers",hide_table_of_contents:!0,description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",keywords:["c++ orm","supported compilers","supported build systems","tinyorm"]},d="Supported Compilers",o={id:"supported-compilers",title:"Supported Compilers",description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",source:"@site/docs/supported-compilers.mdx",sourceDirName:".",slug:"/supported-compilers",permalink:"/supported-compilers",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"\ud83d\ude80 Supported Compilers",hide_table_of_contents:!0,description:"Platform requirements, supported compilers and build systems for TinyORM C++ library.",keywords:["c++ orm","supported compilers","supported build systems","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udd27 Dependencies",permalink:"/dependencies"},next:{title:"Getting Started",permalink:"/database/getting-started"}},t={},c=[{value:"Windows >=10",id:"windows-10",level:4},{value:"Linux",id:"linux",level:4},{value:"Supported build systems",id:"supported-build-systems",level:2},{value:"Make tools",id:"make-tools",level:5},{value:"Parallel building",id:"parallel-building",level:5}];function a(e){const i={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h4:"h4",h5:"h5",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.header,{children:(0,s.jsx)(i.h1,{id:"supported-compilers",children:"Supported Compilers"})}),"\n",(0,s.jsxs)(i.p,{children:["Following compilers are backed up by the GitHub Action ",(0,s.jsx)(i.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:"workflows"})," (CI pipelines), these workflows also include more then ",(0,s.jsx)(i.strong,{children:"3378 unit tests"})," \ud83d\ude2e\ud83d\udca5."]}),"\n",(0,s.jsxs)("div",{id:"supported-compilers",children:[(0,s.jsx)(i.h4,{id:"windows-10",children:(0,s.jsx)(i.code,{children:"Windows >=10"})}),(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["MSVC 2019 ",(0,s.jsx)(i.code,{children:">=16.9"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSVC 2022 ",(0,s.jsx)(i.code,{children:">=17"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSYS2 UCRT64 GCC ",(0,s.jsx)(i.code,{children:"11.2"})," - ",(0,s.jsx)(i.code,{children:"14.2"})]}),"\n",(0,s.jsxs)(i.li,{children:["MSYS2 UCRT64 Clang ",(0,s.jsx)(i.code,{children:">=15"})]}),"\n",(0,s.jsxs)(i.li,{children:["Clang-cl ",(0,s.jsx)(i.code,{children:">=15"})," with MSVC 2019/2022"]}),"\n"]}),(0,s.jsx)(i.h4,{id:"linux",children:(0,s.jsx)(i.code,{children:"Linux"})}),(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["GCC ",(0,s.jsx)(i.code,{children:"11.2"})," - ",(0,s.jsx)(i.code,{children:"14.2"})]}),"\n",(0,s.jsxs)(i.li,{children:["Clang ",(0,s.jsx)(i.code,{children:">=15"})," ",(0,s.jsx)("small",{className:"darker",children:"(libstdc++ only)"})]}),"\n"]})]}),"\n",(0,s.jsx)(i.admonition,{type:"tip",children:(0,s.jsx)(i.p,{children:"You can compile TinyORM with the MSVC 2022 even if Qt doesn't provide binaries for the MSVC 2022, you can link against Qt MSVC 2019 binaries without any limitations."})}),"\n",(0,s.jsx)(i.admonition,{type:"info",children:(0,s.jsxs)(i.p,{children:["Qt finally provides ",(0,s.jsx)(i.strong,{children:"MSVC 2022"})," binaries from ",(0,s.jsx)(i.strong,{children:"Qt v6.8"})," (after 2.5 years \ud83e\udd14), what are good news. There will be no MSVC 2019 binaries from Qt v6.8. Everything will work normally and ",(0,s.jsx)(i.strong,{children:"no explicit actions"})," are needed."]})}),"\n",(0,s.jsx)(i.admonition,{type:"warning",children:(0,s.jsxs)(i.p,{children:["The ",(0,s.jsx)(i.code,{children:"macOS"})," and Clang with ",(0,s.jsx)(i.code,{children:"libc++"})," are not supported."]})}),"\n",(0,s.jsx)(i.h2,{id:"supported-build-systems",children:"Supported build systems"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"CMake"})," ",(0,s.jsx)(i.code,{children:">=3.22"})," ",(0,s.jsx)("small",{className:"darker",children:"(policies <= CMP0128 default to NEW)"})]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"qmake"})," distributed by the Qt Framework"]}),"\n"]}),"\n",(0,s.jsx)(i.h5,{id:"make-tools",children:"Make tools"}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"jom"})," - highly recommended with the ",(0,s.jsx)(i.code,{children:"qmake"})," build system on Windows ",(0,s.jsx)("small",{className:"darker",children:"(replacement for nmake)"})]}),"\n",(0,s.jsxs)(i.li,{children:[(0,s.jsx)(i.code,{children:"ninja"})," - recommended for ",(0,s.jsx)(i.code,{children:"CMake"})," as the make file generator"]}),"\n"]}),"\n",(0,s.jsx)(i.h5,{id:"parallel-building",children:"Parallel building"}),"\n",(0,s.jsx)(i.p,{children:"You can control parallel building using the following environment variables."}),"\n",(0,s.jsxs)(i.ul,{children:["\n",(0,s.jsxs)(i.li,{children:["CMake - ",(0,s.jsx)(i.code,{children:"CMAKE_BUILD_PARALLEL_LEVEL"})," eg. to ",(0,s.jsx)(i.code,{children:"10"})]}),"\n",(0,s.jsxs)(i.li,{children:["jom - ",(0,s.jsx)(i.code,{children:"JOMFLAGS"})," eg. to ",(0,s.jsx)(i.code,{children:"j11"})]}),"\n",(0,s.jsxs)(i.li,{children:["make - ",(0,s.jsx)(i.code,{children:"MAKEFLAGS"})," eg. to ",(0,s.jsx)(i.code,{children:"-j10"})]}),"\n",(0,s.jsxs)(i.li,{children:["vcpkg - ",(0,s.jsx)(i.code,{children:"VCPKG_MAX_CONCURRENCY"})," eg. to ",(0,s.jsx)(i.code,{children:"10"})]}),"\n"]})]})}function h(e={}){const{wrapper:i}={...(0,r.R)(),...e.components};return i?(0,s.jsx)(i,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},8453:(e,i,n)=>{n.d(i,{R:()=>d,x:()=>o});var s=n(6540);const r={},l=s.createContext(r);function d(e){const i=s.useContext(l);return s.useMemo((function(){return"function"==typeof e?e(i):{...i,...e}}),[i,e])}function o(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:d(e.components),s.createElement(l.Provider,{value:i},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e19c288b.a42b5d93.js b/assets/js/e19c288b.a42b5d93.js new file mode 100644 index 000000000..8b6086c9c --- /dev/null +++ b/assets/js/e19c288b.a42b5d93.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[69],{9158:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>d,toc:()=>l});var t=r(4848),o=r(8453),s=r(6684);const a={sidebar_position:9,sidebar_label:"\u2764\ufe0f Sponsors",hide_table_of_contents:!0,description:"How to sponsor and support the TinyORM project.",keywords:["c++ orm","tinyorm","support","fund","funding","sponsors","donations","sponsors"]},i="Sponsors",d={id:"sponsors",title:"Sponsors",description:"How to sponsor and support the TinyORM project.",source:"@site/docs/sponsors.mdx",sourceDirName:".",slug:"/sponsors",permalink:"/sponsors",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:9,frontMatter:{sidebar_position:9,sidebar_label:"\u2764\ufe0f Sponsors",hide_table_of_contents:!0,description:"How to sponsor and support the TinyORM project.",keywords:["c++ orm","tinyorm","support","fund","funding","sponsors","donations","sponsors"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udcc4 Features Summary",permalink:"/features-summary"}},c={},l=[];function p(e){const n={a:"a",h1:"h1",header:"header",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"sponsors",children:"Sponsors"})}),"\n",(0,t.jsx)(n.p,{children:"I have spent ~2 years every day 10 hours of coding (excluding weekends and sick days) to make this project real. Everything was funded from my personal resources, I had no problem with it to be honest, it was really fun \ud83c\udf89, but I had to move to the new apartment a few months ago and I'm out of money now. \u2639\ufe0f"}),"\n",(0,t.jsx)(n.p,{children:"I would like to continue developing and enhancing this project and I will as long as I can. But the future is unclear now."}),"\n",(0,t.jsx)("div",{id:"apitable-sponsors",children:(0,t.jsx)(s.A,{children:(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Service"}),(0,t.jsx)(n.th,{children:"Address"})]})}),(0,t.jsxs)(n.tbody,{children:[(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:"Bitcoin address"}),(0,t.jsx)(n.td,{children:"1NiF2cTvYxUj8FTZJnGn1ycN4yisWfo1vJ"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:"PayPal"}),(0,t.jsx)(n.td,{children:(0,t.jsx)(n.a,{href:"https://paypal.me/silverzachara",children:"https://paypal.me/silverzachara"})})]})]})]})})})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(p,{...e})}):p(e)}},6684:(e,n,r)=>{r.d(n,{A:()=>l});var t=r(6540),o=r(3427),s=r(6347);const a={apiTable:"apiTable_flxF"};var i=r(4848);function d(e,n){let{name:r,children:a}=e;const d=function(e){let n=e;for(;(0,t.isValidElement)(n);)[n]=t.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(a),c=r?`${r}-${d}`:d,l=`#${c}`,p=(0,s.W6)();return(0,o.A)().collectAnchor(c),(0,i.jsx)("tr",{id:c,tabIndex:0,ref:p.location.hash===l?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||p.push(l)},onKeyDown:e=>{"Enter"===e.key&&p.push(l)},children:a.props.children})}const c=t.forwardRef(d);function l(e){let{children:n,name:r}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[o,s]=t.Children.toArray(n.props.children),d=(0,t.useRef)(null);(0,t.useEffect)((()=>{d.current?.focus()}),[d]);const l=t.Children.map(s.props.children,(e=>(0,i.jsx)(c,{name:r,ref:d,children:e})));return(0,i.jsxs)("table",{className:a.apiTable,children:[o,(0,i.jsx)("tbody",{children:l})]})}},8453:(e,n,r)=>{r.d(n,{R:()=>a,x:()=>i});var t=r(6540);const o={},s=t.createContext(o);function a(e){const n=t.useContext(s);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e19c288b.d0c41dce.js b/assets/js/e19c288b.d0c41dce.js deleted file mode 100644 index 74efaa348..000000000 --- a/assets/js/e19c288b.d0c41dce.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[69],{9158:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>d,toc:()=>l});var o=t(4848),r=t(8453),s=t(6684);const a={sidebar_position:9,sidebar_label:"\u2764\ufe0f Sponsors",hide_table_of_contents:!0,description:"How to sponsor and support the TinyORM project.",keywords:["c++ orm","tinyorm","support","fund","funding","sponsors","donations","sponsors"]},i="Sponsors",d={id:"sponsors",title:"Sponsors",description:"How to sponsor and support the TinyORM project.",source:"@site/docs/sponsors.mdx",sourceDirName:".",slug:"/sponsors",permalink:"/sponsors",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:9,frontMatter:{sidebar_position:9,sidebar_label:"\u2764\ufe0f Sponsors",hide_table_of_contents:!0,description:"How to sponsor and support the TinyORM project.",keywords:["c++ orm","tinyorm","support","fund","funding","sponsors","donations","sponsors"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udcc4 Features Summary",permalink:"/features-summary"}},c={},l=[];function p(e){const n={a:"a",h1:"h1",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h1,{id:"sponsors",children:"Sponsors"}),"\n",(0,o.jsx)(n.p,{children:"I have spent ~2 years every day 10 hours of coding (excluding weekends and sick days) to make this project real. Everything was funded from my personal resources, I had no problem with it to be honest, it was really fun \ud83c\udf89, but I had to move to the new apartment a few months ago and I'm out of money now. \u2639\ufe0f"}),"\n",(0,o.jsx)(n.p,{children:"I would like to continue developing and enhancing this project and I will as long as I can. But the future is unclear now."}),"\n",(0,o.jsx)("div",{id:"apitable-sponsors",children:(0,o.jsx)(s.A,{children:(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Service"}),(0,o.jsx)(n.th,{children:"Address"})]})}),(0,o.jsxs)(n.tbody,{children:[(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:"Bitcoin address"}),(0,o.jsx)(n.td,{children:"1NiF2cTvYxUj8FTZJnGn1ycN4yisWfo1vJ"})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:"PayPal"}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.a,{href:"https://paypal.me/silverzachara",children:"https://paypal.me/silverzachara"})})]})]})]})})})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}},6684:(e,n,t)=>{t.d(n,{A:()=>l});var o=t(6540),r=t(3427),s=t(6347);const a={apiTable:"apiTable_flxF"};var i=t(4848);function d(e,n){let{name:t,children:a}=e;const d=function(e){let n=e;for(;(0,o.isValidElement)(n);)[n]=o.Children.toArray(n.props.children);if("string"!=typeof n)throw new Error(`Could not extract APITable row name from JSX tree:\n${JSON.stringify(e,null,2)}`);return n}(a),c=t?`${t}-${d}`:d,l=`#${c}`,p=(0,s.W6)();return(0,r.A)().collectAnchor(c),(0,i.jsx)("tr",{id:c,tabIndex:0,ref:p.location.hash===l?n:void 0,onClick:e=>{const n=e.target;[n,n.parentElement].some((e=>"A"===e?.tagName.toUpperCase()))||p.push(l)},onKeyDown:e=>{"Enter"===e.key&&p.push(l)},children:a.props.children})}const c=o.forwardRef(d);function l(e){let{children:n,name:t}=e;if("table"!==n.type)throw new Error("Bad usage of APITable component.\nIt is probably that your Markdown table is malformed.\nMake sure to double-check you have the appropriate number of columns for each table row.");const[r,s]=o.Children.toArray(n.props.children),d=(0,o.useRef)(null);(0,o.useEffect)((()=>{d.current?.focus()}),[d]);const l=o.Children.map(s.props.children,(e=>(0,i.jsx)(c,{name:t,ref:d,children:e})));return(0,i.jsxs)("table",{className:a.apiTable,children:[r,(0,i.jsx)("tbody",{children:l})]})}},8453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>i});var o=t(6540);const r={},s=o.createContext(r);function a(e){const n=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),o.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e3ac21cb.5bbce64e.js b/assets/js/e3ac21cb.5bbce64e.js deleted file mode 100644 index 46b430d05..000000000 --- a/assets/js/e3ac21cb.5bbce64e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[467],{348:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>p,frontMatter:()=>d,metadata:()=>o,toc:()=>c});var r=t(4848),i=t(8453),s=t(8774);const d={sidebar_position:1,sidebar_label:"\ud83d\udd27 Dependencies",hide_table_of_contents:!0,description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",keywords:["c++ orm","dependencies","tinyorm"]},a="Dependencies",o={id:"dependencies",title:"Dependencies",description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",source:"@site/docs/dependencies.mdx",sourceDirName:".",slug:"/dependencies",permalink:"/dependencies",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"\ud83d\udd27 Dependencies",hide_table_of_contents:!0,description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",keywords:["c++ orm","dependencies","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udd25 Prologue",permalink:"/"},next:{title:"\ud83d\ude80 Supported Compilers",permalink:"/supported-compilers"}},l={},c=[{value:"Required",id:"required",level:5},{value:"Optional",id:"optional",level:5},{value:"Install dependencies",id:"install-dependencies",level:3}];function h(e){const n={a:"a",admonition:"admonition",code:"code",del:"del",h1:"h1",h3:"h3",h5:"h5",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"dependencies",children:"Dependencies"}),"\n",(0,r.jsxs)(n.p,{children:["The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18, so may be assumed it will work on future releases of these compilers. Minimum required ISO C++ standard is C++20.\nThe Qt framework version used during development was ",(0,r.jsx)(n.del,{children:"5.15.2"})," and >=6.2."]}),"\n",(0,r.jsx)(n.h5,{id:"required",children:"Required"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"minimum ISO C++ standard is C++20"}),"\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://www.qt.io/download-qt-installer",children:"Qt Framework 6.2"})," - ",(0,r.jsx)(n.a,{href:"https://doc.qt.io/qt-6/qtcore-module.html",children:(0,r.jsx)(n.code,{children:"QtCore"})})," and ",(0,r.jsx)(n.a,{href:"https://doc.qt.io/qt-6/qtsql-index.html",children:(0,r.jsx)(n.code,{children:"QtSql"})})," modules"]}),"\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://github.com/ericniebler/range-v3",children:"range-v3 0.11.0"})]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/p-ranav/tabulate",children:"tabulate"})}),"\n"]}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:["Support for ",(0,r.jsx)(n.strong,{children:"Qt v5.15"})," was removed since ",(0,r.jsx)(n.strong,{children:"TinyORM v0.38.0"}),". \ud83c\udf89\ud83d\ude4c"]})}),"\n",(0,r.jsx)(n.admonition,{type:"warning",children:(0,r.jsxs)(n.p,{children:["Be aware that the standard support for the last release of the ",(0,r.jsx)(n.strong,{children:"Qt v5"})," series ended on ",(0,r.jsx)(n.strong,{children:"26. May 2023"}),". [",(0,r.jsx)(n.a,{href:"https://endoflife.date/qt",children:"1"}),"][",(0,r.jsx)(n.a,{href:"https://www.qt.io/blog/qt-5.15-support-ends",children:"2"}),"]"]})}),"\n",(0,r.jsx)(n.h5,{id:"optional",children:"Optional"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/downloads/c-api/",children:"MySQL Connector/C 8"})," - used only for the ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-ping.html",children:(0,r.jsx)(n.code,{children:"mysql_ping"})})," function and provided by ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/downloads/mysql/",children:"MySQL 8 Server"})]}),"\n"]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"TinyORM"})," will support ",(0,r.jsx)(n.code,{children:"Qt"})," versions that aren't ",(0,r.jsx)(n.a,{href:"https://endoflife.date/qt",children:"end-of-life"}),"."]})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["You can view the supported database servers in the ",(0,r.jsx)(n.a,{href:"/database/getting-started#introduction",children:"Database - Getting Started"})," section."]})}),"\n",(0,r.jsx)(n.h3,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,r.jsxs)(n.p,{children:["On ",(0,r.jsx)(n.code,{children:"Linux"}),", you can install dependencies with the package manager."]}),"\n",(0,r.jsxs)("small",{children:[(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='MySQL C library'",children:"Arch - pacman -S mariadb-libs\nGentoo - emerge dev-db/mysql (package.use: -server -perl)\nUbuntu - apt install libmysqlclient-dev\n"})}),(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='range-v3 library (header only)'",children:"Arch - pacman -S range-v3\nGentoo - emerge dev-cpp/range-v3\nUbuntu - apt install librange-v3-dev\n"})}),(0,r.jsx)(s.A,{id:"linux-installation-ccache"}),(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='ccache'",children:"Arch - pacman -S ccache\nGentoo - emerge dev-util/ccache\nUbuntu - apt install ccache\n"})})]})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>d,x:()=>a});var r=t(6540);const i={},s=r.createContext(i);function d(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e3ac21cb.ba171561.js b/assets/js/e3ac21cb.ba171561.js new file mode 100644 index 000000000..1bf046f91 --- /dev/null +++ b/assets/js/e3ac21cb.ba171561.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[467],{348:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>p,frontMatter:()=>d,metadata:()=>o,toc:()=>c});var r=t(4848),i=t(8453),s=t(8774);const d={sidebar_position:1,sidebar_label:"\ud83d\udd27 Dependencies",hide_table_of_contents:!0,description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",keywords:["c++ orm","dependencies","tinyorm"]},a="Dependencies",o={id:"dependencies",title:"Dependencies",description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",source:"@site/docs/dependencies.mdx",sourceDirName:".",slug:"/dependencies",permalink:"/dependencies",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"\ud83d\udd27 Dependencies",hide_table_of_contents:!0,description:"Library dependencies are MySQL Connector/C 8, range-v3 >=0.11.0, tabulate and the Qt framework version used during development was 5.15.2 and >=6.2. The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18.",keywords:["c++ orm","dependencies","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udd25 Prologue",permalink:"/"},next:{title:"\ud83d\ude80 Supported Compilers",permalink:"/supported-compilers"}},l={},c=[{value:"Required",id:"required",level:5},{value:"Optional",id:"optional",level:5},{value:"Install dependencies",id:"install-dependencies",level:3}];function h(e){const n={a:"a",admonition:"admonition",code:"code",del:"del",h1:"h1",h3:"h3",h5:"h5",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"dependencies",children:"Dependencies"})}),"\n",(0,r.jsxs)(n.p,{children:["The code was developed on MSVC 16.9-16.11, MSVC 17.2-17.9, GCC 11.2-14.2, and Clang 11-18, so may be assumed it will work on future releases of these compilers. Minimum required ISO C++ standard is C++20.\nThe Qt framework version used during development was ",(0,r.jsx)(n.del,{children:"5.15.2"})," and >=6.2."]}),"\n",(0,r.jsx)(n.h5,{id:"required",children:"Required"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"minimum ISO C++ standard is C++20"}),"\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://www.qt.io/download-qt-installer",children:"Qt Framework 6.2"})," - ",(0,r.jsx)(n.a,{href:"https://doc.qt.io/qt-6/qtcore-module.html",children:(0,r.jsx)(n.code,{children:"QtCore"})})," and ",(0,r.jsx)(n.a,{href:"https://doc.qt.io/qt-6/qtsql-index.html",children:(0,r.jsx)(n.code,{children:"QtSql"})})," modules"]}),"\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://github.com/ericniebler/range-v3",children:"range-v3 0.11.0"})]}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/p-ranav/tabulate",children:"tabulate"})}),"\n"]}),"\n",(0,r.jsx)(n.admonition,{type:"danger",children:(0,r.jsxs)(n.p,{children:["Support for ",(0,r.jsx)(n.strong,{children:"Qt v5.15"})," was removed since ",(0,r.jsx)(n.strong,{children:"TinyORM v0.38.0"}),". \ud83c\udf89\ud83d\ude4c"]})}),"\n",(0,r.jsx)(n.admonition,{type:"warning",children:(0,r.jsxs)(n.p,{children:["Be aware that the standard support for the last release of the ",(0,r.jsx)(n.strong,{children:"Qt v5"})," series ended on ",(0,r.jsx)(n.strong,{children:"26. May 2023"}),". [",(0,r.jsx)(n.a,{href:"https://endoflife.date/qt",children:"1"}),"][",(0,r.jsx)(n.a,{href:"https://www.qt.io/blog/qt-5.15-support-ends",children:"2"}),"]"]})}),"\n",(0,r.jsx)(n.h5,{id:"optional",children:"Optional"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[">= ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/downloads/c-api/",children:"MySQL Connector/C 8"})," - used only for the ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/doc/c-api/9.0/en/mysql-ping.html",children:(0,r.jsx)(n.code,{children:"mysql_ping"})})," function and provided by ",(0,r.jsx)(n.a,{href:"https://dev.mysql.com/downloads/mysql/",children:"MySQL 8 Server"})]}),"\n"]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"TinyORM"})," will support ",(0,r.jsx)(n.code,{children:"Qt"})," versions that aren't ",(0,r.jsx)(n.a,{href:"https://endoflife.date/qt",children:"end-of-life"}),"."]})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["You can view the supported database servers in the ",(0,r.jsx)(n.a,{href:"/database/getting-started#introduction",children:"Database - Getting Started"})," section."]})}),"\n",(0,r.jsx)(n.h3,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,r.jsxs)(n.p,{children:["On ",(0,r.jsx)(n.code,{children:"Linux"}),", you can install dependencies with the package manager."]}),"\n",(0,r.jsxs)("small",{children:[(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='MySQL C library'",children:"Arch - pacman -S mariadb-libs\nGentoo - emerge dev-db/mysql (package.use: -server -perl)\nUbuntu - apt install libmysqlclient-dev\n"})}),(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='range-v3 library (header only)'",children:"Arch - pacman -S range-v3\nGentoo - emerge dev-cpp/range-v3\nUbuntu - apt install librange-v3-dev\n"})}),(0,r.jsx)(s.A,{id:"linux-installation-ccache"}),(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",metastring:"title='ccache'",children:"Arch - pacman -S ccache\nGentoo - emerge dev-util/ccache\nUbuntu - apt install ccache\n"})})]})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>d,x:()=>a});var r=t(6540);const i={},s=r.createContext(i);function d(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/fb313d4e.2fcd3c4b.js b/assets/js/fb313d4e.2fcd3c4b.js deleted file mode 100644 index 07f6c9c21..000000000 --- a/assets/js/fb313d4e.2fcd3c4b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[871],{8489:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>d});var t=s(4848),i=s(8453);const r={sidebar_position:8,sidebar_label:"\ud83d\udcc4 Features Summary",hide_table_of_contents:!0,description:"List that fastly summarizes all TinyORM features.",keywords:["c++ orm","tinyorm","features","summary","features summary"]},a="Features Summary",l={id:"features-summary",title:"Features Summary",description:"List that fastly summarizes all TinyORM features.",source:"@site/docs/features-summary.mdx",sourceDirName:".",slug:"/features-summary",permalink:"/features-summary",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:8,frontMatter:{sidebar_position:8,sidebar_label:"\ud83d\udcc4 Features Summary",hide_table_of_contents:!0,description:"List that fastly summarizes all TinyORM features.",keywords:["c++ orm","tinyorm","features","summary","features summary"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udea9 Stability",permalink:"/stability"},next:{title:"\u2764\ufe0f Sponsors",permalink:"/sponsors"}},o={},d=[{value:"Summary List",id:"summary-list",level:2},{value:"Showcase Images",id:"showcase-images",level:2},{value:"Tom console application",id:"tom-console-application",level:6},{value:"Passed all unit tests \ud83e\udd73",id:"passed-all-unit-tests-",level:6},{value:"TinyOrmPlayground",id:"tinyormplayground",level:4},{value:"TinyOrmPlayground single-threaded",id:"tinyormplayground-single-threaded",level:6},{value:"TinyOrmPlayground multi-threaded",id:"tinyormplayground-multi-threaded",level:6}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h4:"h4",h6:"h6",li:"li",p:"p",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"features-summary",children:"Features Summary"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#summary-list",children:"Summary List"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#showcase-images",children:"Showcase Images"})}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"summary-list",children:"Summary List"}),"\n",(0,t.jsxs)(n.p,{children:["The following list fastly summarizes all the ",(0,t.jsx)(n.code,{children:"TinyORM"})," features."]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"simple database connections management"})," \ud83e\uddec","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"database manager that helps with the database connections management"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"Orm::DB"})," facade class for nicer and shorter syntax"]}),"\n",(0,t.jsxs)(n.li,{children:["MySQL, MariaDB, SQLite, and PostgreSQL support for ",(0,t.jsx)(n.strong,{children:"all"})," features \ud83d\udc8e"]}),"\n",(0,t.jsx)(n.li,{children:"multi-threading support \ud83d\udc40"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"SSL"})," connections support \ud83d\udd12"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"impressive query builder"})," \ud83d\udd27","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"allows passing sub-queries and raw expressions practically everywhere, to column names, values, and to every SQL clause as select, where, joins, group by, having, order by \ud83d\udd25"}),"\n",(0,t.jsx)(n.li,{children:"a logical grouping that offers to wrap logical groups in parenthesis"}),"\n",(0,t.jsx)(n.li,{children:"chunked results for lower memory footprint \u2728"}),"\n",(0,t.jsx)(n.li,{children:"raw methods for all SQL clauses"}),"\n",(0,t.jsx)(n.li,{children:"all join types (left, right, cross, inner) and also join where clause support \ud83e\udee4"}),"\n",(0,t.jsx)(n.li,{children:"aggregate methods min, max, sum, increment, decrement, ..."}),"\n",(0,t.jsx)(n.li,{children:"whereExists and exists methods for an existence queries"}),"\n",(0,t.jsx)(n.li,{children:"transactions and pessimistic locking \ud83d\udd12"}),"\n",(0,t.jsx)(n.li,{children:"of course, insert, update, and delete SQL clauses support"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"correct QDateTime time zone"})," using the ",(0,t.jsx)(n.code,{children:"qt_timezone"})," connection configuration option \ud83d\udcc5 (returned QDateTime instances will have the correct time zone, and also works for an ORM)","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"this feature allows you to set up the database server time zone to the UTC and all returned QDateTime instances will have the correct UTC time zone"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"clever ORM with all relation types support"})," \ud83c\udf89","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"one-to-one, one-to-many, and many-to-many relation types (also inverse relationships) \ud83e\udde8"}),"\n",(0,t.jsx)(n.li,{children:"eager and lazy loading with custom select and constraints \ud83d\ude80"}),"\n",(0,t.jsxs)(n.li,{children:["fluent ",(0,t.jsx)(n.code,{children:"ModelsCollection"})," that expose a variety of map / reduce operations that may be chained using an intuitive interface \u2728"]}),"\n",(0,t.jsx)(n.li,{children:"all query builder methods are proxied from the model instances and also from the relation instances back to the query builder \ud83e\udd2f (everything that can be called on the query builder can also be called on the model and relation instances)"}),"\n",(0,t.jsx)(n.li,{children:"clean active record pattern"}),"\n",(0,t.jsxs)(n.li,{children:["advanced features like timestamps, touching parent timestamps, ",(0,t.jsx)(n.strong,{children:"soft deleting"}),", default models, default model attributes, and attribute casting \ud83e\udd13"]}),"\n",(0,t.jsxs)(n.li,{children:["querying relationships existence/absence using the has, whereHas, and hasNested methods (using dot notation for selecting nested relationships ",(0,t.jsx)(n.em,{children:"users.posts.comments"}),")"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"serializing"})," models and collection of models including all nested relations to ",(0,t.jsx)(n.strong,{children:"JSON"})," and converting to vectors and maps \ud83e\udea1","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"supports controlling a custom date format during serialization"}),"\n",(0,t.jsx)(n.li,{children:"supports hiding and appending attributes"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"compiled database migrations and seeders"})," \ud83d\udd7a","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"create, update, drop, and rename database tables"}),"\n",(0,t.jsx)(n.li,{children:"create, drop, and rename table columns"}),"\n",(0,t.jsx)(n.li,{children:"extensive schema builder that allows creating of all possible column types"}),"\n",(0,t.jsx)(n.li,{children:"terser syntax for creating foreign keys and foreign key constraints"}),"\n",(0,t.jsx)(n.li,{children:"supports creating, and dropping column indexes (primary, unique, fulltext, spatial)"}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsxs)(n.strong,{children:["the ",(0,t.jsx)(n.code,{children:"tom"})," console application with tab completion for all shells (pwsh, bash, zsh)"]})," \ud83e\udd73","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"scaffolding of models, migrations, and seeders"}),"\n",(0,t.jsxs)(n.li,{children:["impressive models scaffolding, every feature that is supported by models can be generated using the ",(0,t.jsx)(n.code,{children:"tom make:model"})," cli command"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["a huge amount of code is unit tested, currently ",(0,t.jsx)(n.strong,{children:"3378 unit tests"})," \ud83e\udd2f"]}),"\n",(0,t.jsxs)(n.li,{children:["C++20 only, with all the latest features used like concepts/constraints, ranges, smart pointers (no ",(0,t.jsx)(n.code,{children:"new"})," keyword in the whole code \ud83d\ude0e), folding expressions"]}),"\n",(0,t.jsxs)(n.li,{children:["qmake and CMake build systems support","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"CMake FetchContent module support \ud83e\udd19"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:"vcpkg support (also the vcpkg port, currently not committed to the vcpkg repository \u2639\ufe0f)"}),"\n",(0,t.jsx)(n.li,{children:"it's really fast, you can run 1000 complex queries in 500ms (heavily DB dependant, the PostgreSQL is by far the fastest) \u231a"}),"\n",(0,t.jsx)(n.li,{children:"extensive documentation \ud83d\udcc3"}),"\n",(0,t.jsx)(n.li,{children:"..."}),"\n"]}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["See the ",(0,t.jsx)(n.code,{children:"TinyDrivers"})," ",(0,t.jsx)(n.a,{href:"tinydrivers/getting-started#features-summary",children:"Features summary"}),"."]})}),"\n",(0,t.jsx)(n.h2,{id:"showcase-images",children:"Showcase Images"}),"\n",(0,t.jsx)(n.h6,{id:"tom-console-application",children:"Tom console application"}),"\n",(0,t.jsx)("img",{src:s(5848).A,alt:"TinyORM - Tom console application - Showcase",title:"Tom console application"}),"\n",(0,t.jsx)(n.h6,{id:"passed-all-unit-tests-",children:"Passed all unit tests \ud83e\udd73"}),"\n",(0,t.jsx)("img",{src:s(8994).A,alt:"TinyORM - Passed all unit tests - Showcase",title:"Passed all unit tests",width:"700",className:"no-blurry"}),"\n",(0,t.jsx)(n.h4,{id:"tinyormplayground",children:"TinyOrmPlayground"}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.a,{href:"https://github.com/silverqx/TinyOrmPlayground",children:"TinyOrmPlayground"})," project is my personal project where I have tested all the TinyORM database queries in the early development phases, currently, it executes ~1600 database queries across the whole TinyORM framework. Every query has a nice title header, is logged to the console, and is counted and measured (elapsed time). Every query also runs on all ",(0,t.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["The TinyOrmPlayground project can be compiled in a single-threaded or multi-threaded mode. In the multi-threaded mode, every database connection runs in its own thread. At the end of every database connection is logged a connection summary and before an exit is logged the application summary. Whole TinyOrmPlayground application is configurable through the ",(0,t.jsx)(n.a,{href:"https://github.com/silverqx/TinyOrmPlayground/blob/main/src/configuration.hpp",children:"src/configuration.hpp"})," class."]}),"\n",(0,t.jsx)(n.h6,{id:"tinyormplayground-single-threaded",children:"TinyOrmPlayground single-threaded"}),"\n",(0,t.jsx)("img",{src:s(3672).A,alt:"TinyORM - Invoked TinyOrmPlayground single-threaded - Showcase",title:"Invoked TinyOrmPlayground single-threaded"}),"\n",(0,t.jsx)(n.h6,{id:"tinyormplayground-multi-threaded",children:"TinyOrmPlayground multi-threaded"}),"\n",(0,t.jsx)("img",{src:s(2599).A,alt:"TinyORM - Invoked TinyOrmPlayground multi-threaded - Showcase",title:"Invoked TinyOrmPlayground multi-threaded"})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},8994:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyorm-passed_all_unit_tests-d730d995b6b490fb42c3671738e3b81e.png"},2599:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyormplayground-multi-threaded-edb67030c75e2845e1fa7013e510174c.png"},3672:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyormplayground-single-threaded-4e7a5769ad5a768a4d04c6dc856c4391.png"},5848:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tom_cli-402f7dd4dfe7dbd0b20dfe5fb61838a2.png"},8453:(e,n,s)=>{s.d(n,{R:()=>a,x:()=>l});var t=s(6540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/fb313d4e.d61d160a.js b/assets/js/fb313d4e.d61d160a.js new file mode 100644 index 000000000..c7940ca5e --- /dev/null +++ b/assets/js/fb313d4e.d61d160a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[871],{8489:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>d});var t=s(4848),i=s(8453);const r={sidebar_position:8,sidebar_label:"\ud83d\udcc4 Features Summary",hide_table_of_contents:!0,description:"List that fastly summarizes all TinyORM features.",keywords:["c++ orm","tinyorm","features","summary","features summary"]},a="Features Summary",l={id:"features-summary",title:"Features Summary",description:"List that fastly summarizes all TinyORM features.",source:"@site/docs/features-summary.mdx",sourceDirName:".",slug:"/features-summary",permalink:"/features-summary",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:8,frontMatter:{sidebar_position:8,sidebar_label:"\ud83d\udcc4 Features Summary",hide_table_of_contents:!0,description:"List that fastly summarizes all TinyORM features.",keywords:["c++ orm","tinyorm","features","summary","features summary"]},sidebar:"tinyormSidebar",previous:{title:"\ud83d\udea9 Stability",permalink:"/stability"},next:{title:"\u2764\ufe0f Sponsors",permalink:"/sponsors"}},o={},d=[{value:"Summary List",id:"summary-list",level:2},{value:"Showcase Images",id:"showcase-images",level:2},{value:"Tom console application",id:"tom-console-application",level:6},{value:"Passed all unit tests \ud83e\udd73",id:"passed-all-unit-tests-",level:6},{value:"TinyOrmPlayground",id:"tinyormplayground",level:4},{value:"TinyOrmPlayground single-threaded",id:"tinyormplayground-single-threaded",level:6},{value:"TinyOrmPlayground multi-threaded",id:"tinyormplayground-multi-threaded",level:6}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h4:"h4",h6:"h6",header:"header",li:"li",p:"p",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"features-summary",children:"Features Summary"})}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#summary-list",children:"Summary List"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#showcase-images",children:"Showcase Images"})}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"summary-list",children:"Summary List"}),"\n",(0,t.jsxs)(n.p,{children:["The following list fastly summarizes all the ",(0,t.jsx)(n.code,{children:"TinyORM"})," features."]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"simple database connections management"})," \ud83e\uddec","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"database manager that helps with the database connections management"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"Orm::DB"})," facade class for nicer and shorter syntax"]}),"\n",(0,t.jsxs)(n.li,{children:["MySQL, MariaDB, SQLite, and PostgreSQL support for ",(0,t.jsx)(n.strong,{children:"all"})," features \ud83d\udc8e"]}),"\n",(0,t.jsx)(n.li,{children:"multi-threading support \ud83d\udc40"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"SSL"})," connections support \ud83d\udd12"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"impressive query builder"})," \ud83d\udd27","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"allows passing sub-queries and raw expressions practically everywhere, to column names, values, and to every SQL clause as select, where, joins, group by, having, order by \ud83d\udd25"}),"\n",(0,t.jsx)(n.li,{children:"a logical grouping that offers to wrap logical groups in parenthesis"}),"\n",(0,t.jsx)(n.li,{children:"chunked results for lower memory footprint \u2728"}),"\n",(0,t.jsx)(n.li,{children:"raw methods for all SQL clauses"}),"\n",(0,t.jsx)(n.li,{children:"all join types (left, right, cross, inner) and also join where clause support \ud83e\udee4"}),"\n",(0,t.jsx)(n.li,{children:"aggregate methods min, max, sum, increment, decrement, ..."}),"\n",(0,t.jsx)(n.li,{children:"whereExists and exists methods for an existence queries"}),"\n",(0,t.jsx)(n.li,{children:"transactions and pessimistic locking \ud83d\udd12"}),"\n",(0,t.jsx)(n.li,{children:"of course, insert, update, and delete SQL clauses support"}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"correct QDateTime time zone"})," using the ",(0,t.jsx)(n.code,{children:"qt_timezone"})," connection configuration option \ud83d\udcc5 (returned QDateTime instances will have the correct time zone, and also works for an ORM)","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"this feature allows you to set up the database server time zone to the UTC and all returned QDateTime instances will have the correct UTC time zone"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"clever ORM with all relation types support"})," \ud83c\udf89","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"one-to-one, one-to-many, and many-to-many relation types (also inverse relationships) \ud83e\udde8"}),"\n",(0,t.jsx)(n.li,{children:"eager and lazy loading with custom select and constraints \ud83d\ude80"}),"\n",(0,t.jsxs)(n.li,{children:["fluent ",(0,t.jsx)(n.code,{children:"ModelsCollection"})," that expose a variety of map / reduce operations that may be chained using an intuitive interface \u2728"]}),"\n",(0,t.jsx)(n.li,{children:"all query builder methods are proxied from the model instances and also from the relation instances back to the query builder \ud83e\udd2f (everything that can be called on the query builder can also be called on the model and relation instances)"}),"\n",(0,t.jsx)(n.li,{children:"clean active record pattern"}),"\n",(0,t.jsxs)(n.li,{children:["advanced features like timestamps, touching parent timestamps, ",(0,t.jsx)(n.strong,{children:"soft deleting"}),", default models, default model attributes, and attribute casting \ud83e\udd13"]}),"\n",(0,t.jsxs)(n.li,{children:["querying relationships existence/absence using the has, whereHas, and hasNested methods (using dot notation for selecting nested relationships ",(0,t.jsx)(n.em,{children:"users.posts.comments"}),")"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"serializing"})," models and collection of models including all nested relations to ",(0,t.jsx)(n.strong,{children:"JSON"})," and converting to vectors and maps \ud83e\udea1","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"supports controlling a custom date format during serialization"}),"\n",(0,t.jsx)(n.li,{children:"supports hiding and appending attributes"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"compiled database migrations and seeders"})," \ud83d\udd7a","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"create, update, drop, and rename database tables"}),"\n",(0,t.jsx)(n.li,{children:"create, drop, and rename table columns"}),"\n",(0,t.jsx)(n.li,{children:"extensive schema builder that allows creating of all possible column types"}),"\n",(0,t.jsx)(n.li,{children:"terser syntax for creating foreign keys and foreign key constraints"}),"\n",(0,t.jsx)(n.li,{children:"supports creating, and dropping column indexes (primary, unique, fulltext, spatial)"}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsxs)(n.strong,{children:["the ",(0,t.jsx)(n.code,{children:"tom"})," console application with tab completion for all shells (pwsh, bash, zsh)"]})," \ud83e\udd73","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"scaffolding of models, migrations, and seeders"}),"\n",(0,t.jsxs)(n.li,{children:["impressive models scaffolding, every feature that is supported by models can be generated using the ",(0,t.jsx)(n.code,{children:"tom make:model"})," cli command"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["a huge amount of code is unit tested, currently ",(0,t.jsx)(n.strong,{children:"3378 unit tests"})," \ud83e\udd2f"]}),"\n",(0,t.jsxs)(n.li,{children:["C++20 only, with all the latest features used like concepts/constraints, ranges, smart pointers (no ",(0,t.jsx)(n.code,{children:"new"})," keyword in the whole code \ud83d\ude0e), folding expressions"]}),"\n",(0,t.jsxs)(n.li,{children:["qmake and CMake build systems support","\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"CMake FetchContent module support \ud83e\udd19"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:"vcpkg support (also the vcpkg port, currently not committed to the vcpkg repository \u2639\ufe0f)"}),"\n",(0,t.jsx)(n.li,{children:"it's really fast, you can run 1000 complex queries in 500ms (heavily DB dependant, the PostgreSQL is by far the fastest) \u231a"}),"\n",(0,t.jsx)(n.li,{children:"extensive documentation \ud83d\udcc3"}),"\n",(0,t.jsx)(n.li,{children:"..."}),"\n"]}),"\n",(0,t.jsx)(n.admonition,{type:"info",children:(0,t.jsxs)(n.p,{children:["See the ",(0,t.jsx)(n.code,{children:"TinyDrivers"})," ",(0,t.jsx)(n.a,{href:"tinydrivers/getting-started#features-summary",children:"Features summary"}),"."]})}),"\n",(0,t.jsx)(n.h2,{id:"showcase-images",children:"Showcase Images"}),"\n",(0,t.jsx)(n.h6,{id:"tom-console-application",children:"Tom console application"}),"\n",(0,t.jsx)("img",{src:s(5848).A,alt:"TinyORM - Tom console application - Showcase",title:"Tom console application"}),"\n",(0,t.jsx)(n.h6,{id:"passed-all-unit-tests-",children:"Passed all unit tests \ud83e\udd73"}),"\n",(0,t.jsx)("img",{src:s(8994).A,alt:"TinyORM - Passed all unit tests - Showcase",title:"Passed all unit tests",width:"700",className:"no-blurry"}),"\n",(0,t.jsx)(n.h4,{id:"tinyormplayground",children:"TinyOrmPlayground"}),"\n",(0,t.jsxs)(n.p,{children:["The ",(0,t.jsx)(n.a,{href:"https://github.com/silverqx/TinyOrmPlayground",children:"TinyOrmPlayground"})," project is my personal project where I have tested all the TinyORM database queries in the early development phases, currently, it executes ~1600 database queries across the whole TinyORM framework. Every query has a nice title header, is logged to the console, and is counted and measured (elapsed time). Every query also runs on all ",(0,t.jsx)(n.a,{href:"/database/getting-started#introduction",children:"supported databases"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["The TinyOrmPlayground project can be compiled in a single-threaded or multi-threaded mode. In the multi-threaded mode, every database connection runs in its own thread. At the end of every database connection is logged a connection summary and before an exit is logged the application summary. Whole TinyOrmPlayground application is configurable through the ",(0,t.jsx)(n.a,{href:"https://github.com/silverqx/TinyOrmPlayground/blob/main/src/configuration.hpp",children:"src/configuration.hpp"})," class."]}),"\n",(0,t.jsx)(n.h6,{id:"tinyormplayground-single-threaded",children:"TinyOrmPlayground single-threaded"}),"\n",(0,t.jsx)("img",{src:s(3672).A,alt:"TinyORM - Invoked TinyOrmPlayground single-threaded - Showcase",title:"Invoked TinyOrmPlayground single-threaded"}),"\n",(0,t.jsx)(n.h6,{id:"tinyormplayground-multi-threaded",children:"TinyOrmPlayground multi-threaded"}),"\n",(0,t.jsx)("img",{src:s(2599).A,alt:"TinyORM - Invoked TinyOrmPlayground multi-threaded - Showcase",title:"Invoked TinyOrmPlayground multi-threaded"})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},8994:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyorm-passed_all_unit_tests-d730d995b6b490fb42c3671738e3b81e.png"},2599:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyormplayground-multi-threaded-edb67030c75e2845e1fa7013e510174c.png"},3672:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tinyormplayground-single-threaded-4e7a5769ad5a768a4d04c6dc856c4391.png"},5848:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/tom_cli-402f7dd4dfe7dbd0b20dfe5fb61838a2.png"},8453:(e,n,s)=>{s.d(n,{R:()=>a,x:()=>l});var t=s(6540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/feaee7f3.17aa4b37.js b/assets/js/feaee7f3.17aa4b37.js new file mode 100644 index 000000000..0531ddd98 --- /dev/null +++ b/assets/js/feaee7f3.17aa4b37.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[983],{8781:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>m,contentTitle:()=>u,default:()=>g,frontMatter:()=>h,metadata:()=>p,toc:()=>x});var i=l(4848),r=l(8453),t=l(8774),o=l(2364),a=l(9365),s=l(1470),d=l(7324),c=l(6694);const h={sidebar_position:2,sidebar_label:"Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",keywords:["c++ orm","building","hello world","tinyorm"]},u="Building: Hello world",p={id:"building/hello-world",title:"Building: Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",source:"@site/docs/building/hello-world.mdx",sourceDirName:"building",slug:"/building/hello-world",permalink:"/building/hello-world",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",keywords:["c++ orm","building","hello world","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"TinyORM",permalink:"/building/tinyorm"},next:{title:"Migrations",permalink:"/building/migrations"}},m={},x=[{value:"Introduction",id:"introduction",level:2},{value:"Prepare SQLite 3 database",id:"prepare-sqlite-3-database",level:2},{value:"Install dependencies",id:"install-dependencies",level:2},{value:"Using vcpkg.json (manifest mode)",id:"using-vcpkg-json-manifest-mode",level:4},{value:"Using vcpkg install (manually)",id:"using-vcpkg-install-manually",level:4},{value:"Source code",id:"source-code",level:2},{value:"Hello world with CMake",id:"hello-world-with-cmake",level:2},{value:"CMake project",id:"cmake-project",level:3},{value:"FetchContent",id:"fetchcontent",level:3},{value:"How FetchContent module works",id:"how-fetchcontent-module-works",level:4},{value:"Build Hello world",id:"build-hello-world-cmake",level:3},{value:"Execute Hello world",id:"execute-hello-world-cmake",level:3},{value:"Hello world with qmake",id:"hello-world-with-qmake",level:2},{value:"qmake project",id:"qmake-project",level:3},{value:"Auto-configure using .qmake.conf and .env",id:"auto-configure-using-qmake_conf-and-env",level:4},{value:"Build Hello world",id:"build-hello-world-qmake",level:3},{value:"Execute Hello world",id:"execute-hello-world-qmake",level:3}];function j(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"building-hello-world",children:"Building: Hello world"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#prepare-sqlite-3-database",children:"Prepare SQLite 3 database"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-vcpkg-json-manifest-mode",children:"Using vcpkg.json"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-vcpkg-install-manually",children:"Using vcpkg install"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#source-code",children:"Source code"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#hello-world-with-cmake",children:"Hello world with CMake"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#cmake-project",children:"CMake project"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#fetchcontent",children:"FetchContent"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#build-hello-world-cmake",children:"Build Hello world"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#execute-hello-world-cmake",children:"Execute Hello world"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#hello-world-with-qmake",children:"Hello world with qmake"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#qmake-project",children:"qmake project"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#build-hello-world-qmake",children:"Build Hello world"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#execute-hello-world-qmake",children:"Execute Hello world"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{className:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(t.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(n.p,{children:["We will try to create the simplest working console application, in the terminal with the ",(0,i.jsx)(n.code,{children:"CMake"})," and in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"})," with the ",(0,i.jsx)(n.code,{children:"qmake"})," build systems."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example also expects the following ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"}),", let's create them."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}\nmkdir HelloWorld/HelloWorld\ncd HelloWorld`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}\nmkdir -p HelloWorld/HelloWorld\ncd HelloWorld`})})]}),"\n",(0,i.jsx)(n.h2,{id:"prepare-sqlite-3-database",children:"Prepare SQLite 3 database"}),"\n",(0,i.jsxs)(n.p,{children:["The easiest way to demonstrate the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example will be with a ",(0,i.jsx)(n.code,{children:"SQLite 3"})," database."]}),"\n",(0,i.jsxs)(n.p,{children:["Execute the following command in the terminal to create and insert two rows into the ",(0,i.jsx)(n.code,{children:"SQLite 3"})," database."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"sqlite3 HelloWorld.sqlite3 \"\ncreate table posts(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL);\ninsert into posts values(1, 'First Post');\ninsert into posts values(2, 'Second Post');\nselect * from posts;\"\n"})}),"\n",(0,i.jsx)(n.h2,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,i.jsxs)(n.p,{children:["First, install the ",(0,i.jsx)(n.code,{children:"vcpkg"})," package manager as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#vcpkg",children:"here"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"range-v3"})," and ",(0,i.jsx)(n.code,{children:"tabulate"})," libraries are required dependencies because ",(0,i.jsx)(n.code,{children:"TinyORM"})," uses them in header files, you have to install them before you can use ",(0,i.jsx)(n.code,{children:"TinyORM"}),". The ",(0,i.jsx)(n.code,{children:"tabulate"})," library is only needed in the ",(0,i.jsx)(n.code,{children:"tom"})," migrations it's used by the ",(0,i.jsx)(n.code,{children:"migrate:status"})," command."]}),"\n",(0,i.jsxs)(n.p,{children:["There are two ways how to install the ",(0,i.jsx)(n.code,{children:"range-v3"})," and ",(0,i.jsx)(n.code,{children:"tabulate"})," libraries using ",(0,i.jsx)(n.code,{children:"vcpkg"}),"."]}),"\n",(0,i.jsxs)(n.h4,{id:"using-vcpkg-json-manifest-mode",children:["Using vcpkg.json ",(0,i.jsx)("small",{children:"(manifest mode)"})]}),"\n",(0,i.jsxs)(n.p,{children:["Create a ",(0,i.jsx)(n.code,{children:"vcpkg.json"})," file with the following content. ",(0,i.jsx)(n.code,{children:"CMake"})," example below uses this method."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd HelloWorld\nvim vcpkg.json\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",metastring:"title='vcpkg.json'",children:'{\n "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",\n "name": "tinyorm-helloworld",\n "version-semver": "0.1.0",\n "maintainers": "Silver Zachara ",\n "description": "Hello world console application for TinyORM C++ library",\n "homepage": "https://github.com/silverqx/TinyORM",\n "documentation": "https://www.tinyorm.org/building/hello-world",\n "supports": "!(uwp | arm | android | emscripten | osx | ios | xbox | freebsd | openbsd | wasm32)",\n "dependencies": [\n "range-v3",\n "tabulate"\n ]\n}\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["Only ",(0,i.jsx)(n.code,{children:"CMake"})," via the ",(0,i.jsx)(n.code,{children:"toolchain file"})," supports this method."]})}),"\n",(0,i.jsxs)(n.h4,{id:"using-vcpkg-install-manually",children:["Using vcpkg install ",(0,i.jsx)("small",{children:"(manually)"})]}),"\n",(0,i.jsxs)(n.p,{children:["This method can be used with both ",(0,i.jsx)(n.code,{children:"CMake"})," and ",(0,i.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,i.jsx)(n.h2,{id:"source-code",children:"Source code"}),"\n",(0,i.jsxs)(n.p,{children:["Let's start in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project folder."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld`})})]}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"main.cpp"})," source file."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"vim main.cpp\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,i.jsx)(n.code,{children:"vim"}),", press ",(0,i.jsx)("kbd",{children:"Shift"})," + ",(0,i.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,i.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",metastring:"title='main.cpp'",children:'#include \n#include \n\n#ifdef _WIN32\n# include \n#endif\n\n#include \n\nusing Orm::DB;\n\nint main(int argc, char *argv[])\n{\n#ifdef _WIN32\n SetConsoleOutputCP(CP_UTF8);\n// SetConsoleOutputCP(1250);\n#endif\n\n /* Needed from Qt v6.5.3 to avoid:\n qt.core.qobject.connect: QObject::connect(QObject, Unknown): invalid nullptr parameter */\n QCoreApplication app(argc, argv);\n\n // Ownership of a shared_ptr()\n auto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("TINYORM_HELLOWORLD_DB_SQLITE_DATABASE",\n "../../HelloWorld.sqlite3")},\n {"check_database_exists", true},\n });\n\n auto posts = DB::select("select * from posts");\n\n while(posts.next())\n qDebug() << posts.value("id").toULongLong()\n << posts.value("name").toString();\n}\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," depends on ",(0,i.jsx)(n.code,{children:"QCoreApplication"})," from ",(0,i.jsx)(n.code,{children:"Qt v6.5.3"})," so you must create the ",(0,i.jsx)(n.code,{children:"QCoreApplication"})," instance before you will call anything from the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library. \ud83e\udee4 The change was made ",(0,i.jsx)(n.a,{href:"https://github.com/qt/qtbase/commit/8d2bdc9cd5482eace12ba7e45304857bd24db0e6#diff-1d355c25c0b0eddec2be48253407780c4dc510d986739aec61e1ec892ccaf86e",children:"here"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"hello-world-with-cmake",children:"Hello world with CMake"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["If something is not clear, you can still look at GitHub Action ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:(0,i.jsx)(n.code,{children:"workflows"})})," how the build is done."]})}),"\n",(0,i.jsxs)(n.p,{children:["Create a folder for the ",(0,i.jsx)(n.code,{children:"CMake"})," build."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:"cd ..\nmkdir HelloWorld-builds-cmake/build-debug\n\ncd HelloWorld"})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:"cd ..\nmkdir -p HelloWorld-builds-cmake/build-debug\n\ncd HelloWorld"})})]}),"\n",(0,i.jsx)(n.h3,{id:"cmake-project",children:"CMake project"}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"CMakeLists.txt"})," file with the following content."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.b,(0,c.OZ)(d.b))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt\${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt\${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.xj,(0,c.OZ)(d.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt\${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt\${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)`})})]}),"\n",(0,i.jsx)(n.h3,{id:"fetchcontent",children:"FetchContent"}),"\n",(0,i.jsxs)(n.p,{children:["If you don't have cloned and built the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library, or you want to quickly try TinyORM without wasting time with cloning and building the TinyORM library, then you can use CMake's ",(0,i.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/module/FetchContent.html",children:(0,i.jsx)(n.code,{children:"FetchContent"})})," module that will do all of this for you."]}),"\n",(0,i.jsxs)(n.p,{children:["Instead of providing a path by the ",(0,i.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"})," (or using the ",(0,i.jsx)(n.code,{children:"User Package Registry"}),") like in the example below:"]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.b,(0,c.OZ)(d.b))}/TinyORM/TinyORM-builds-cmake/build-debug")`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.xj,(0,c.OZ)(d.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")`})})]}),"\n",(0,i.jsxs)(n.p,{children:["You can use the ",(0,i.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/module/FetchContent.html",children:(0,i.jsx)(n.code,{children:"FetchContent"})})," module like in the following example."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:"cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# FetchContent method\ninclude(FetchContent)\nFetchContent_Declare(TinyOrm\n GIT_REPOSITORY https://github.com/silverqx/TinyORM.git\n GIT_TAG origin/main\n OVERRIDE_FIND_PACKAGE\n)\n# Here you can configure TinyORM CMake options\nset(MYSQL_PING OFF)\nset(TOM_EXAMPLE ON)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)"})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:"cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# FetchContent method\ninclude(FetchContent)\nFetchContent_Declare(TinyOrm\n GIT_REPOSITORY https://github.com/silverqx/TinyORM.git\n GIT_TAG origin/main\n OVERRIDE_FIND_PACKAGE\n)\n# Here you can configure TinyORM CMake options\nset(MYSQL_PING OFF)\nset(TOM_EXAMPLE ON)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)"})})]}),"\n",(0,i.jsx)(n.h4,{id:"how-fetchcontent-module-works",children:"How FetchContent module works"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"FetchContent_Declare"})," command is like calling the git clone inside the build folder and then adding a cloned folder in a similar way as the ",(0,i.jsx)(n.code,{children:"add_subdirectory()"})," command does."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"FetchContent_MakeAvailable()"})," internally calls the ",(0,i.jsx)(n.code,{children:"find_package()"})," command or if you pass the ",(0,i.jsx)(n.code,{children:"OVERRIDE_FIND_PACKAGE"})," argument, then you don't have to call the the ",(0,i.jsx)(n.code,{children:"FetchContent_MakeAvailable"}),", but you must call the ",(0,i.jsx)(n.code,{children:"find_package( x.y.z CONFIG REQUIRED)"})," command manually."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["An advantage of the ",(0,i.jsx)(n.code,{children:"OVERRIDE_FIND_PACKAGE"})," argument is that you can call the ",(0,i.jsx)(n.code,{children:"find_package"})," command much later, and you can insert additional configurations between."]})}),"\n",(0,i.jsx)(n.h3,{id:"build-hello-world-cmake",children:"Build Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["Now you are ready to configure ",(0,i.jsx)(n.code,{children:"HelloWorld"})," ",(0,i.jsx)(n.code,{children:"CMake"})," application."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd ../HelloWorld-builds-cmake/build-debug\n"})}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld" \`\n-B "${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.b)}/tmp/HelloWorld"`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cmake \\\n-S "${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld" \\\n-B "${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.xj)}/tmp/TinyORM"`})})]}),"\n",(0,i.jsx)(n.p,{children:"And build."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Enable the ",(0,i.jsx)(n.a,{href:"/building/tinyorm#cmake-strict_mode-option",children:(0,i.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})})," environment variable to produce better code and to follow good code practices."]})}),"\n",(0,i.jsx)(n.h3,{id:"execute-hello-world-cmake",children:"Execute Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["Do not forget to add ",(0,i.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,i.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so ",(0,i.jsx)(n.code,{children:"HelloWorld"})," application can find it during execution, as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#tinyorm-on-path-cmake",children:"here"}),"."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,name:"tinyorm-on-path",children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`$env:Path = "${(0,c.OZ)(d.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,c.OZ)(d.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,i.jsxs)(n.p,{children:["Execute ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-powershell",children:".\\HelloWorld.exe\n"})})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"./HelloWorld\n"})})})]}),"\n",(0,i.jsx)(n.p,{children:"The output will look like this."}),"\n",(0,i.jsx)(o.A,{className:"language-less",children:'Executed prepared query (6ms, -1 results, 0 affected, tinyorm_default) : select * from posts\n1 "First Post"\n2 "Second Post"'}),"\n",(0,i.jsx)(n.h2,{id:"hello-world-with-qmake",children:"Hello world with qmake"}),"\n",(0,i.jsxs)(n.p,{children:["Create a folder for the ",(0,i.jsx)(n.code,{children:"qmake"})," build."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/HelloWorld\n\nmkdir HelloWorld-builds-qmake`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/HelloWorld\n\nmkdir HelloWorld-builds-qmake`})})]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.a,{href:"#source-code",children:(0,i.jsx)(n.code,{children:"source code"})})," is the same as for the ",(0,i.jsx)(n.code,{children:"HelloWorld CMake"})," example."]}),"\n",(0,i.jsx)(n.h3,{id:"qmake-project",children:"qmake project"}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"HelloWorld.pro"})," qmake file with the following content."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd HelloWorld\nvim HelloWorld.pro\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,i.jsx)(n.code,{children:"vim"}),", press ",(0,i.jsx)("kbd",{children:"Shift"})," + ",(0,i.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",metastring:"title='HelloWorld.pro'",children:"QT -= gui\n\nTEMPLATE = app\n\nCONFIG *= cmdline\n\nDEFINES *= PROJECT_TINYORM_HELLOWORLD\n\nSOURCES += $$PWD/main.cpp\n\n# Auto-configure TinyORM library \ud83d\udd25\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The exact ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," is crucial in this example because the paths to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," source and build folders are relative."]})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsx)(n.p,{children:"Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!"})}),"\n",(0,i.jsxs)(n.h4,{id:"auto-configure-using-qmake_conf-and-env",children:[(0,i.jsx)(n.code,{children:"Auto-configure"})," using ",(0,i.jsx)(n.code,{children:".qmake.conf"})," and ",(0,i.jsx)(n.code,{children:".env"})]}),"\n",(0,i.jsxs)(n.p,{children:["If you want to have properly configured ",(0,i.jsx)(n.code,{children:"DEFINES"})," (C preprocessor macros) or have Qt headers marked as system headers, then you need to specify a path to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,i.jsx)(n.code,{children:".prf"})," files) which handle this correctly; this path is provided by the ",(0,i.jsx)(n.code,{children:"QMAKEFEATURES"})," variable and can only be set in the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Read the ",(0,i.jsx)(n.a,{href:"/building/tinyorm#consume-tinyorm-library-qmake",children:"Consume TinyOrm library (qmake)"})," section, as everything that is described in that section applies here as well."]})}),"\n",(0,i.jsxs)(n.p,{children:["Create the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project root folder with the following content."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)\n# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n# Path to the current build tree (used to guess the TinyORM build tree)\n#TINY_BUILD_TREE = $$shadowed($$PWD)\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Then, create a ",(0,i.jsx)("code",{children:".env.(win32|unix|mingw)"})," file in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project root folder with the following content."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:".env.win32",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-windows\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n"})})}),(0,i.jsx)(a.A,{value:d.xj,label:".env.unix",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-linux\n\n# Use faster linker\nclang: CONFIG *= use_lld_linker\nelse: CONFIG *= use_gold_linker\n\n# Or use the mold linker\n#QMAKE_LFLAGS *= -fuse-ld=mold\n"})})}),(0,i.jsx)(a.A,{value:"mingw",label:".env.mingw",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_clang_64bit-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-mingw-dynamic\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n\n# Use faster linker (for both GCC and Clang)\n# CONFIG *= use_lld_linker does not work on MinGW\nQMAKE_LFLAGS *= -fuse-ld=lld\n"})})})]}),"\n",(0,i.jsxs)(n.p,{children:["Don't forget to update the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and ",(0,i.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," folder paths to your needs if you are not using the recommended ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:(0,i.jsx)(n.code,{children:"Folders structure"})}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You can use the ",(0,i.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually. Just comment out the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and uncomment the ",(0,i.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"})," in the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can entirely avoid the ",(0,i.jsx)(n.code,{children:".env"})," files, just move the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," to the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," or remove it by help of ",(0,i.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," and set the ",(0,i.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable at system level as is described in ",(0,i.jsx)(n.a,{href:"/building/tinyorm#set-up-vcpkg-environment",children:(0,i.jsx)(n.code,{children:"Set up vcpkg environment"})}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["Configuring by the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," and ",(0,i.jsx)(n.code,{children:".env"})," files has one big advantage, which is that you don't have to modify the project files."]})}),"\n",(0,i.jsx)(n.h3,{id:"build-hello-world-qmake",children:"Build Hello world"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["I recommend creating a new ",(0,i.jsx)(n.code,{children:"Session"})," in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"})," as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#open-qtcreator-ide",children:"here"}),"."]})}),"\n",(0,i.jsxs)(n.p,{children:["Now you can open the ",(0,i.jsx)(n.code,{children:"HelloWorld.pro"})," project in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["This will open the ",(0,i.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,i.jsx)("img",{src:l(3180).A,alt:"HelloWorld - QtCreator - Configure Project",width:"760"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can force the ",(0,i.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#qtcreator-default-build-directory",children:"here"}),"."]})}),"\n",(0,i.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"5"})," to open ",(0,i.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,i.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,i.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,i.jsx)("img",{src:l(7028).A,className:"no-blurry",alt:"HelloWorld - QtCreator - Build Settings",width:"760"}),"\n",(0,i.jsxs)(n.p,{children:["Disable ",(0,i.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,i.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,i.jsxs)(n.p,{children:["In the left sidebar open ",(0,i.jsx)(n.code,{children:"Dependencies"})," and check ",(0,i.jsx)(n.code,{children:"TinyORM"})," project and ",(0,i.jsx)(n.code,{children:"Synchronize configuration"}),", this setting ensures that the current project will be rebuilt correctly when the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library source code changes."]}),"\n",(0,i.jsxs)(n.p,{children:["Everything is ready to build, you can press ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,i.jsx)(n.h3,{id:"execute-hello-world-qmake",children:"Execute Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"QtCreator"})," takes care of all the necessary configurations, sets up the build environment correctly, and also prepends dependency libraries on the system path on Windows and on the ",(0,i.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux."]}),"\n",(0,i.jsxs)(n.p,{children:["The only thing you might want to change is to run the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example in the new terminal window. To do so, hit ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"5"})," to open the ",(0,i.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,i.jsx)(n.code,{children:"Run"})," in the left sidebar to open the ",(0,i.jsx)(n.code,{children:"Run Settings"}),", then in the ",(0,i.jsx)(n.code,{children:"Run"})," section select the ",(0,i.jsx)(n.code,{children:"Run in terminal"})," checkbox."]}),"\n",(0,i.jsxs)(n.p,{children:["To execute the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example press ",(0,i.jsx)("kbd",{children:"Ctrl"})," + ",(0,i.jsx)("kbd",{children:"r"}),"."]}),"\n",(0,i.jsx)(n.p,{children:"The output will look like this."}),"\n",(0,i.jsx)(o.A,{className:"language-less",children:'Executed prepared query (6ms, -1 results, 0 affected, tinyorm_default) : select * from posts\n1 "First Post"\n2 "Second Post"'})]})}function g(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(j,{...e})}):j(e)}},9365:(e,n,l)=>{l.d(n,{A:()=>o});l(6540);var i=l(4164);const r={tabItem:"tabItem_Ymn6"};var t=l(4848);function o(e){let{children:n,hidden:l,className:o}=e;return(0,t.jsx)("div",{role:"tabpanel",className:(0,i.A)(r.tabItem,o),hidden:l,children:n})}},1470:(e,n,l)=>{l.d(n,{A:()=>y});var i=l(6540),r=l(4164),t=l(3104),o=l(6347),a=l(205),s=l(7485),d=l(1682),c=l(679);function h(e){return i.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,i.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:l}=e;return(0,i.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:l,attributes:i,default:r}}=e;return{value:n,label:l,attributes:i,default:r}}))}(l);return function(e){const n=(0,d.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,l])}function p(e){let{value:n,tabValues:l}=e;return l.some((e=>e.value===n))}function m(e){let{queryString:n=!1,groupId:l}=e;const r=(0,o.W6)(),t=function(e){let{queryString:n=!1,groupId:l}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!l)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return l??null}({queryString:n,groupId:l});return[(0,s.aZ)(t),(0,i.useCallback)((e=>{if(!t)return;const n=new URLSearchParams(r.location.search);n.set(t,e),r.replace({...r.location,search:n.toString()})}),[t,r])]}function x(e){const{defaultValue:n,queryString:l=!1,groupId:r}=e,t=u(e),[o,s]=(0,i.useState)((()=>function(e){let{defaultValue:n,tabValues:l}=e;if(0===l.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:l}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${l.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const i=l.find((e=>e.default))??l[0];if(!i)throw new Error("Unexpected error: 0 tabValues");return i.value}({defaultValue:n,tabValues:t}))),[d,h]=m({queryString:l,groupId:r}),[x,j]=function(e){let{groupId:n}=e;const l=function(e){return e?`docusaurus.tab.${e}`:null}(n),[r,t]=(0,c.Dv)(l);return[r,(0,i.useCallback)((e=>{l&&t.set(e)}),[l,t])]}({groupId:r}),g=(()=>{const e=d??x;return p({value:e,tabValues:t})?e:null})();(0,a.A)((()=>{g&&s(g)}),[g]);return{selectedValue:o,selectValue:(0,i.useCallback)((e=>{if(!p({value:e,tabValues:t}))throw new Error(`Can't select invalid tab value=${e}`);s(e),h(e),j(e)}),[h,j,t]),tabValues:t}}var j=l(2303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=l(4848);function f(e){let{className:n,block:l,selectedValue:i,selectValue:o,tabValues:a}=e;const s=[],{blockElementScrollPositionUntilNextRender:d}=(0,t.a_)(),c=e=>{const n=e.currentTarget,l=s.indexOf(n),r=a[l].value;r!==i&&(d(n),o(r))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const l=s.indexOf(e.currentTarget)+1;n=s[l]??s[0];break}case"ArrowLeft":{const l=s.indexOf(e.currentTarget)-1;n=s[l]??s[s.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":l},n),children:a.map((e=>{let{value:n,label:l,attributes:t}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:i===n?0:-1,"aria-selected":i===n,ref:e=>s.push(e),onKeyDown:h,onClick:c,...t,className:(0,r.A)("tabs__item",g.tabItem,t?.className,{"tabs__item--active":i===n}),children:l??n},n)}))})}function _(e){let{lazy:n,children:l,selectedValue:t}=e;const o=(Array.isArray(l)?l:[l]).filter(Boolean);if(n){const e=o.find((e=>e.props.value===t));return e?(0,i.cloneElement)(e,{className:(0,r.A)("margin-top--md",e.props.className)}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:o.map(((e,n)=>(0,i.cloneElement)(e,{key:n,hidden:e.props.value!==t})))})}function T(e){const n=x(e);return(0,b.jsxs)("div",{className:(0,r.A)("tabs-container",g.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(_,{...n,...e})]})}function y(e){const n=(0,j.A)();return(0,b.jsx)(T,{...e,children:h(e.children)},String(n))}},7324:(e,n,l)=>{l.d(n,{$E:()=>j,A3:()=>b,CW:()=>g,Dx:()=>c,F4:()=>u,Fi:()=>d,J_:()=>y,LQ:()=>f,Lf:()=>k,OO:()=>r,Q7:()=>_,b:()=>a,cy:()=>s,gg:()=>m,kl:()=>p,os:()=>h,pW:()=>t,ux:()=>x,vf:()=>i,xj:()=>o,xt:()=>T});const i="shell",r="database",t="application",o="bash",a="pwsh",s="zsh",d="maria",c="mysql",h="postgres",u="sqlite",p="application",m="bash",x="pwsh",j="zsh",g="MariaDB",b="MySQL",f="PostgreSQL",_="SQLite",T="tinyorm.org",y="$HOME/Code/c/",k="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,l)=>{l.d(n,{A:()=>t});var i=l(6540),r=l(1838);function t(){const e=(0,i.useContext)(r.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,l)=>{l.d(n,{OZ:()=>s,Sn:()=>o,T3:()=>c,bw:()=>d,nC:()=>h,np:()=>a});var i=l(6362),r=l(2303),t=l(7324);const o=function(e,n){return void 0===n&&(n=!0),u((0,i.A)().rootFolder[e]??d(e),e,n)},a=()=>(0,i.A)().rootFolder[t.pW]??d(t.pW),s=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const l=n||e!==t.b?"/":"\\";return u(o(e)+l+a(),e,n)};function d(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,r.A)())return"";switch(e){case t.b:return t.Lf;case t.xj:return t.J_;case t.pW:return t.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===t.pW}function h(e,n){if(null==n||""===n)return n;const l="$ENV{$1}$2";switch(e){case t.b:return m(n).replace(/\$env:(.+?)(\/.*)/,l);case t.xj:return n.replace(/\$(.+?)(\/.*)/,l);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function u(e,n,l){if(void 0===l&&(l=!0),null==e||""===e)return e;if(n!==t.b)return p(e);const i=p(e);return l?m(i):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(i)}function p(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function m(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},7028:(e,n,l)=>{l.d(n,{A:()=>i});const i=l.p+"assets/images/qmake-build_settings-ebdc6c0c056d11462096ff10cba682a1.png"},3180:(e,n,l)=>{l.d(n,{A:()=>i});const i=l.p+"assets/images/qmake-configure_project-8caf87e6af4452f0c28bd15c85c392fc.png"}}]); \ No newline at end of file diff --git a/assets/js/feaee7f3.e63c6b5d.js b/assets/js/feaee7f3.e63c6b5d.js deleted file mode 100644 index 64058b4fc..000000000 --- a/assets/js/feaee7f3.e63c6b5d.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[983],{8781:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>m,contentTitle:()=>u,default:()=>g,frontMatter:()=>h,metadata:()=>p,toc:()=>x});var i=l(4848),r=l(8453),t=l(8774),o=l(2364),a=l(9365),s=l(1470),d=l(7324),c=l(6694);const h={sidebar_position:2,sidebar_label:"Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",keywords:["c++ orm","building","hello world","tinyorm"]},u="Building: Hello world",p={id:"building/hello-world",title:"Building: Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",source:"@site/docs/building/hello-world.mdx",sourceDirName:"building",slug:"/building/hello-world",permalink:"/building/hello-world",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,sidebar_label:"Hello world",description:"Hello world example created in the terminal and QtCreator IDE.",keywords:["c++ orm","building","hello world","tinyorm"]},sidebar:"tinyormSidebar",previous:{title:"TinyORM",permalink:"/building/tinyorm"},next:{title:"Migrations",permalink:"/building/migrations"}},m={},x=[{value:"Introduction",id:"introduction",level:2},{value:"Prepare SQLite 3 database",id:"prepare-sqlite-3-database",level:2},{value:"Install dependencies",id:"install-dependencies",level:2},{value:"Using vcpkg.json (manifest mode)",id:"using-vcpkg-json-manifest-mode",level:4},{value:"Using vcpkg install (manually)",id:"using-vcpkg-install-manually",level:4},{value:"Source code",id:"source-code",level:2},{value:"Hello world with CMake",id:"hello-world-with-cmake",level:2},{value:"CMake project",id:"cmake-project",level:3},{value:"FetchContent",id:"fetchcontent",level:3},{value:"How FetchContent module works",id:"how-fetchcontent-module-works",level:4},{value:"Build Hello world",id:"build-hello-world-cmake",level:3},{value:"Execute Hello world",id:"execute-hello-world-cmake",level:3},{value:"Hello world with qmake",id:"hello-world-with-qmake",level:2},{value:"qmake project",id:"qmake-project",level:3},{value:"Auto-configure using .qmake.conf and .env",id:"auto-configure-using-qmake_conf-and-env",level:4},{value:"Build Hello world",id:"build-hello-world-qmake",level:3},{value:"Execute Hello world",id:"execute-hello-world-qmake",level:3}];function j(e){const n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"building-hello-world",children:"Building: Hello world"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#introduction",children:"Introduction"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#prepare-sqlite-3-database",children:"Prepare SQLite 3 database"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#install-dependencies",children:"Install dependencies"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-vcpkg-json-manifest-mode",children:"Using vcpkg.json"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#using-vcpkg-install-manually",children:"Using vcpkg install"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#source-code",children:"Source code"})}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#hello-world-with-cmake",children:"Hello world with CMake"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#cmake-project",children:"CMake project"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#fetchcontent",children:"FetchContent"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#build-hello-world-cmake",children:"Build Hello world"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#execute-hello-world-cmake",children:"Execute Hello world"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.a,{href:"#hello-world-with-qmake",children:"Hello world with qmake"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#qmake-project",children:"qmake project"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#build-hello-world-qmake",children:"Build Hello world"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"#execute-hello-world-qmake",children:"Execute Hello world"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)("div",{class:"api-stability alert alert--success",children:(0,i.jsxs)(n.p,{children:[(0,i.jsx)(t.A,{to:"/stability#stability-indexes",children:(0,i.jsx)(n.strong,{children:"Stability: 2"})})," - Stable"]})}),"\n",(0,i.jsxs)(n.p,{children:["We will try to create the simplest working console application, in the terminal with the ",(0,i.jsx)(n.code,{children:"CMake"})," and in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"})," with the ",(0,i.jsx)(n.code,{children:"qmake"})," build systems."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example also expects the following ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"}),", let's create them."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}\nmkdir HelloWorld/HelloWorld\ncd HelloWorld`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}\nmkdir -p HelloWorld/HelloWorld\ncd HelloWorld`})})]}),"\n",(0,i.jsx)(n.h2,{id:"prepare-sqlite-3-database",children:"Prepare SQLite 3 database"}),"\n",(0,i.jsxs)(n.p,{children:["The easiest way to demonstrate the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example will be with a ",(0,i.jsx)(n.code,{children:"SQLite 3"})," database."]}),"\n",(0,i.jsxs)(n.p,{children:["Execute the following command in the terminal to create and insert two rows into the ",(0,i.jsx)(n.code,{children:"SQLite 3"})," database."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"sqlite3 HelloWorld.sqlite3 \"\ncreate table posts(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR NOT NULL);\ninsert into posts values(1, 'First Post');\ninsert into posts values(2, 'Second Post');\nselect * from posts;\"\n"})}),"\n",(0,i.jsx)(n.h2,{id:"install-dependencies",children:"Install dependencies"}),"\n",(0,i.jsxs)(n.p,{children:["First, install the ",(0,i.jsx)(n.code,{children:"vcpkg"})," package manager as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#vcpkg",children:"here"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"range-v3"})," and ",(0,i.jsx)(n.code,{children:"tabulate"})," libraries are required dependencies because ",(0,i.jsx)(n.code,{children:"TinyORM"})," uses them in header files, you have to install them before you can use ",(0,i.jsx)(n.code,{children:"TinyORM"}),". The ",(0,i.jsx)(n.code,{children:"tabulate"})," library is only needed in the ",(0,i.jsx)(n.code,{children:"tom"})," migrations it's used by the ",(0,i.jsx)(n.code,{children:"migrate:status"})," command."]}),"\n",(0,i.jsxs)(n.p,{children:["There are two ways how to install the ",(0,i.jsx)(n.code,{children:"range-v3"})," and ",(0,i.jsx)(n.code,{children:"tabulate"})," libraries using ",(0,i.jsx)(n.code,{children:"vcpkg"}),"."]}),"\n",(0,i.jsxs)(n.h4,{id:"using-vcpkg-json-manifest-mode",children:["Using vcpkg.json ",(0,i.jsx)("small",{children:"(manifest mode)"})]}),"\n",(0,i.jsxs)(n.p,{children:["Create a ",(0,i.jsx)(n.code,{children:"vcpkg.json"})," file with the following content. ",(0,i.jsx)(n.code,{children:"CMake"})," example below uses this method."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd HelloWorld\nvim vcpkg.json\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",metastring:"title='vcpkg.json'",children:'{\n "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",\n "name": "tinyorm-helloworld",\n "version-semver": "0.1.0",\n "maintainers": "Silver Zachara ",\n "description": "Hello world console application for TinyORM C++ library",\n "homepage": "https://github.com/silverqx/TinyORM",\n "documentation": "https://www.tinyorm.org/building/hello-world",\n "supports": "!(uwp | arm | android | emscripten | osx | ios | xbox | freebsd | openbsd | wasm32)",\n "dependencies": [\n "range-v3",\n "tabulate"\n ]\n}\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"note",children:(0,i.jsxs)(n.p,{children:["Only ",(0,i.jsx)(n.code,{children:"CMake"})," via the ",(0,i.jsx)(n.code,{children:"toolchain file"})," supports this method."]})}),"\n",(0,i.jsxs)(n.h4,{id:"using-vcpkg-install-manually",children:["Using vcpkg install ",(0,i.jsx)("small",{children:"(manually)"})]}),"\n",(0,i.jsxs)(n.p,{children:["This method can be used with both ",(0,i.jsx)(n.code,{children:"CMake"})," and ",(0,i.jsx)(n.code,{children:"qmake"}),"."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd ../../vcpkg\n\nvcpkg search range-v3\nvcpkg search tabulate\nvcpkg install range-v3 tabulate\nvcpkg list\n"})}),"\n",(0,i.jsx)(n.h2,{id:"source-code",children:"Source code"}),"\n",(0,i.jsxs)(n.p,{children:["Let's start in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project folder."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld`})})]}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"main.cpp"})," source file."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"vim main.cpp\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,i.jsx)(n.code,{children:"vim"}),", press ",(0,i.jsx)("kbd",{children:"Shift"})," + ",(0,i.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,i.jsx)(n.p,{children:"And paste the following code."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-cpp",metastring:"title='main.cpp'",children:'#include \n#include \n\n#ifdef _WIN32\n# include \n#endif\n\n#include \n\nusing Orm::DB;\n\nint main(int argc, char *argv[])\n{\n#ifdef _WIN32\n SetConsoleOutputCP(CP_UTF8);\n// SetConsoleOutputCP(1250);\n#endif\n\n /* Needed from Qt v6.5.3 to avoid:\n qt.core.qobject.connect: QObject::connect(QObject, Unknown): invalid nullptr parameter */\n QCoreApplication app(argc, argv);\n\n // Ownership of a shared_ptr()\n auto manager = DB::create({\n {"driver", "QSQLITE"},\n {"database", qEnvironmentVariable("TINYORM_HELLOWORLD_DB_SQLITE_DATABASE",\n "../../HelloWorld.sqlite3")},\n {"check_database_exists", true},\n });\n\n auto posts = DB::select("select * from posts");\n\n while(posts.next())\n qDebug() << posts.value("id").toULongLong()\n << posts.value("name").toString();\n}\n'})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"QSqlDatabase"})," depends on ",(0,i.jsx)(n.code,{children:"QCoreApplication"})," from ",(0,i.jsx)(n.code,{children:"Qt v6.5.3"})," so you must create the ",(0,i.jsx)(n.code,{children:"QCoreApplication"})," instance before you will call anything from the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library. \ud83e\udee4 The change was made ",(0,i.jsx)(n.a,{href:"https://github.com/qt/qtbase/commit/8d2bdc9cd5482eace12ba7e45304857bd24db0e6#diff-1d355c25c0b0eddec2be48253407780c4dc510d986739aec61e1ec892ccaf86e",children:"here"}),"."]})}),"\n",(0,i.jsx)(n.h2,{id:"hello-world-with-cmake",children:"Hello world with CMake"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["If something is not clear, you can still look at GitHub Action ",(0,i.jsx)(n.a,{href:"https://github.com/silverqx/TinyORM/tree/main/.github/workflows",children:(0,i.jsx)(n.code,{children:"workflows"})})," how the build is done."]})}),"\n",(0,i.jsxs)(n.p,{children:["Create a folder for the ",(0,i.jsx)(n.code,{children:"CMake"})," build."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:"cd ..\nmkdir HelloWorld-builds-cmake/build-debug\n\ncd HelloWorld"})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:"cd ..\nmkdir -p HelloWorld-builds-cmake/build-debug\n\ncd HelloWorld"})})]}),"\n",(0,i.jsx)(n.h3,{id:"cmake-project",children:"CMake project"}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"CMakeLists.txt"})," file with the following content."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.b,(0,c.OZ)(d.b))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt\${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt\${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\n# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.xj,(0,c.OZ)(d.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt\${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt\${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)`})})]}),"\n",(0,i.jsx)(n.h3,{id:"fetchcontent",children:"FetchContent"}),"\n",(0,i.jsxs)(n.p,{children:["If you don't have cloned and built the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library, or you want to quickly try TinyORM without wasting time with cloning and building the TinyORM library, then you can use CMake's ",(0,i.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/module/FetchContent.html",children:(0,i.jsx)(n.code,{children:"FetchContent"})})," module that will do all of this for you."]}),"\n",(0,i.jsxs)(n.p,{children:["Instead of providing a path by the ",(0,i.jsx)(n.code,{children:"CMAKE_PREFIX_PATH"})," (or using the ",(0,i.jsx)(n.code,{children:"User Package Registry"}),") like in the example below:"]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.b,(0,c.OZ)(d.b))}/TinyORM/TinyORM-builds-cmake/build-debug")`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:`# build tree\nlist(APPEND CMAKE_PREFIX_PATH "${(0,c.nC)(d.xj,(0,c.OZ)(d.xj))}/TinyORM/TinyORM-builds-cmake/build-debug")`})})]}),"\n",(0,i.jsxs)(n.p,{children:["You can use the ",(0,i.jsx)(n.a,{href:"https://cmake.org/cmake/help/latest/module/FetchContent.html",children:(0,i.jsx)(n.code,{children:"FetchContent"})})," module like in the following example."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-cmake",children:"cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# FetchContent method\ninclude(FetchContent)\nFetchContent_Declare(TinyOrm\n GIT_REPOSITORY https://github.com/silverqx/TinyORM.git\n GIT_TAG origin/main\n OVERRIDE_FIND_PACKAGE\n)\n# Here you can configure TinyORM CMake options\nset(MYSQL_PING OFF)\nset(TOM_EXAMPLE ON)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)"})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-cmake",children:"cmake_minimum_required(VERSION VERSION 3.22...3.30 FATAL_ERROR)\n\nproject(HelloWorld LANGUAGES CXX)\n\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\n# FetchContent method\ninclude(FetchContent)\nFetchContent_Declare(TinyOrm\n GIT_REPOSITORY https://github.com/silverqx/TinyORM.git\n GIT_TAG origin/main\n OVERRIDE_FIND_PACKAGE\n)\n# Here you can configure TinyORM CMake options\nset(MYSQL_PING OFF)\nset(TOM_EXAMPLE ON)\n\nadd_executable(HelloWorld\n main.cpp\n)\n\nfind_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)\nfind_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\nfind_package(TinyOrm 0.38.0 CONFIG REQUIRED)\n\ntarget_link_libraries(HelloWorld\n PRIVATE\n Qt${QT_VERSION_MAJOR}::Core\n TinyOrm::TinyOrm\n)"})})]}),"\n",(0,i.jsx)(n.h4,{id:"how-fetchcontent-module-works",children:"How FetchContent module works"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"FetchContent_Declare"})," command is like calling the git clone inside the build folder and then adding a cloned folder in a similar way as the ",(0,i.jsx)(n.code,{children:"add_subdirectory()"})," command does."]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"FetchContent_MakeAvailable()"})," internally calls the ",(0,i.jsx)(n.code,{children:"find_package()"})," command or if you pass the ",(0,i.jsx)(n.code,{children:"OVERRIDE_FIND_PACKAGE"})," argument, then you don't have to call the the ",(0,i.jsx)(n.code,{children:"FetchContent_MakeAvailable"}),", but you must call the ",(0,i.jsx)(n.code,{children:"find_package( x.y.z CONFIG REQUIRED)"})," command manually."]}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["An advantage of the ",(0,i.jsx)(n.code,{children:"OVERRIDE_FIND_PACKAGE"})," argument is that you can call the ",(0,i.jsx)(n.code,{children:"find_package"})," command much later, and you can insert additional configurations between."]})}),"\n",(0,i.jsx)(n.h3,{id:"build-hello-world-cmake",children:"Build Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["Now you are ready to configure ",(0,i.jsx)(n.code,{children:"HelloWorld"})," ",(0,i.jsx)(n.code,{children:"CMake"})," application."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd ../HelloWorld-builds-cmake/build-debug\n"})}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cmake.exe \`\n-S "${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld" \`\n-B "${(0,c.OZ)(d.b)}/HelloWorld/HelloWorld-builds-cmake/build-debug" \`\n-G 'Ninja' \`\n-D CMAKE_BUILD_TYPE:STRING='Debug' \`\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.b)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \`\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \`\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.b)}/tmp/HelloWorld"`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cmake \\\n-S "${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld" \\\n-B "${(0,c.OZ)(d.xj)}/HelloWorld/HelloWorld-builds-cmake/build-debug" \\\n-G 'Ninja' \\\n-D CMAKE_BUILD_TYPE:STRING='Debug' \\\n-D CMAKE_TOOLCHAIN_FILE:FILEPATH="${(0,c.Sn)(d.xj)}/vcpkg/scripts/buildsystems/vcpkg.cmake" \\\n-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF \\\n-D CMAKE_INSTALL_PREFIX:PATH="${(0,c.Sn)(d.xj)}/tmp/TinyORM"`})})]}),"\n",(0,i.jsx)(n.p,{children:"And build."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cmake --build . --target all\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Enable the ",(0,i.jsx)(n.a,{href:"/building/tinyorm#cmake-strict_mode-option",children:(0,i.jsx)(n.code,{children:"TINYORM_STRICT_MODE"})})," environment variable to produce better code and to follow good code practices."]})}),"\n",(0,i.jsx)(n.h3,{id:"execute-hello-world-cmake",children:"Execute Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["Do not forget to add ",(0,i.jsx)(n.code,{children:"TinyOrm0d.dll"})," on the path on Windows and on the ",(0,i.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux, so ",(0,i.jsx)(n.code,{children:"HelloWorld"})," application can find it during execution, as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#tinyorm-on-path-cmake",children:"here"}),"."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,name:"tinyorm-on-path",children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`$env:Path = "${(0,c.OZ)(d.b,!1)}\\TinyORM\\TinyORM-builds-cmake\\build-debug;" + $env:Path`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`export LD_LIBRARY_PATH=${(0,c.OZ)(d.xj)}/TinyORM/TinyORM-builds-cmake/build-debug\${PATH:+:}$PATH`})})]}),"\n",(0,i.jsxs)(n.p,{children:["Execute ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-powershell",children:".\\HelloWorld.exe\n"})})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"./HelloWorld\n"})})})]}),"\n",(0,i.jsx)(n.p,{children:"The output will look like this."}),"\n",(0,i.jsx)(o.A,{className:"language-less",children:'Executed prepared query (6ms, -1 results, 0 affected, tinyorm_default) : select * from posts\n1 "First Post"\n2 "Second Post"'}),"\n",(0,i.jsx)(n.h2,{id:"hello-world-with-qmake",children:"Hello world with qmake"}),"\n",(0,i.jsxs)(n.p,{children:["Create a folder for the ",(0,i.jsx)(n.code,{children:"qmake"})," build."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:d.ux,children:(0,i.jsx)(o.A,{className:"language-powershell",children:`cd ${(0,c.OZ)(d.b)}/HelloWorld\n\nmkdir HelloWorld-builds-qmake`})}),(0,i.jsx)(a.A,{value:d.xj,label:d.gg,children:(0,i.jsx)(o.A,{className:"language-bash",children:`cd ${(0,c.OZ)(d.xj)}/HelloWorld\n\nmkdir HelloWorld-builds-qmake`})})]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.a,{href:"#source-code",children:(0,i.jsx)(n.code,{children:"source code"})})," is the same as for the ",(0,i.jsx)(n.code,{children:"HelloWorld CMake"})," example."]}),"\n",(0,i.jsx)(n.h3,{id:"qmake-project",children:"qmake project"}),"\n",(0,i.jsxs)(n.p,{children:["Create ",(0,i.jsx)(n.code,{children:"HelloWorld.pro"})," qmake file with the following content."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"cd HelloWorld\nvim HelloWorld.pro\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["To paste a source code correctly in ",(0,i.jsx)(n.code,{children:"vim"}),", press ",(0,i.jsx)("kbd",{children:"Shift"})," + ",(0,i.jsx)("kbd",{children:"p"}),"."]})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",metastring:"title='HelloWorld.pro'",children:"QT -= gui\n\nTEMPLATE = app\n\nCONFIG *= cmdline\n\nDEFINES *= PROJECT_TINYORM_HELLOWORLD\n\nSOURCES += $$PWD/main.cpp\n\n# Auto-configure TinyORM library \ud83d\udd25\ninclude($$TINY_MAIN_DIR/TinyORM/qmake/TinyOrm.pri)\n"})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsxs)(n.p,{children:["The exact ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," is crucial in this example because the paths to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," source and build folders are relative."]})}),"\n",(0,i.jsx)(n.admonition,{type:"warning",children:(0,i.jsx)(n.p,{children:"Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!"})}),"\n",(0,i.jsxs)(n.h4,{id:"auto-configure-using-qmake_conf-and-env",children:[(0,i.jsx)(n.code,{children:"Auto-configure"})," using ",(0,i.jsx)(n.code,{children:".qmake.conf"})," and ",(0,i.jsx)(n.code,{children:".env"})]}),"\n",(0,i.jsxs)(n.p,{children:["If you want to have properly configured ",(0,i.jsx)(n.code,{children:"DEFINES"})," (C preprocessor macros) or have Qt headers marked as system headers, then you need to specify a path to the ",(0,i.jsx)(n.code,{children:"TinyORM"})," qmake features (",(0,i.jsx)(n.code,{children:".prf"})," files) which handle this correctly; this path is provided by the ",(0,i.jsx)(n.code,{children:"QMAKEFEATURES"})," variable and can only be set in the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["Read the ",(0,i.jsx)(n.a,{href:"/building/tinyorm#consume-tinyorm-library-qmake",children:"Consume TinyOrm library (qmake)"})," section, as everything that is described in that section applies here as well."]})}),"\n",(0,i.jsxs)(n.p,{children:["Create the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project root folder with the following content."]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",metastring:"title='.qmake.conf'",children:"# Path to the PARENT folder of the TinyORM source folder\nTINY_MAIN_DIR = $$clean_path($$PWD/../../TinyORM/)\n# To find .env and .env.$$QMAKE_PLATFORM files\nTINY_DOTENV_ROOT = $$PWD\n# Path to the current build tree (used to guess the TinyORM build tree)\n#TINY_BUILD_TREE = $$shadowed($$PWD)\n\n# To find .prf files, needed by eg. CONFIG += tiny_system_headers inline/extern_constants\nQMAKEFEATURES *= $$quote($$TINY_MAIN_DIR/TinyORM/qmake/features)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["Then, create a ",(0,i.jsx)("code",{children:".env.(win32|unix|mingw)"})," file in the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," project root folder with the following content."]}),"\n",(0,i.jsxs)(s.A,{groupId:d.vf,children:[(0,i.jsx)(a.A,{value:d.b,label:".env.win32",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSVC2022_64bit-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-windows\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n"})})}),(0,i.jsx)(a.A,{value:d.xj,label:".env.unix",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_clang18_64bit_ccache-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-linux\n\n# Use faster linker\nclang: CONFIG *= use_lld_linker\nelse: CONFIG *= use_gold_linker\n\n# Or use the mold linker\n#QMAKE_LFLAGS *= -fuse-ld=mold\n"})})}),(0,i.jsx)(a.A,{value:"mingw",label:".env.mingw",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-qmake",children:"# Names and values of these qmake variables are crucial, they are used in HelloWorld.pro\n# Please pay special attention to letter casing in paths, especially TinyOrm vs TinyORM!\n\n# Path to the TinyORM build folder\nTINYORM_BUILD_TREE = $$quote($$TINY_MAIN_DIR/TinyORM-builds-qmake/build-TinyORM-Desktop_Qt_6_7_2_MSYS2_UCRT64_clang_64bit-Debug/)\n\n# Path to the vcpkg - range-v3\n# Will use the TINY_VCPKG_ROOT or VCPKG_ROOT environment variable if is empty\nTINY_VCPKG_ROOT = $$clean_path($$PWD/../../../vcpkg/)\nTINY_VCPKG_TRIPLET = x64-mingw-dynamic\n\n# Enable ccache wrapper\n#CONFIG *= ccache\n\n# Use faster linker (for both GCC and Clang)\n# CONFIG *= use_lld_linker does not work on MinGW\nQMAKE_LFLAGS *= -fuse-ld=lld\n"})})})]}),"\n",(0,i.jsxs)(n.p,{children:["Don't forget to update the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and ",(0,i.jsx)(n.code,{children:"TINY_VCPKG_ROOT"})," folder paths to your needs if you are not using the recommended ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:(0,i.jsx)(n.code,{children:"Folders structure"})}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["You can use the ",(0,i.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," if you don't like to specify it manually. Just comment out the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," and uncomment the ",(0,i.jsx)(n.code,{children:"TINY_BUILD_TREE = $$shadowed($$PWD)"})," in the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," file."]}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can entirely avoid the ",(0,i.jsx)(n.code,{children:".env"})," files, just move the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})," to the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," or remove it by help of ",(0,i.jsxs)(n.a,{href:"/building/tinyorm#partial-guessing-of-the-tinyorm_build_tree",children:["Partial guessing of the ",(0,i.jsx)(n.code,{children:"TINYORM_BUILD_TREE"})]})," and set the ",(0,i.jsx)(n.code,{children:"VCPKG_ROOT"})," environment variable at system level as is described in ",(0,i.jsx)(n.a,{href:"/building/tinyorm#set-up-vcpkg-environment",children:(0,i.jsx)(n.code,{children:"Set up vcpkg environment"})}),"."]})}),"\n",(0,i.jsx)(n.admonition,{type:"info",children:(0,i.jsxs)(n.p,{children:["Configuring by the ",(0,i.jsx)(n.code,{children:".qmake.conf"})," and ",(0,i.jsx)(n.code,{children:".env"})," files has one big advantage, which is that you don't have to modify the project files."]})}),"\n",(0,i.jsx)(n.h3,{id:"build-hello-world-qmake",children:"Build Hello world"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["I recommend creating a new ",(0,i.jsx)(n.code,{children:"Session"})," in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"})," as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#open-qtcreator-ide",children:"here"}),"."]})}),"\n",(0,i.jsxs)(n.p,{children:["Now you can open the ",(0,i.jsx)(n.code,{children:"HelloWorld.pro"})," project in the ",(0,i.jsx)(n.code,{children:"QtCreator IDE"}),"."]}),"\n",(0,i.jsxs)(n.p,{children:["This will open the ",(0,i.jsx)(n.code,{children:"Configure Project"})," tab, select some kit and update build folder paths to meet our ",(0,i.jsx)(n.a,{href:"/building/tinyorm#folders-structure",children:"folders structure"})," or like you want."]}),"\n",(0,i.jsx)("img",{src:l(3180).A,alt:"HelloWorld - QtCreator - Configure Project",width:"760"}),"\n",(0,i.jsx)(n.admonition,{type:"tip",children:(0,i.jsxs)(n.p,{children:["You can force the ",(0,i.jsx)(n.code,{children:"QtCreator"})," to generate a build folders structure as is described ",(0,i.jsx)(n.a,{href:"/building/tinyorm#qtcreator-default-build-directory",children:"here"}),"."]})}),"\n",(0,i.jsxs)(n.p,{children:["You are ready to configure build options, hit ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"5"})," to open ",(0,i.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,i.jsx)(n.code,{children:"Build"})," in the left sidebar to open the ",(0,i.jsx)(n.code,{children:"Build Settings"}),", it should look similar to the following picture."]}),"\n",(0,i.jsx)("img",{src:l(7028).A,className:"no-blurry",alt:"HelloWorld - QtCreator - Build Settings",width:"760"}),"\n",(0,i.jsxs)(n.p,{children:["Disable ",(0,i.jsx)(n.code,{children:"QML debugging and profiling"})," and ",(0,i.jsx)(n.code,{children:"Qt Quick Compiler"}),", they are not used."]}),"\n",(0,i.jsxs)(n.p,{children:["In the left sidebar open ",(0,i.jsx)(n.code,{children:"Dependencies"})," and check ",(0,i.jsx)(n.code,{children:"TinyORM"})," project and ",(0,i.jsx)(n.code,{children:"Synchronize configuration"}),", this setting ensures that the current project will be rebuilt correctly when the ",(0,i.jsx)(n.code,{children:"TinyORM"})," library source code changes."]}),"\n",(0,i.jsxs)(n.p,{children:["Everything is ready to build, you can press ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"b"})," to build the project."]}),"\n",(0,i.jsx)(n.h3,{id:"execute-hello-world-qmake",children:"Execute Hello world"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"QtCreator"})," takes care of all the necessary configurations, sets up the build environment correctly, and also prepends dependency libraries on the system path on Windows and on the ",(0,i.jsx)(n.code,{children:"LD_LIBRARY_PATH"})," on Linux."]}),"\n",(0,i.jsxs)(n.p,{children:["The only thing you might want to change is to run the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example in the new terminal window. To do so, hit ",(0,i.jsx)("kbd",{children:"Ctrl"}),"+",(0,i.jsx)("kbd",{children:"5"})," to open the ",(0,i.jsx)(n.code,{children:"Project Settings"})," tab and select ",(0,i.jsx)(n.code,{children:"Run"})," in the left sidebar to open the ",(0,i.jsx)(n.code,{children:"Run Settings"}),", then in the ",(0,i.jsx)(n.code,{children:"Run"})," section select the ",(0,i.jsx)(n.code,{children:"Run in terminal"})," checkbox."]}),"\n",(0,i.jsxs)(n.p,{children:["To execute the ",(0,i.jsx)(n.code,{children:"HelloWorld"})," example press ",(0,i.jsx)("kbd",{children:"Ctrl"})," + ",(0,i.jsx)("kbd",{children:"r"}),"."]}),"\n",(0,i.jsx)(n.p,{children:"The output will look like this."}),"\n",(0,i.jsx)(o.A,{className:"language-less",children:'Executed prepared query (6ms, -1 results, 0 affected, tinyorm_default) : select * from posts\n1 "First Post"\n2 "Second Post"'})]})}function g(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(j,{...e})}):j(e)}},9365:(e,n,l)=>{l.d(n,{A:()=>o});l(6540);var i=l(4164);const r={tabItem:"tabItem_Ymn6"};var t=l(4848);function o(e){let{children:n,hidden:l,className:o}=e;return(0,t.jsx)("div",{role:"tabpanel",className:(0,i.A)(r.tabItem,o),hidden:l,children:n})}},1470:(e,n,l)=>{l.d(n,{A:()=>y});var i=l(6540),r=l(4164),t=l(3104),o=l(6347),a=l(205),s=l(7485),d=l(1682),c=l(679);function h(e){return i.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,i.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:l}=e;return(0,i.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:l,attributes:i,default:r}}=e;return{value:n,label:l,attributes:i,default:r}}))}(l);return function(e){const n=(0,d.X)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,l])}function p(e){let{value:n,tabValues:l}=e;return l.some((e=>e.value===n))}function m(e){let{queryString:n=!1,groupId:l}=e;const r=(0,o.W6)(),t=function(e){let{queryString:n=!1,groupId:l}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!l)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return l??null}({queryString:n,groupId:l});return[(0,s.aZ)(t),(0,i.useCallback)((e=>{if(!t)return;const n=new URLSearchParams(r.location.search);n.set(t,e),r.replace({...r.location,search:n.toString()})}),[t,r])]}function x(e){const{defaultValue:n,queryString:l=!1,groupId:r}=e,t=u(e),[o,s]=(0,i.useState)((()=>function(e){let{defaultValue:n,tabValues:l}=e;if(0===l.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:l}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${l.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const i=l.find((e=>e.default))??l[0];if(!i)throw new Error("Unexpected error: 0 tabValues");return i.value}({defaultValue:n,tabValues:t}))),[d,h]=m({queryString:l,groupId:r}),[x,j]=function(e){let{groupId:n}=e;const l=function(e){return e?`docusaurus.tab.${e}`:null}(n),[r,t]=(0,c.Dv)(l);return[r,(0,i.useCallback)((e=>{l&&t.set(e)}),[l,t])]}({groupId:r}),g=(()=>{const e=d??x;return p({value:e,tabValues:t})?e:null})();(0,a.A)((()=>{g&&s(g)}),[g]);return{selectedValue:o,selectValue:(0,i.useCallback)((e=>{if(!p({value:e,tabValues:t}))throw new Error(`Can't select invalid tab value=${e}`);s(e),h(e),j(e)}),[h,j,t]),tabValues:t}}var j=l(2303);const g={tabList:"tabList__CuJ",tabItem:"tabItem_LNqP"};var b=l(4848);function f(e){let{className:n,block:l,selectedValue:i,selectValue:o,tabValues:a}=e;const s=[],{blockElementScrollPositionUntilNextRender:d}=(0,t.a_)(),c=e=>{const n=e.currentTarget,l=s.indexOf(n),r=a[l].value;r!==i&&(d(n),o(r))},h=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const l=s.indexOf(e.currentTarget)+1;n=s[l]??s[0];break}case"ArrowLeft":{const l=s.indexOf(e.currentTarget)-1;n=s[l]??s[s.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":l},n),children:a.map((e=>{let{value:n,label:l,attributes:t}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:i===n?0:-1,"aria-selected":i===n,ref:e=>s.push(e),onKeyDown:h,onClick:c,...t,className:(0,r.A)("tabs__item",g.tabItem,t?.className,{"tabs__item--active":i===n}),children:l??n},n)}))})}function _(e){let{lazy:n,children:l,selectedValue:r}=e;const t=(Array.isArray(l)?l:[l]).filter(Boolean);if(n){const e=t.find((e=>e.props.value===r));return e?(0,i.cloneElement)(e,{className:"margin-top--md"}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:t.map(((e,n)=>(0,i.cloneElement)(e,{key:n,hidden:e.props.value!==r})))})}function T(e){const n=x(e);return(0,b.jsxs)("div",{className:(0,r.A)("tabs-container",g.tabList),children:[(0,b.jsx)(f,{...n,...e}),(0,b.jsx)(_,{...n,...e})]})}function y(e){const n=(0,j.A)();return(0,b.jsx)(T,{...e,children:h(e.children)},String(n))}},7324:(e,n,l)=>{l.d(n,{$E:()=>j,A3:()=>b,CW:()=>g,Dx:()=>c,F4:()=>u,Fi:()=>d,J_:()=>y,LQ:()=>f,Lf:()=>k,OO:()=>r,Q7:()=>_,b:()=>a,cy:()=>s,gg:()=>m,kl:()=>p,os:()=>h,pW:()=>t,ux:()=>x,vf:()=>i,xj:()=>o,xt:()=>T});const i="shell",r="database",t="application",o="bash",a="pwsh",s="zsh",d="maria",c="mysql",h="postgres",u="sqlite",p="application",m="bash",x="pwsh",j="zsh",g="MariaDB",b="MySQL",f="PostgreSQL",_="SQLite",T="tinyorm.org",y="$HOME/Code/c/",k="$env:USERPROFILE\\Code\\c\\"},6362:(e,n,l)=>{l.d(n,{A:()=>t});var i=l(6540),r=l(1838);function t(){const e=(0,i.useContext)(r.A);if(null!=e)return e;throw new Error("useRootFolderContext is used outside of Layout component.")}},6694:(e,n,l)=>{l.d(n,{OZ:()=>s,Sn:()=>o,T3:()=>c,bw:()=>d,nC:()=>h,np:()=>a});var i=l(6362),r=l(2303),t=l(7324);const o=function(e,n){return void 0===n&&(n=!0),u((0,i.A)().rootFolder[e]??d(e),e,n)},a=()=>(0,i.A)().rootFolder[t.pW]??d(t.pW),s=function(e,n){if(void 0===n&&(n=!0),null==e)throw new Error("The groupId in the applicationFolderPath() can not be empty.");const l=n||e!==t.b?"/":"\\";return u(o(e)+l+a(),e,n)};function d(e){if(null==e)throw new Error("The groupId in the folderDefaultValue() can not be empty.");if(!(0,r.A)())return"";switch(e){case t.b:return t.Lf;case t.xj:return t.J_;case t.pW:return t.xt;default:throw new Error(`No default value for '${e}' groupId in the folderDefaultValue().`)}}function c(e){return e===t.pW}function h(e,n){if(null==n||""===n)return n;const l="$ENV{$1}$2";switch(e){case t.b:return m(n).replace(/\$env:(.+?)(\/.*)/,l);case t.xj:return n.replace(/\$(.+?)(\/.*)/,l);default:throw new Error(`Unsupported shell type '${e}' in the convertToCmakeEnvVariable().`)}}function u(e,n,l){if(void 0===l&&(l=!0),null==e||""===e)return e;if(n!==t.b)return p(e);const i=p(e);return l?m(i):function(e){return null==e||""===e?e:e.replaceAll(/\/+/g,"\\")}(i)}function p(e){return null==e||""===e?e:e.replace(/[/\\]+$/,"")}function m(e){return null==e||""===e?e:e.replaceAll(/\\+(?! )/g,"/")}},7028:(e,n,l)=>{l.d(n,{A:()=>i});const i=l.p+"assets/images/qmake-build_settings-ebdc6c0c056d11462096ff10cba682a1.png"},3180:(e,n,l)=>{l.d(n,{A:()=>i});const i=l.p+"assets/images/qmake-configure_project-8caf87e6af4452f0c28bd15c85c392fc.png"}}]); \ No newline at end of file diff --git a/assets/js/main.6eeb88ae.js b/assets/js/main.6eeb88ae.js new file mode 100644 index 000000000..0c8a10ee7 --- /dev/null +++ b/assets/js/main.6eeb88ae.js @@ -0,0 +1,2 @@ +/*! For license information please see main.6eeb88ae.js.LICENSE.txt */ +(self.webpackChunktinyorm_org=self.webpackChunktinyorm_org||[]).push([[792],{3219:(e,t,n)=>{"use strict";n.d(t,{Bc:()=>g,E8:()=>Hn,a1:()=>$n});var r=n(6540);n(961);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw o}}return a}}(e,t)||d(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||d(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function D(e){for(var t=1;t=3||2===n&&r>=4||1===n&&r>=10);function a(t,n,r){if(o&&void 0!==r){var a=r[0].__autocomplete_algoliaCredentials,i={"X-Algolia-Application-Id":a.appId,"X-Algolia-API-Key":a.apiKey};e.apply(void 0,[t].concat(R(n),[{headers:i}]))}else e.apply(void 0,[t].concat(R(n)))}return{init:function(t,n){e("init",{appId:t,apiKey:n})},setUserToken:function(t){e("setUserToken",t)},clickedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&a("clickedObjectIDsAfterSearch",M(t),t[0].items)},clickedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&a("clickedObjectIDs",M(t),t[0].items)},clickedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["clickedFilters"].concat(n))},convertedObjectIDsAfterSearch:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&a("convertedObjectIDsAfterSearch",M(t),t[0].items)},convertedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&a("convertedObjectIDs",M(t),t[0].items)},convertedFilters:function(){for(var t=arguments.length,n=new Array(t),r=0;r0&&e.apply(void 0,["convertedFilters"].concat(n))},viewedObjectIDs:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&t.reduce((function(e,t){var n=t.items,r=N(t,C);return[].concat(R(e),R(function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,n=[],r=0;r0&&e.apply(void 0,["viewedFilters"].concat(n))}}}function U(e){var t=e.items.reduce((function(e,t){var n;return e[t.__autocomplete_indexName]=(null!==(n=e[t.__autocomplete_indexName])&&void 0!==n?n:[]).concat(t),e}),{});return Object.keys(t).map((function(e){return{index:e,items:t[e],algoliaSource:["autocomplete"]}}))}function B(e){return e.objectID&&e.__autocomplete_indexName&&e.__autocomplete_queryID}function z(e){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},z(e)}function $(e){return function(e){if(Array.isArray(e))return H(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return H(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?H(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&K({onItemsChange:r,items:n,insights:l,state:t}))}}),0);return{name:"aa.algoliaInsightsPlugin",subscribe:function(e){var t=e.setContext,n=e.onSelect,r=e.onActive;i("addAlgoliaAgent","insights-plugin"),t({algoliaInsightsPlugin:{__algoliaSearchParameters:{clickAnalytics:!0},insights:l}}),n((function(e){var t=e.item,n=e.state,r=e.event;B(t)&&o({state:n,event:r,insights:l,item:t,insightsEvents:[G({eventName:"Item Selected"},T({item:t,items:s.current}))]})})),r((function(e){var t=e.item,n=e.state,r=e.event;B(t)&&a({state:n,event:r,insights:l,item:t,insightsEvents:[G({eventName:"Item Active"},T({item:t,items:s.current}))]})}))},onStateChange:function(e){var t=e.state;c({state:t})},__autocomplete_pluginOptions:e}}function X(e,t){var n=t;return{then:function(t,r){return X(e.then(Z(t,n,e),Z(r,n,e)),n)},catch:function(t){return X(e.catch(Z(t,n,e)),n)},finally:function(t){return t&&n.onCancelList.push(t),X(e.finally(Z(t&&function(){return n.onCancelList=[],t()},n,e)),n)},cancel:function(){n.isCanceled=!0;var e=n.onCancelList;n.onCancelList=[],e.forEach((function(e){e()}))},isCanceled:function(){return!0===n.isCanceled}}}function Q(e){return X(e,{isCanceled:!1,onCancelList:[]})}function Z(e,t,n){return e?function(n){return t.isCanceled?n:e(n)}:n}function J(e,t,n,r){if(!n)return null;if(e<0&&(null===t||null!==r&&0===t))return n+e;var o=(null===t?-1:t)+e;return o<=-1||o>=n?null===r?null:0:o}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n0},reshape:function(e){return e.sources}},e),{},{id:null!==(n=e.id)&&void 0!==n?n:"autocomplete-".concat(S++),plugins:o,initialState:ge({activeItemId:null,query:"",completion:null,collections:[],isOpen:!1,status:"idle",context:{}},e.initialState),onStateChange:function(t){var n;null===(n=e.onStateChange)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onStateChange)||void 0===n?void 0:n.call(e,t)}))},onSubmit:function(t){var n;null===(n=e.onSubmit)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onSubmit)||void 0===n?void 0:n.call(e,t)}))},onReset:function(t){var n;null===(n=e.onReset)||void 0===n||n.call(e,t),o.forEach((function(e){var n;return null===(n=e.onReset)||void 0===n?void 0:n.call(e,t)}))},getSources:function(n){return Promise.all([].concat(function(e){return function(e){if(Array.isArray(e))return me(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?me(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(o.map((function(e){return e.getSources}))),[e.getSources]).filter(Boolean).map((function(e){return function(e,t){var n=[];return Promise.resolve(e(t)).then((function(e){return Promise.all(e.filter((function(e){return Boolean(e)})).map((function(e){if(e.sourceId,n.includes(e.sourceId))throw new Error("[Autocomplete] The `sourceId` ".concat(JSON.stringify(e.sourceId)," is not unique."));n.push(e.sourceId);var t={getItemInputValue:function(e){return e.state.query},getItemUrl:function(){},onSelect:function(e){(0,e.setIsOpen)(!1)},onActive:k,onResolve:k};Object.keys(t).forEach((function(e){t[e].__default=!0}));var r=te(te({},t),e);return Promise.resolve(r)})))}))}(e,n)}))).then((function(e){return v(e)})).then((function(e){return e.map((function(e){return ge(ge({},e),{},{onSelect:function(n){e.onSelect(n),t.forEach((function(e){var t;return null===(t=e.onSelect)||void 0===t?void 0:t.call(e,n)}))},onActive:function(n){e.onActive(n),t.forEach((function(e){var t;return null===(t=e.onActive)||void 0===t?void 0:t.call(e,n)}))},onResolve:function(n){e.onResolve(n),t.forEach((function(e){var t;return null===(t=e.onResolve)||void 0===t?void 0:t.call(e,n)}))}})}))}))},navigator:ge({navigate:function(e){var t=e.itemUrl;r.location.assign(t)},navigateNewTab:function(e){var t=e.itemUrl,n=r.open(t,"_blank","noopener");null==n||n.focus()},navigateNewWindow:function(e){var t=e.itemUrl;r.open(t,"_blank","noopener")}},e.navigator)})}function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function Se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ee(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,Pe);Ue&&o.environment.clearTimeout(Ue);var c=s.setCollections,u=s.setIsOpen,d=s.setQuery,f=s.setActiveItemId,p=s.setStatus;if(d(a),f(o.defaultActiveItemId),!a&&!1===o.openOnFocus){var m,h=l.getState().collections.map((function(e){return Le(Le({},e),{},{items:[]})}));p("idle"),c(h),u(null!==(m=r.isOpen)&&void 0!==m?m:o.shouldPanelOpen({state:l.getState()}));var g=Q(Be(h).then((function(){return Promise.resolve()})));return l.pendingRequests.add(g)}p("loading"),Ue=o.environment.setTimeout((function(){p("stalled")}),o.stallThreshold);var y=Q(Be(o.getSources(Le({query:a,refresh:i,state:l.getState()},s)).then((function(e){return Promise.all(e.map((function(e){return Promise.resolve(e.getItems(Le({query:a,refresh:i,state:l.getState()},s))).then((function(t){return function(e,t,n){if(o=e,Boolean(null==o?void 0:o.execute)){var r="algolia"===e.requesterId?Object.assign.apply(Object,[{}].concat(xe(Object.keys(n.context).map((function(e){var t;return null===(t=n.context[e])||void 0===t?void 0:t.__algoliaSearchParameters}))))):{};return Oe(Oe({},e),{},{requests:e.queries.map((function(n){return{query:"algolia"===e.requesterId?Oe(Oe({},n),{},{params:Oe(Oe({},r),n.params)}):n,sourceId:t,transformResponse:e.transformResponse}}))})}var o;return{items:e,sourceId:t}}(t,e.sourceId,l.getState())}))}))).then(Ie).then((function(t){return function(e,t,n){return t.map((function(t){var r,o=e.filter((function(e){return e.sourceId===t.sourceId})),a=o.map((function(e){return e.items})),i=o[0].transformResponse,l=i?i({results:r=a,hits:r.map((function(e){return e.hits})).filter(Boolean),facetHits:r.map((function(e){var t;return null===(t=e.facetHits)||void 0===t?void 0:t.map((function(e){return{label:e.value,count:e.count,_highlightResult:{label:{value:e.highlighted}}}}))})).filter(Boolean)}):a;return t.onResolve({source:t,results:a,items:l,state:n.getState()}),l.every(Boolean),'The `getItems` function from source "'.concat(t.sourceId,'" must return an array of items but returned ').concat(JSON.stringify(void 0),".\n\nDid you forget to return items?\n\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems"),{source:t,items:l}}))}(t,e,l)})).then((function(e){return function(e){var t=e.props,n=e.state,r=e.collections.reduce((function(e,t){return Ee(Ee({},e),{},we({},t.source.sourceId,Ee(Ee({},t.source),{},{getItems:function(){return v(t.items)}})))}),{}),o=t.plugins.reduce((function(e,t){return t.reshape?t.reshape(e):e}),{sourcesBySourceId:r,state:n}).sourcesBySourceId;return v(t.reshape({sourcesBySourceId:o,sources:Object.values(o),state:n})).filter(Boolean).map((function(e){return{source:e,items:e.getItems()}}))}({collections:e,props:o,state:l.getState()})}))})))).then((function(e){var n;p("idle"),c(e);var d=o.shouldPanelOpen({state:l.getState()});u(null!==(n=r.isOpen)&&void 0!==n?n:o.openOnFocus&&!a&&d||d);var f=oe(l.getState());if(null!==l.getState().activeItemId&&f){var m=f.item,h=f.itemInputValue,g=f.itemUrl,y=f.source;y.onActive(Le({event:t,item:m,itemInputValue:h,itemUrl:g,refresh:i,source:y,state:l.getState()},s))}})).finally((function(){p("idle"),Ue&&o.environment.clearTimeout(Ue)}));return l.pendingRequests.add(y)}function $e(e){return $e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$e(e)}var He=["event","props","refresh","store"];function Ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ge(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function at(e){var t=e.props,n=e.refresh,r=e.store,o=ot(e,Ke),a=function(e,t){return void 0!==t?"".concat(e,"-").concat(t):e};return{getEnvironmentProps:function(e){var n=e.inputElement,o=e.formElement,a=e.panelElement;function i(e){!r.getState().isOpen&&r.pendingRequests.isEmpty()||e.target===n||!1===[o,a].some((function(t){return(n=t)===(r=e.target)||n.contains(r);var n,r}))&&(r.dispatch("blur",null),t.debug||r.pendingRequests.cancelAll())}return nt({onTouchStart:i,onMouseDown:i,onTouchMove:function(e){!1!==r.getState().isOpen&&n===t.environment.document.activeElement&&e.target!==n&&n.blur()}},ot(e,Ye))},getRootProps:function(e){return nt({role:"combobox","aria-expanded":r.getState().isOpen,"aria-haspopup":"listbox","aria-owns":r.getState().isOpen?"".concat(t.id,"-list"):void 0,"aria-labelledby":"".concat(t.id,"-label")},e)},getFormProps:function(e){return e.inputElement,nt({action:"",noValidate:!0,role:"search",onSubmit:function(a){var i;a.preventDefault(),t.onSubmit(nt({event:a,refresh:n,state:r.getState()},o)),r.dispatch("submit",null),null===(i=e.inputElement)||void 0===i||i.blur()},onReset:function(a){var i;a.preventDefault(),t.onReset(nt({event:a,refresh:n,state:r.getState()},o)),r.dispatch("reset",null),null===(i=e.inputElement)||void 0===i||i.focus()}},ot(e,Xe))},getLabelProps:function(e){var n=e||{},r=n.sourceIndex,o=ot(n,Ze);return nt({htmlFor:"".concat(a(t.id,r),"-input"),id:"".concat(a(t.id,r),"-label")},o)},getInputProps:function(e){var a;function i(e){(t.openOnFocus||Boolean(r.getState().query))&&ze(nt({event:e,props:t,query:r.getState().completion||r.getState().query,refresh:n,store:r},o)),r.dispatch("focus",null)}var l=e||{},s=(l.inputElement,l.maxLength),c=void 0===s?512:s,u=ot(l,Qe),d=oe(r.getState()),f=function(e){return Boolean(e&&e.match(ae))}((null===(a=t.environment.navigator)||void 0===a?void 0:a.userAgent)||""),p=null!=d&&d.itemUrl&&!f?"go":"search";return nt({"aria-autocomplete":"both","aria-activedescendant":r.getState().isOpen&&null!==r.getState().activeItemId?"".concat(t.id,"-item-").concat(r.getState().activeItemId):void 0,"aria-controls":r.getState().isOpen?"".concat(t.id,"-list"):void 0,"aria-labelledby":"".concat(t.id,"-label"),value:r.getState().completion||r.getState().query,id:"".concat(t.id,"-input"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",enterKeyHint:p,spellCheck:"false",autoFocus:t.autoFocus,placeholder:t.placeholder,maxLength:c,type:"search",onChange:function(e){ze(nt({event:e,props:t,query:e.currentTarget.value.slice(0,c),refresh:n,store:r},o))},onKeyDown:function(e){!function(e){var t=e.event,n=e.props,r=e.refresh,o=e.store,a=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,He);if("ArrowUp"===t.key||"ArrowDown"===t.key){var i=function(){var e=n.environment.document.getElementById("".concat(n.id,"-item-").concat(o.getState().activeItemId));e&&(e.scrollIntoViewIfNeeded?e.scrollIntoViewIfNeeded(!1):e.scrollIntoView(!1))},l=function(){var e=oe(o.getState());if(null!==o.getState().activeItemId&&e){var n=e.item,i=e.itemInputValue,l=e.itemUrl,s=e.source;s.onActive(Ge({event:t,item:n,itemInputValue:i,itemUrl:l,refresh:r,source:s,state:o.getState()},a))}};t.preventDefault(),!1===o.getState().isOpen&&(n.openOnFocus||Boolean(o.getState().query))?ze(Ge({event:t,props:n,query:o.getState().query,refresh:r,store:o},a)).then((function(){o.dispatch(t.key,{nextActiveItemId:n.defaultActiveItemId}),l(),setTimeout(i,0)})):(o.dispatch(t.key,{}),l(),i())}else if("Escape"===t.key)t.preventDefault(),o.dispatch(t.key,null),o.pendingRequests.cancelAll();else if("Tab"===t.key)o.dispatch("blur",null),o.pendingRequests.cancelAll();else if("Enter"===t.key){if(null===o.getState().activeItemId||o.getState().collections.every((function(e){return 0===e.items.length})))return void(n.debug||o.pendingRequests.cancelAll());t.preventDefault();var s=oe(o.getState()),c=s.item,u=s.itemInputValue,d=s.itemUrl,f=s.source;if(t.metaKey||t.ctrlKey)void 0!==d&&(f.onSelect(Ge({event:t,item:c,itemInputValue:u,itemUrl:d,refresh:r,source:f,state:o.getState()},a)),n.navigator.navigateNewTab({itemUrl:d,item:c,state:o.getState()}));else if(t.shiftKey)void 0!==d&&(f.onSelect(Ge({event:t,item:c,itemInputValue:u,itemUrl:d,refresh:r,source:f,state:o.getState()},a)),n.navigator.navigateNewWindow({itemUrl:d,item:c,state:o.getState()}));else if(t.altKey);else{if(void 0!==d)return f.onSelect(Ge({event:t,item:c,itemInputValue:u,itemUrl:d,refresh:r,source:f,state:o.getState()},a)),void n.navigator.navigate({itemUrl:d,item:c,state:o.getState()});ze(Ge({event:t,nextState:{isOpen:!1},props:n,query:u,refresh:r,store:o},a)).then((function(){f.onSelect(Ge({event:t,item:c,itemInputValue:u,itemUrl:d,refresh:r,source:f,state:o.getState()},a))}))}}}(nt({event:e,props:t,refresh:n,store:r},o))},onFocus:i,onBlur:k,onClick:function(n){e.inputElement!==t.environment.document.activeElement||r.getState().isOpen||i(n)}},u)},getPanelProps:function(e){return nt({onMouseDown:function(e){e.preventDefault()},onMouseLeave:function(){r.dispatch("mouseleave",null)}},e)},getListProps:function(e){var n=e||{},r=n.sourceIndex,o=ot(n,Je);return nt({role:"listbox","aria-labelledby":"".concat(a(t.id,r),"-label"),id:"".concat(a(t.id,r),"-list")},o)},getItemProps:function(e){var i=e.item,l=e.source,s=e.sourceIndex,c=ot(e,et);return nt({id:"".concat(a(t.id,s),"-item-").concat(i.__autocomplete_id),role:"option","aria-selected":r.getState().activeItemId===i.__autocomplete_id,onMouseMove:function(e){if(i.__autocomplete_id!==r.getState().activeItemId){r.dispatch("mousemove",i.__autocomplete_id);var t=oe(r.getState());if(null!==r.getState().activeItemId&&t){var a=t.item,l=t.itemInputValue,s=t.itemUrl,c=t.source;c.onActive(nt({event:e,item:a,itemInputValue:l,itemUrl:s,refresh:n,source:c,state:r.getState()},o))}}},onMouseDown:function(e){e.preventDefault()},onClick:function(e){var a=l.getItemInputValue({item:i,state:r.getState()}),s=l.getItemUrl({item:i,state:r.getState()});(s?Promise.resolve():ze(nt({event:e,nextState:{isOpen:!1},props:t,query:a,refresh:n,store:r},o))).then((function(){l.onSelect(nt({event:e,item:i,itemInputValue:a,itemUrl:s,refresh:n,source:l,state:r.getState()},o))}))}},c)}}}function it(e){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},it(e)}function lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function st(e){for(var t=1;t0&&r.createElement("div",{className:"DocSearch-NoResults-Prefill-List"},r.createElement("p",{className:"DocSearch-Help"},c,":"),r.createElement("ul",null,h.slice(0,3).reduce((function(e,t){return[].concat(u(e),[r.createElement("li",{key:t},r.createElement("button",{className:"DocSearch-Prefill",key:t,type:"button",onClick:function(){o.setQuery(t.toLowerCase()+" "),o.refresh(),o.inputRef.current.focus()}},t))])}),[]))),o.getMissingResultsUrl&&r.createElement("p",{className:"DocSearch-Help"},"".concat(f," "),r.createElement("a",{href:o.getMissingResultsUrl({query:o.state.query}),target:"_blank",rel:"noopener noreferrer"},m)))}var Bt=["hit","attribute","tagName"];function zt(e,t){return t.split(".").reduce((function(e,t){return null!=e&&e[t]?e[t]:null}),e)}function $t(e){var t=e.hit,n=e.attribute,o=e.tagName,i=void 0===o?"span":o,l=s(e,Bt);return(0,r.createElement)(i,a(a({},l),{},{dangerouslySetInnerHTML:{__html:zt(t,"_snippetResult.".concat(n,".value"))||zt(t,n)}}))}function Ht(e){return e.collection&&0!==e.collection.items.length?r.createElement("section",{className:"DocSearch-Hits"},r.createElement("div",{className:"DocSearch-Hit-source"},e.title),r.createElement("ul",e.getListProps(),e.collection.items.map((function(t,n){return r.createElement(Vt,l({key:[e.title,t.objectID].join(":"),item:t,index:n},e))})))):null}function Vt(e){var t=e.item,n=e.index,o=e.renderIcon,a=e.renderAction,i=e.getItemProps,s=e.onItemClick,u=e.collection,d=e.hitComponent,f=c(r.useState(!1),2),p=f[0],m=f[1],h=c(r.useState(!1),2),g=h[0],y=h[1],b=r.useRef(null),v=d;return r.createElement("li",l({className:["DocSearch-Hit",t.__docsearch_parent&&"DocSearch-Hit--Child",p&&"DocSearch-Hit--deleting",g&&"DocSearch-Hit--favoriting"].filter(Boolean).join(" "),onTransitionEnd:function(){b.current&&b.current()}},i({item:t,source:u.source,onClick:function(e){s(t,e)}})),r.createElement(v,{hit:t},r.createElement("div",{className:"DocSearch-Hit-Container"},o({item:t,index:n}),t.hierarchy[t.type]&&"lvl1"===t.type&&r.createElement("div",{className:"DocSearch-Hit-content-wrapper"},r.createElement($t,{className:"DocSearch-Hit-title",hit:t,attribute:"hierarchy.lvl1"}),t.content&&r.createElement($t,{className:"DocSearch-Hit-path",hit:t,attribute:"content"})),t.hierarchy[t.type]&&("lvl2"===t.type||"lvl3"===t.type||"lvl4"===t.type||"lvl5"===t.type||"lvl6"===t.type)&&r.createElement("div",{className:"DocSearch-Hit-content-wrapper"},r.createElement($t,{className:"DocSearch-Hit-title",hit:t,attribute:"hierarchy.".concat(t.type)}),r.createElement($t,{className:"DocSearch-Hit-path",hit:t,attribute:"hierarchy.lvl1"})),"content"===t.type&&r.createElement("div",{className:"DocSearch-Hit-content-wrapper"},r.createElement($t,{className:"DocSearch-Hit-title",hit:t,attribute:"content"}),r.createElement($t,{className:"DocSearch-Hit-path",hit:t,attribute:"hierarchy.lvl1"})),a({item:t,runDeleteTransition:function(e){m(!0),b.current=e},runFavoriteTransition:function(e){y(!0),b.current=e}}))))}function Gt(e,t,n){return e.reduce((function(e,r){var o=t(r);return e.hasOwnProperty(o)||(e[o]=[]),e[o].length<(n||5)&&e[o].push(r),e}),{})}function qt(e){return e}function Wt(e){return 1===e.button||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}function Kt(){}var Yt=/(|<\/mark>)/g,Xt=RegExp(Yt.source);function Qt(e){var t,n,r=e;if(!r.__docsearch_parent&&!e._highlightResult)return e.hierarchy.lvl0;var o=((r.__docsearch_parent?null===(t=r.__docsearch_parent)||void 0===t||null===(t=t._highlightResult)||void 0===t||null===(t=t.hierarchy)||void 0===t?void 0:t.lvl0:null===(n=e._highlightResult)||void 0===n||null===(n=n.hierarchy)||void 0===n?void 0:n.lvl0)||{}).value;return o&&Xt.test(o)?o.replace(Yt,""):o}function Zt(e){return r.createElement("div",{className:"DocSearch-Dropdown-Container"},e.state.collections.map((function(t){if(0===t.items.length)return null;var n=Qt(t.items[0]);return r.createElement(Ht,l({},e,{key:t.source.sourceId,title:n,collection:t,renderIcon:function(e){var n,o=e.item,a=e.index;return r.createElement(r.Fragment,null,o.__docsearch_parent&&r.createElement("svg",{className:"DocSearch-Hit-Tree",viewBox:"0 0 24 54"},r.createElement("g",{stroke:"currentColor",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},o.__docsearch_parent!==(null===(n=t.items[a+1])||void 0===n?void 0:n.__docsearch_parent)?r.createElement("path",{d:"M8 6v21M20 27H8.3"}):r.createElement("path",{d:"M8 6v42M20 27H8.3"}))),r.createElement("div",{className:"DocSearch-Hit-icon"},r.createElement(Rt,{type:o.type})))},renderAction:function(){return r.createElement("div",{className:"DocSearch-Hit-action"},r.createElement(Ct,null))}}))})),e.resultsFooterComponent&&r.createElement("section",{className:"DocSearch-HitsFooter"},r.createElement(e.resultsFooterComponent,{state:e.state})))}var Jt=["translations"];function en(e){var t=e.translations,n=void 0===t?{}:t,o=s(e,Jt),a=n.recentSearchesTitle,i=void 0===a?"Recent":a,c=n.noRecentSearchesText,u=void 0===c?"No recent searches":c,d=n.saveRecentSearchButtonTitle,f=void 0===d?"Save this search":d,p=n.removeRecentSearchButtonTitle,m=void 0===p?"Remove this search from history":p,h=n.favoriteSearchesTitle,g=void 0===h?"Favorite":h,y=n.removeFavoriteSearchButtonTitle,b=void 0===y?"Remove this search from favorites":y;return"idle"===o.state.status&&!1===o.hasCollections?o.disableUserPersonalization?null:r.createElement("div",{className:"DocSearch-StartScreen"},r.createElement("p",{className:"DocSearch-Help"},u)):!1===o.hasCollections?null:r.createElement("div",{className:"DocSearch-Dropdown-Container"},r.createElement(Ht,l({},o,{title:i,collection:o.state.collections[0],renderIcon:function(){return r.createElement("div",{className:"DocSearch-Hit-icon"},r.createElement(xt,null))},renderAction:function(e){var t=e.item,n=e.runFavoriteTransition,a=e.runDeleteTransition;return r.createElement(r.Fragment,null,r.createElement("div",{className:"DocSearch-Hit-action"},r.createElement("button",{className:"DocSearch-Hit-action-button",title:f,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),n((function(){o.favoriteSearches.add(t),o.recentSearches.remove(t),o.refresh()}))}},r.createElement(Lt,null))),r.createElement("div",{className:"DocSearch-Hit-action"},r.createElement("button",{className:"DocSearch-Hit-action-button",title:m,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),a((function(){o.recentSearches.remove(t),o.refresh()}))}},r.createElement(At,null))))}})),r.createElement(Ht,l({},o,{title:g,collection:o.state.collections[1],renderIcon:function(){return r.createElement("div",{className:"DocSearch-Hit-icon"},r.createElement(Lt,null))},renderAction:function(e){var t=e.item,n=e.runDeleteTransition;return r.createElement("div",{className:"DocSearch-Hit-action"},r.createElement("button",{className:"DocSearch-Hit-action-button",title:b,type:"submit",onClick:function(e){e.preventDefault(),e.stopPropagation(),n((function(){o.favoriteSearches.remove(t),o.refresh()}))}},r.createElement(At,null)))}})))}var tn=["translations"],nn=r.memo((function(e){var t=e.translations,n=void 0===t?{}:t,o=s(e,tn);if("error"===o.state.status)return r.createElement(Mt,{translations:null==n?void 0:n.errorScreen});var a=o.state.collections.some((function(e){return e.items.length>0}));return o.state.query?!1===a?r.createElement(Ut,l({},o,{translations:null==n?void 0:n.noResultsScreen})):r.createElement(Zt,o):r.createElement(en,l({},o,{hasCollections:a,translations:null==n?void 0:n.startScreen}))}),(function(e,t){return"loading"===t.state.status||"stalled"===t.state.status})),rn=["translations"];function on(e){var t=e.translations,n=void 0===t?{}:t,o=s(e,rn),a=n.resetButtonTitle,i=void 0===a?"Clear the query":a,c=n.resetButtonAriaLabel,u=void 0===c?"Clear the query":c,d=n.cancelButtonText,f=void 0===d?"Cancel":d,p=n.cancelButtonAriaLabel,h=void 0===p?"Cancel":p,g=n.searchInputLabel,y=void 0===g?"Search":g,b=o.getFormProps({inputElement:o.inputRef.current}).onReset;return r.useEffect((function(){o.autoFocus&&o.inputRef.current&&o.inputRef.current.focus()}),[o.autoFocus,o.inputRef]),r.useEffect((function(){o.isFromSelection&&o.inputRef.current&&o.inputRef.current.select()}),[o.isFromSelection,o.inputRef]),r.createElement(r.Fragment,null,r.createElement("form",{className:"DocSearch-Form",onSubmit:function(e){e.preventDefault()},onReset:b},r.createElement("label",l({className:"DocSearch-MagnifierLabel"},o.getLabelProps()),r.createElement(m,null),r.createElement("span",{className:"DocSearch-VisuallyHiddenForAccessibility"},y)),r.createElement("div",{className:"DocSearch-LoadingIndicator"},r.createElement(Tt,null)),r.createElement("input",l({className:"DocSearch-Input",ref:o.inputRef},o.getInputProps({inputElement:o.inputRef.current,autoFocus:o.autoFocus,maxLength:64}))),r.createElement("button",{type:"reset",title:i,className:"DocSearch-Reset","aria-label":u,hidden:!o.state.query},r.createElement(At,null))),r.createElement("button",{className:"DocSearch-Cancel",type:"reset","aria-label":h,onClick:o.onClose},f))}var an=["_highlightResult","_snippetResult"];function ln(e){var t=e.key,n=e.limit,r=void 0===n?5:n,o=function(e){return!1===function(){var e="__TEST_KEY__";try{return localStorage.setItem(e,""),localStorage.removeItem(e),!0}catch(e){return!1}}()?{setItem:function(){},getItem:function(){return[]}}:{setItem:function(t){return window.localStorage.setItem(e,JSON.stringify(t))},getItem:function(){var t=window.localStorage.getItem(e);return t?JSON.parse(t):[]}}}(t),a=o.getItem().slice(0,r);return{add:function(e){var t=e,n=(t._highlightResult,t._snippetResult,s(t,an)),i=a.findIndex((function(e){return e.objectID===n.objectID}));i>-1&&a.splice(i,1),a.unshift(n),a=a.slice(0,r),o.setItem(a)},remove:function(e){a=a.filter((function(t){return t.objectID!==e.objectID})),o.setItem(a)},getAll:function(){return a}}}function sn(e){const t=`algoliasearch-client-js-${e.key}`;let n;const r=()=>(void 0===n&&(n=e.localStorage||window.localStorage),n),o=()=>JSON.parse(r().getItem(t)||"{}"),a=e=>{r().setItem(t,JSON.stringify(e))};return{get:(t,n,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{(()=>{const t=e.timeToLive?1e3*e.timeToLive:null,n=o(),r=Object.fromEntries(Object.entries(n).filter((([,e])=>void 0!==e.timestamp)));if(a(r),!t)return;const i=Object.fromEntries(Object.entries(r).filter((([,e])=>{const n=(new Date).getTime();return!(e.timestamp+tPromise.all([e?e.value:n(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,n)=>Promise.resolve().then((()=>{const a=o();return a[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:n},r().setItem(t,JSON.stringify(a)),n})),delete:e=>Promise.resolve().then((()=>{const n=o();delete n[JSON.stringify(e)],r().setItem(t,JSON.stringify(n))})),clear:()=>Promise.resolve().then((()=>{r().removeItem(t)}))}}function cn(e){const t=[...e.caches],n=t.shift();return void 0===n?{get:(e,t,n={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,n.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,r,o={miss:()=>Promise.resolve()})=>n.get(e,r,o).catch((()=>cn({caches:t}).get(e,r,o))),set:(e,r)=>n.set(e,r).catch((()=>cn({caches:t}).set(e,r))),delete:e=>n.delete(e).catch((()=>cn({caches:t}).delete(e))),clear:()=>n.clear().catch((()=>cn({caches:t}).clear()))}}function un(e={serializable:!0}){let t={};return{get(n,r,o={miss:()=>Promise.resolve()}){const a=JSON.stringify(n);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);const i=r(),l=o&&o.miss||(()=>Promise.resolve());return i.then((e=>l(e))).then((()=>i))},set:(n,r)=>(t[JSON.stringify(n)]=e.serializable?JSON.stringify(r):r,Promise.resolve(r)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}function dn(e){let t=e.length-1;for(;t>0;t--){const n=Math.floor(Math.random()*(t+1)),r=e[t];e[t]=e[n],e[n]=r}return e}function fn(e,t){return t?(Object.keys(t).forEach((n=>{e[n]=t[n](e)})),e):e}function pn(e,...t){let n=0;return e.replace(/%s/g,(()=>encodeURIComponent(t[n++])))}const mn={WithinQueryParameters:0,WithinHeaders:1};function hn(e,t){const n=e||{},r=n.data||{};return Object.keys(n).forEach((e=>{-1===["timeout","headers","queryParameters","data","cacheable"].indexOf(e)&&(r[e]=n[e])})),{data:Object.entries(r).length>0?r:void 0,timeout:n.timeout||t,headers:n.headers||{},queryParameters:n.queryParameters||{},cacheable:n.cacheable}}const gn={Read:1,Write:2,Any:3},yn=1,bn=3;function vn(e,t=yn){return{...e,status:t,lastUpdate:Date.now()}}function Sn(e){return"string"==typeof e?{protocol:"https",url:e,accept:gn.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||gn.Any}}const En="GET",wn="POST";function _n(e,t,n,r){const o=[],a=function(e,t){if(e.method===En||void 0===e.data&&void 0===t.data)return;const n=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(n)}(n,r),i=function(e,t){const n={...e.headers,...t.headers},r={};return Object.keys(n).forEach((e=>{const t=n[e];r[e.toLowerCase()]=t})),r}(e,r),l=n.method,s=n.method!==En?{}:{...n.data,...r.data},c={"x-algolia-agent":e.userAgent.value,...e.queryParameters,...s,...r.queryParameters};let u=0;const d=(t,s)=>{const f=t.pop();if(void 0===f)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:xn(o)};const p={data:a,headers:i,method:l,url:On(f,n.path,c),connectTimeout:s(u,e.timeouts.connect),responseTimeout:s(u,r.timeout)},m=e=>{const n={request:p,response:e,host:f,triesLeft:t.length};return o.push(n),n},h={onSuccess:e=>function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e),onRetry(n){const r=m(n);return n.isTimedOut&&u++,Promise.all([e.logger.info("Retryable failure",An(r)),e.hostsCache.set(f,vn(f,n.isTimedOut?bn:2))]).then((()=>d(t,s)))},onFail(e){throw m(e),function({content:e,status:t},n){let r=e;try{r=JSON.parse(e).message}catch(e){}return function(e,t,n){return{name:"ApiError",message:e,status:t,transporterStackTrace:n}}(r,t,n)}(e,xn(o))}};return e.requester.send(p).then((e=>((e,t)=>(e=>{const t=e.status;return e.isTimedOut||(({isTimedOut:e,status:t})=>!e&&!~~t)(e)||2!=~~(t/100)&&4!=~~(t/100)})(e)?t.onRetry(e):(({status:e})=>2==~~(e/100))(e)?t.onSuccess(e):t.onFail(e))(e,h)))};return function(e,t){return Promise.all(t.map((t=>e.get(t,(()=>Promise.resolve(vn(t))))))).then((e=>{const n=e.filter((e=>function(e){return e.status===yn||Date.now()-e.lastUpdate>12e4}(e))),r=e.filter((e=>function(e){return e.status===bn&&Date.now()-e.lastUpdate<=12e4}(e))),o=[...n,...r];return{getTimeout:(e,t)=>(0===r.length&&0===e?1:r.length+3+e)*t,statelessHosts:o.length>0?o.map((e=>Sn(e))):t}}))}(e.hostsCache,t).then((e=>d([...e.statelessHosts].reverse(),e.getTimeout)))}function kn(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const n=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(n)&&(t.value=`${t.value}${n}`),t}};return t}function On(e,t,n){const r=Tn(n);let o=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return r.length&&(o+=`?${r}`),o}function Tn(e){return Object.keys(e).map((t=>{return pn("%s=%s",t,(n=e[t],"[object Object]"===Object.prototype.toString.call(n)||"[object Array]"===Object.prototype.toString.call(n)?JSON.stringify(e[t]):e[t]));var n})).join("&")}function xn(e){return e.map((e=>An(e)))}function An(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}const Cn=e=>{const t=e.appId,n=function(e,t,n){const r={"x-algolia-api-key":n,"x-algolia-application-id":t};return{headers:()=>e===mn.WithinHeaders?r:{},queryParameters:()=>e===mn.WithinQueryParameters?r:{}}}(void 0!==e.authMode?e.authMode:mn.WithinHeaders,t,e.apiKey),r=function(e){const{hostsCache:t,logger:n,requester:r,requestsCache:o,responsesCache:a,timeouts:i,userAgent:l,hosts:s,queryParameters:c,headers:u}=e,d={hostsCache:t,logger:n,requester:r,requestsCache:o,responsesCache:a,timeouts:i,userAgent:l,headers:u,queryParameters:c,hosts:s.map((e=>Sn(e))),read(e,t){const n=hn(t,d.timeouts.read),r=()=>_n(d,d.hosts.filter((e=>!!(e.accept&gn.Read))),e,n);if(!0!==(void 0!==n.cacheable?n.cacheable:e.cacheable))return r();const o={request:e,mappedRequestOptions:n,transporter:{queryParameters:d.queryParameters,headers:d.headers}};return d.responsesCache.get(o,(()=>d.requestsCache.get(o,(()=>d.requestsCache.set(o,r()).then((e=>Promise.all([d.requestsCache.delete(o),e])),(e=>Promise.all([d.requestsCache.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>d.responsesCache.set(o,e)})},write:(e,t)=>_n(d,d.hosts.filter((e=>!!(e.accept&gn.Write))),e,hn(t,d.timeouts.write))};return d}({hosts:[{url:`${t}-dsn.algolia.net`,accept:gn.Read},{url:`${t}.algolia.net`,accept:gn.Write}].concat(dn([{url:`${t}-1.algolianet.com`},{url:`${t}-2.algolianet.com`},{url:`${t}-3.algolianet.com`}])),...e,headers:{...n.headers(),"content-type":"application/x-www-form-urlencoded",...e.headers},queryParameters:{...n.queryParameters(),...e.queryParameters}}),o={transporter:r,appId:t,addAlgoliaAgent(e,t){r.userAgent.add({segment:e,version:t})},clearCache:()=>Promise.all([r.requestsCache.clear(),r.responsesCache.clear()]).then((()=>{}))};return fn(o,e.methods)},In=e=>(t,n)=>t.method===En?e.transporter.read(t,n):e.transporter.write(t,n),Rn=e=>(t,n={})=>fn({transporter:e.transporter,appId:e.appId,indexName:t},n.methods),Pn=e=>(t,n)=>{const r=t.map((e=>({...e,params:Tn(e.params||{})})));return e.transporter.read({method:wn,path:"1/indexes/*/queries",data:{requests:r},cacheable:!0},n)},Nn=e=>(t,n)=>Promise.all(t.map((t=>{const{facetName:r,facetQuery:o,...a}=t.params;return Rn(e)(t.indexName,{methods:{searchForFacetValues:jn}}).searchForFacetValues(r,o,{...n,...a})}))),Ln=e=>(t,n,r)=>e.transporter.read({method:wn,path:pn("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:n},cacheable:!0},r),Dn=e=>(t,n)=>e.transporter.read({method:wn,path:pn("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},n),jn=e=>(t,n,r)=>e.transporter.read({method:wn,path:pn("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:n},cacheable:!0},r),Mn=1,Fn=2,Un=3;function Bn(e,t,n){const r={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:e=>new Promise((t=>{const n=new XMLHttpRequest;n.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>n.setRequestHeader(t,e.headers[t])));const r=(e,r)=>setTimeout((()=>{n.abort(),t({status:0,content:r,isTimedOut:!0})}),1e3*e),o=r(e.connectTimeout,"Connection timeout");let a;n.onreadystatechange=()=>{n.readyState>n.OPENED&&void 0===a&&(clearTimeout(o),a=r(e.responseTimeout,"Socket timeout"))},n.onerror=()=>{0===n.status&&(clearTimeout(o),clearTimeout(a),t({content:n.responseText||"Network request failed",status:n.status,isTimedOut:!1}))},n.onload=()=>{clearTimeout(o),clearTimeout(a),t({content:n.responseText,status:n.status,isTimedOut:!1})},n.send(e.data)}))},logger:(o=Un,{debug:(e,t)=>(Mn>=o&&console.debug(e,t),Promise.resolve()),info:(e,t)=>(Fn>=o&&console.info(e,t),Promise.resolve()),error:(e,t)=>(console.error(e,t),Promise.resolve())}),responsesCache:un(),requestsCache:un({serializable:!1}),hostsCache:cn({caches:[sn({key:`4.19.1-${e}`}),un()]}),userAgent:kn("4.19.1").add({segment:"Browser",version:"lite"}),authMode:mn.WithinQueryParameters};var o;return Cn({...r,...n,methods:{search:Pn,searchForFacetValues:Nn,multipleQueries:Pn,multipleSearchForFacetValues:Nn,customRequest:In,initIndex:e=>t=>Rn(e)(t,{methods:{search:Dn,searchForFacetValues:jn,findAnswers:Ln}})}})}Bn.version="4.19.1";var zn=["footer","searchBox"];function $n(e){var t=e.appId,n=e.apiKey,o=e.indexName,i=e.placeholder,u=void 0===i?"Search docs":i,d=e.searchParameters,f=e.maxResultsPerGroup,p=e.onClose,m=void 0===p?Kt:p,h=e.transformItems,g=void 0===h?qt:h,y=e.hitComponent,b=void 0===y?Ot:y,v=e.resultsFooterComponent,S=void 0===v?function(){return null}:v,E=e.navigator,w=e.initialScrollY,_=void 0===w?0:w,k=e.transformSearchClient,O=void 0===k?qt:k,T=e.disableUserPersonalization,x=void 0!==T&&T,A=e.initialQuery,C=void 0===A?"":A,I=e.translations,R=void 0===I?{}:I,P=e.getMissingResultsUrl,N=e.insights,L=void 0!==N&&N,D=R.footer,j=R.searchBox,M=s(R,zn),F=c(r.useState({query:"",collections:[],completion:null,context:{},isOpen:!1,activeItemId:null,status:"idle"}),2),U=F[0],B=F[1],z=r.useRef(null),$=r.useRef(null),H=r.useRef(null),V=r.useRef(null),G=r.useRef(null),q=r.useRef(10),W=r.useRef("undefined"!=typeof window?window.getSelection().toString().slice(0,64):"").current,K=r.useRef(C||W).current,Y=function(e,t,n){return r.useMemo((function(){var r=Bn(e,t);return r.addAlgoliaAgent("docsearch","3.6.1"),!1===/docsearch.js \(.*\)/.test(r.transporter.userAgent.value)&&r.addAlgoliaAgent("docsearch-react","3.6.1"),n(r)}),[e,t,n])}(t,n,O),X=r.useRef(ln({key:"__DOCSEARCH_FAVORITE_SEARCHES__".concat(o),limit:10})).current,Q=r.useRef(ln({key:"__DOCSEARCH_RECENT_SEARCHES__".concat(o),limit:0===X.getAll().length?7:4})).current,Z=r.useCallback((function(e){if(!x){var t="content"===e.type?e.__docsearch_parent:e;t&&-1===X.getAll().findIndex((function(e){return e.objectID===t.objectID}))&&Q.add(t)}}),[X,Q,x]),J=r.useCallback((function(e){if(U.context.algoliaInsightsPlugin&&e.__autocomplete_id){var t=e,n={eventName:"Item Selected",index:t.__autocomplete_indexName,items:[t],positions:[e.__autocomplete_id],queryID:t.__autocomplete_queryID};U.context.algoliaInsightsPlugin.insights.clickedObjectIDsAfterSearch(n)}}),[U.context.algoliaInsightsPlugin]),ee=r.useMemo((function(){return Et({id:"docsearch",defaultActiveItemId:0,placeholder:u,openOnFocus:!0,initialState:{query:K,context:{searchSuggestions:[]}},insights:L,navigator:E,onStateChange:function(e){B(e.state)},getSources:function(e){var r=e.query,i=e.state,l=e.setContext,s=e.setStatus;if(!r)return x?[]:[{sourceId:"recentSearches",onSelect:function(e){var t=e.item,n=e.event;Z(t),Wt(n)||m()},getItemUrl:function(e){return e.item.url},getItems:function(){return Q.getAll()}},{sourceId:"favoriteSearches",onSelect:function(e){var t=e.item,n=e.event;Z(t),Wt(n)||m()},getItemUrl:function(e){return e.item.url},getItems:function(){return X.getAll()}}];var c=Boolean(L);return Y.search([{query:r,indexName:o,params:a({attributesToRetrieve:["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"],attributesToSnippet:["hierarchy.lvl1:".concat(q.current),"hierarchy.lvl2:".concat(q.current),"hierarchy.lvl3:".concat(q.current),"hierarchy.lvl4:".concat(q.current),"hierarchy.lvl5:".concat(q.current),"hierarchy.lvl6:".concat(q.current),"content:".concat(q.current)],snippetEllipsisText:"\u2026",highlightPreTag:"",highlightPostTag:"",hitsPerPage:20,clickAnalytics:c},d)}]).catch((function(e){throw"RetryError"===e.name&&s("error"),e})).then((function(e){var r=e.results[0],s=r.hits,u=r.nbHits,d=Gt(s,(function(e){return Qt(e)}),f);i.context.searchSuggestions.length0&&(re(),G.current&&G.current.focus())}),[K,re]),r.useEffect((function(){function e(){if($.current){var e=.01*window.innerHeight;$.current.style.setProperty("--docsearch-vh","".concat(e,"px"))}}return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),r.createElement("div",l({ref:z},ne({"aria-expanded":!0}),{className:["DocSearch","DocSearch-Container","stalled"===U.status&&"DocSearch-Container--Stalled","error"===U.status&&"DocSearch-Container--Errored"].filter(Boolean).join(" "),role:"button",tabIndex:0,onMouseDown:function(e){e.target===e.currentTarget&&m()}}),r.createElement("div",{className:"DocSearch-Modal",ref:$},r.createElement("header",{className:"DocSearch-SearchBar",ref:H},r.createElement(on,l({},ee,{state:U,autoFocus:0===K.length,inputRef:G,isFromSelection:Boolean(K)&&K===W,translations:j,onClose:m}))),r.createElement("div",{className:"DocSearch-Dropdown",ref:V},r.createElement(nn,l({},ee,{indexName:o,state:U,hitComponent:b,resultsFooterComponent:S,disableUserPersonalization:x,recentSearches:Q,favoriteSearches:X,inputRef:G,translations:M,getMissingResultsUrl:P,onItemClick:function(e,t){J(e),Z(e),Wt(t)||m()}}))),r.createElement("footer",{className:"DocSearch-Footer"},r.createElement(kt,{translations:D}))))}function Hn(e){var t=e.isOpen,n=e.onOpen,o=e.onClose,a=e.onInput,i=e.searchButtonRef;r.useEffect((function(){function e(e){var r;(27===e.keyCode&&t||"k"===(null===(r=e.key)||void 0===r?void 0:r.toLowerCase())&&(e.metaKey||e.ctrlKey)||!function(e){var t=e.target,n=t.tagName;return t.isContentEditable||"INPUT"===n||"SELECT"===n||"TEXTAREA"===n}(e)&&"/"===e.key&&!t)&&(e.preventDefault(),t?o():document.body.classList.contains("DocSearch--active")||document.body.classList.contains("DocSearch--active")||n()),i&&i.current===document.activeElement&&a&&/[a-zA-Z0-9]/.test(String.fromCharCode(e.keyCode))&&a(e)}return window.addEventListener("keydown",e),function(){window.removeEventListener("keydown",e)}}),[t,n,o,a,i])}},8328:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});n(6540);var r=n(3259),o=n.n(r),a=n(4054);const i={"0ab078a9":[()=>Promise.all([n.e(869),n.e(446),n.e(395)]).then(n.bind(n,1503)),"@site/docs/building/tinyorm.mdx",1503],"1222ea4e":[()=>n.e(153).then(n.bind(n,3392)),"@site/docs/tinyorm/serialization.mdx",3392],17896441:[()=>Promise.all([n.e(869),n.e(446),n.e(401)]).then(n.bind(n,8222)),"@theme/DocItem",8222],"1a4e3797":[()=>Promise.all([n.e(869),n.e(138)]).then(n.bind(n,9057)),"@theme/SearchPage",9057],"21dc2778":[()=>Promise.all([n.e(869),n.e(446),n.e(295)]).then(n.bind(n,8478)),"@site/docs/database/migrations.mdx",8478],"22dd74f7":[()=>n.e(567).then(n.t.bind(n,5226,19)),"@generated/docusaurus-plugin-content-docs/default/p/index-466.json",5226],"3dd307b5":[()=>n.e(117).then(n.bind(n,4251)),"@site/docs/tinyorm/collections.mdx",4251],"59b1a96c":[()=>n.e(485).then(n.bind(n,7777)),"@site/docs/README.mdx",7777],"5b254f70":[()=>n.e(82).then(n.bind(n,560)),"@site/docs/tinyorm/getting-started.mdx",560],"5e95c892":[()=>n.e(647).then(n.bind(n,7121)),"@theme/DocsRoot",7121],"62a1276f":[()=>n.e(304).then(n.bind(n,2403)),"@site/docs/tinyorm/casts.mdx",2403],"7333c691":[()=>n.e(638).then(n.bind(n,6577)),"@site/docs/tinyorm/relationships.mdx",6577],"8a8faf8d":[()=>Promise.all([n.e(869),n.e(446),n.e(129)]).then(n.bind(n,6455)),"@site/docs/building/migrations.mdx",6455],a4d3e054:[()=>n.e(755).then(n.bind(n,3696)),"@site/docs/database/seeding.mdx",3696],a7bd4aaa:[()=>n.e(98).then(n.bind(n,4532)),"@theme/DocVersionRoot",4532],a94703ab:[()=>Promise.all([n.e(869),n.e(48)]).then(n.bind(n,1377)),"@theme/DocRoot",1377],aba21aa0:[()=>n.e(742).then(n.t.bind(n,7093,19)),"@generated/docusaurus-plugin-content-docs/default/__plugin.json",7093],b4f71b2f:[()=>n.e(205).then(n.bind(n,4218)),"@site/docs/stability.mdx",4218],ba3d4959:[()=>Promise.all([n.e(869),n.e(170)]).then(n.bind(n,2512)),"@site/docs/database/getting-started.mdx",2512],c141421f:[()=>n.e(957).then(n.t.bind(n,936,19)),"@generated/docusaurus-theme-search-algolia/default/__plugin.json",936],cb1e72f9:[()=>n.e(258).then(n.bind(n,6349)),"@site/docs/tinydrivers/getting-started.mdx",6349],cbe663fe:[()=>n.e(995).then(n.bind(n,4583)),"@site/docs/database/query-builder.mdx",4583],d459b1c4:[()=>n.e(27).then(n.bind(n,9120)),"@site/docs/supported-compilers.mdx",9120],e19c288b:[()=>Promise.all([n.e(869),n.e(69)]).then(n.bind(n,9158)),"@site/docs/sponsors.mdx",9158],e3ac21cb:[()=>n.e(467).then(n.bind(n,348)),"@site/docs/dependencies.mdx",348],fb313d4e:[()=>n.e(871).then(n.bind(n,8489)),"@site/docs/features-summary.mdx",8489],feaee7f3:[()=>Promise.all([n.e(869),n.e(446),n.e(983)]).then(n.bind(n,8781)),"@site/docs/building/hello-world.mdx",8781]};var l=n(4848);function s(e){let{error:t,retry:n,pastDelay:r}=e;return t?(0,l.jsxs)("div",{style:{textAlign:"center",color:"#fff",backgroundColor:"#fa383e",borderColor:"#fa383e",borderStyle:"solid",borderRadius:"0.25rem",borderWidth:"1px",boxSizing:"border-box",display:"block",padding:"1rem",flex:"0 0 50%",marginLeft:"25%",marginRight:"25%",marginTop:"5rem",maxWidth:"50%",width:"100%"},children:[(0,l.jsx)("p",{children:String(t)}),(0,l.jsx)("div",{children:(0,l.jsx)("button",{type:"button",onClick:n,children:"Retry"})})]}):r?(0,l.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,l.jsx)("svg",{id:"loader",style:{width:128,height:110,position:"absolute",top:"calc(100vh - 64%)"},viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",stroke:"#61dafb",children:(0,l.jsxs)("g",{fill:"none",fillRule:"evenodd",transform:"translate(1 1)",strokeWidth:"2",children:[(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"1.5s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"1.5s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"1.5s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsxs)("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0",children:[(0,l.jsx)("animate",{attributeName:"r",begin:"3s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-opacity",begin:"3s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),(0,l.jsx)("animate",{attributeName:"stroke-width",begin:"3s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})]}),(0,l.jsx)("circle",{cx:"22",cy:"22",r:"8",children:(0,l.jsx)("animate",{attributeName:"r",begin:"0s",dur:"1.5s",values:"6;1;2;3;4;5;6",calcMode:"linear",repeatCount:"indefinite"})})]})})}):null}var c=n(6921),u=n(3102);function d(e,t){if("*"===e)return o()({loading:s,loader:()=>n.e(237).then(n.bind(n,2237)),modules:["@theme/NotFound"],webpack:()=>[2237],render(e,t){const n=e.default;return(0,l.jsx)(u.W,{value:{plugin:{name:"native",id:"default"}},children:(0,l.jsx)(n,{...t})})}});const r=a[`${e}-${t}`],d={},f=[],p=[],m=(0,c.A)(r);return Object.entries(m).forEach((e=>{let[t,n]=e;const r=i[n];r&&(d[t]=r[0],f.push(r[1]),p.push(r[2]))})),o().Map({loading:s,loader:d,modules:f,webpack:()=>p,render(t,n){const o=JSON.parse(JSON.stringify(r));Object.entries(t).forEach((t=>{let[n,r]=t;const a=r.default;if(!a)throw new Error(`The page component at ${e} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);"object"!=typeof a&&"function"!=typeof a||Object.keys(r).filter((e=>"default"!==e)).forEach((e=>{a[e]=r[e]}));let i=o;const l=n.split(".");l.slice(0,-1).forEach((e=>{i=i[e]})),i[l[l.length-1]]=a}));const a=o.__comp;delete o.__comp;const i=o.__context;delete o.__context;const s=o.__props;return delete o.__props,(0,l.jsx)(u.W,{value:i,children:(0,l.jsx)(a,{...o,...s,...n})})}})}const f=[{path:"/search",component:d("/search","5de"),exact:!0},{path:"/",component:d("/","df2"),routes:[{path:"/",component:d("/","9aa"),routes:[{path:"/",component:d("/","1e6"),routes:[{path:"/building/hello-world",component:d("/building/hello-world","9c2"),exact:!0,sidebar:"tinyormSidebar"},{path:"/building/migrations",component:d("/building/migrations","531"),exact:!0,sidebar:"tinyormSidebar"},{path:"/building/tinyorm",component:d("/building/tinyorm","b57"),exact:!0,sidebar:"tinyormSidebar"},{path:"/database/getting-started",component:d("/database/getting-started","0b1"),exact:!0,sidebar:"tinyormSidebar"},{path:"/database/migrations",component:d("/database/migrations","6de"),exact:!0,sidebar:"tinyormSidebar"},{path:"/database/query-builder",component:d("/database/query-builder","2bb"),exact:!0,sidebar:"tinyormSidebar"},{path:"/database/seeding",component:d("/database/seeding","9c2"),exact:!0,sidebar:"tinyormSidebar"},{path:"/dependencies",component:d("/dependencies","a43"),exact:!0,sidebar:"tinyormSidebar"},{path:"/features-summary",component:d("/features-summary","235"),exact:!0,sidebar:"tinyormSidebar"},{path:"/sponsors",component:d("/sponsors","3aa"),exact:!0,sidebar:"tinyormSidebar"},{path:"/stability",component:d("/stability","065"),exact:!0,sidebar:"tinyormSidebar"},{path:"/supported-compilers",component:d("/supported-compilers","699"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinydrivers/getting-started",component:d("/tinydrivers/getting-started","071"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinyorm/casts",component:d("/tinyorm/casts","09c"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinyorm/collections",component:d("/tinyorm/collections","5b8"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinyorm/getting-started",component:d("/tinyorm/getting-started","699"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinyorm/relationships",component:d("/tinyorm/relationships","80b"),exact:!0,sidebar:"tinyormSidebar"},{path:"/tinyorm/serialization",component:d("/tinyorm/serialization","b90"),exact:!0,sidebar:"tinyormSidebar"},{path:"/",component:d("/","f1e"),exact:!0,sidebar:"tinyormSidebar"}]}]}]},{path:"*",component:d("*")}]},6125:(e,t,n)=>{"use strict";n.d(t,{o:()=>a,x:()=>i});var r=n(6540),o=n(4848);const a=r.createContext(!1);function i(e){let{children:t}=e;const[n,i]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{i(!0)}),[]),(0,o.jsx)(a.Provider,{value:n,children:t})}},6756:(e,t,n)=>{"use strict";var r=n(6540),o=n(5338),a=n(545),i=n(4625),l=n(4784),s=n(8193);const c=[n(1911),n(119),n(6491),n(6294),n(1043)];var u=n(8328),d=n(6347),f=n(2831),p=n(1838),m=n(679);const h="tinyorm.rootFolder.",g=()=>{const[e,t]=(0,r.useState)({}),n=(0,r.useCallback)(((e,t)=>{(0,m.Wf)(`${h}${e}`).set(t)}),[]);return(0,r.useEffect)((()=>{try{const e={};(0,m.Eo)().forEach((t=>{if(t.startsWith(h)){const n=t.substring(19);e[n]=(0,m.Wf)(t).get()}})),t(e)}catch(e){console.error(e)}}),[]),{rootFolder:e,setRootFolder:(e,r)=>{t((t=>({...t,[e]:r}))),n(e,r)}}};var y=n(4848);function b(e){const{rootFolder:t,setRootFolder:n}=g(),o=(0,r.useMemo)((()=>({rootFolder:t,setRootFolder:n})),[t,n]);return(0,y.jsx)(p.A.Provider,{value:o,children:e.children})}let v,S,E,w=0;function _(){const e=document.querySelector('.theme-doc-sidebar-container div[title="Expand sidebar"]');e&&(e.title+=" (q)",clearTimeout(S))}function k(){E=document.querySelector(".theme-doc-sidebar-container > div > div > button"),w>=50?clearInterval(v):E?(E.title+=" (q)",clearInterval(v),E.addEventListener("click",(()=>{S=setTimeout(_,300)}))):++w}function O(e){const t=e.target,n=e.target.nodeName;t.isContentEditable||"INPUT"===n||"TEXTAREA"===n||"SELECT"===n||"KeyQ"===e.code&&(E.click(),S=setTimeout(_,300))}function T(){var e;e=()=>{v=setInterval(k,30),document.addEventListener("keyup",O)},"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e)}function x(e){let{children:t}=e;return(0,y.jsx)(b,{children:t})}s.A.canUseDOM&&T();var A=n(5260),C=n(4586),I=n(6025),R=n(6342),P=n(9024),N=n(2131),L=n(4090),D=n(2967),j=n(440),M=n(1463);function F(){const{i18n:{currentLocale:e,defaultLocale:t,localeConfigs:n}}=(0,C.A)(),r=(0,N.o)(),o=n[e].htmlLang,a=e=>e.replace("-","_");return(0,y.jsxs)(A.A,{children:[Object.entries(n).map((e=>{let[t,{htmlLang:n}]=e;return(0,y.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:n},t)})),(0,y.jsx)("link",{rel:"alternate",href:r.createUrl({locale:t,fullyQualified:!0}),hrefLang:"x-default"}),(0,y.jsx)("meta",{property:"og:locale",content:a(o)}),Object.values(n).filter((e=>o!==e.htmlLang)).map((e=>(0,y.jsx)("meta",{property:"og:locale:alternate",content:a(e.htmlLang)},`meta-og-${e.htmlLang}`)))]})}function U(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,C.A)(),r=function(){const{siteConfig:{url:e,baseUrl:t,trailingSlash:n}}=(0,C.A)(),{pathname:r}=(0,d.zy)();return e+(0,j.Ks)((0,I.Ay)(r),{trailingSlash:n,baseUrl:t})}(),o=t?`${n}${t}`:r;return(0,y.jsxs)(A.A,{children:[(0,y.jsx)("meta",{property:"og:url",content:o}),(0,y.jsx)("link",{rel:"canonical",href:o})]})}function B(){const{i18n:{currentLocale:e}}=(0,C.A)(),{metadata:t,image:n}=(0,R.p)();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(A.A,{children:[(0,y.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,y.jsx)("body",{className:L.w})]}),n&&(0,y.jsx)(P.be,{image:n}),(0,y.jsx)(U,{}),(0,y.jsx)(F,{}),(0,y.jsx)(M.A,{tag:D.C,locale:e}),(0,y.jsx)(A.A,{children:t.map(((e,t)=>(0,y.jsx)("meta",{...e},t)))})]})}const z=new Map;var $=n(6125),H=n(6988),V=n(205);function G(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>o.forEach((e=>e?.()))}const q=function(e){let{children:t,location:n,previousLocation:r}=e;return(0,V.A)((()=>{r!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,o=t.hash===n.hash,a=t.search===n.search;if(r&&o&&!a)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:r}),G("onRouteDidUpdate",{previousLocation:r,location:n}))}),[r,n]),t};function W(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,f.u)(u.A,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class K extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=s.A.canUseDOM?G("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=G("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),W(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return(0,y.jsx)(q,{previousLocation:this.previousLocation,location:t,children:(0,y.jsx)(d.qh,{location:t,render:()=>e})})}}const Y=K,X="__docusaurus-base-url-issue-banner-container",Q="__docusaurus-base-url-issue-banner",Z="__docusaurus-base-url-issue-banner-suggestion-container";function J(e){return`\ndocument.addEventListener('DOMContentLoaded', function maybeInsertBanner() {\n var shouldInsert = typeof window['docusaurus'] === 'undefined';\n shouldInsert && insertBanner();\n});\n\nfunction insertBanner() {\n var bannerContainer = document.createElement('div');\n bannerContainer.id = '${X}';\n var bannerHtml = ${JSON.stringify(function(e){return`\n
\n

Your Docusaurus site did not load properly.

\n

A very common reason is a wrong site baseUrl configuration.

\n

Current configured baseUrl = ${e} ${"/"===e?" (default value)":""}

\n

We suggest trying baseUrl =

\n
\n`}(e)).replace(/{let{route:t}=e;return!0===t.exact})))return z.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return z.set(e.pathname,t),{...e,pathname:t}}((0,d.zy)());return(0,y.jsx)(Y,{location:e,children:ie})}function se(){return(0,y.jsx)(re.A,{children:(0,y.jsx)(H.l,{children:(0,y.jsxs)($.x,{children:[(0,y.jsxs)(x,{children:[(0,y.jsx)(ne,{}),(0,y.jsx)(B,{}),(0,y.jsx)(te,{}),(0,y.jsx)(le,{})]}),(0,y.jsx)(ae,{})]})})})}var ce=n(4054);const ue=function(e){try{return document.createElement("link").relList.supports(e)}catch{return!1}}("prefetch")?function(e){return new Promise(((t,n)=>{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const o=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;o?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var de=n(6921);const fe=new Set,pe=new Set,me=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,he={prefetch:e=>{if(!(e=>!me()&&!pe.has(e)&&!fe.has(e))(e))return!1;fe.add(e);const t=(0,f.u)(u.A,e).flatMap((e=>{return t=e.route.path,Object.entries(ce).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,de.A)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?ue(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!me()&&!pe.has(e))(e)&&(pe.add(e),W(e))},ge=Object.freeze(he);function ye(e){let{children:t}=e;return"hash"===l.A.future.experimental_router?(0,y.jsx)(i.I9,{children:t}):(0,y.jsx)(i.Kd,{children:t})}const be=Boolean(!0);if(s.A.canUseDOM){window.docusaurus=ge;const e=document.getElementById("__docusaurus"),t=(0,y.jsx)(a.vd,{children:(0,y.jsx)(ye,{children:(0,y.jsx)(se,{})})}),n=(e,t)=>{console.error("Docusaurus React Root onRecoverableError:",e,t)},i=()=>{if(window.docusaurusRoot)window.docusaurusRoot.render(t);else if(be)window.docusaurusRoot=o.hydrateRoot(e,t,{onRecoverableError:n});else{const r=o.createRoot(e,{onRecoverableError:n});r.render(t),window.docusaurusRoot=r}};W(window.location.pathname).then((()=>{(0,r.startTransition)(i)}))}},6988:(e,t,n)=>{"use strict";n.d(t,{o:()=>d,l:()=>f});var r=n(6540),o=n(4784);const a=JSON.parse('{"docusaurus-plugin-content-docs":{"default":{"path":"/","versions":[{"name":"current","label":"Next","isLast":true,"path":"/","mainDocId":"README","docs":[{"id":"building/hello-world","path":"/building/hello-world","sidebar":"tinyormSidebar"},{"id":"building/migrations","path":"/building/migrations","sidebar":"tinyormSidebar"},{"id":"building/tinyorm","path":"/building/tinyorm","sidebar":"tinyormSidebar"},{"id":"database/getting-started","path":"/database/getting-started","sidebar":"tinyormSidebar"},{"id":"database/migrations","path":"/database/migrations","sidebar":"tinyormSidebar"},{"id":"database/query-builder","path":"/database/query-builder","sidebar":"tinyormSidebar"},{"id":"database/seeding","path":"/database/seeding","sidebar":"tinyormSidebar"},{"id":"dependencies","path":"/dependencies","sidebar":"tinyormSidebar"},{"id":"features-summary","path":"/features-summary","sidebar":"tinyormSidebar"},{"id":"README","path":"/","sidebar":"tinyormSidebar"},{"id":"sponsors","path":"/sponsors","sidebar":"tinyormSidebar"},{"id":"stability","path":"/stability","sidebar":"tinyormSidebar"},{"id":"supported-compilers","path":"/supported-compilers","sidebar":"tinyormSidebar"},{"id":"tinydrivers/getting-started","path":"/tinydrivers/getting-started","sidebar":"tinyormSidebar"},{"id":"tinyorm/casts","path":"/tinyorm/casts","sidebar":"tinyormSidebar"},{"id":"tinyorm/collections","path":"/tinyorm/collections","sidebar":"tinyormSidebar"},{"id":"tinyorm/getting-started","path":"/tinyorm/getting-started","sidebar":"tinyormSidebar"},{"id":"tinyorm/relationships","path":"/tinyorm/relationships","sidebar":"tinyormSidebar"},{"id":"tinyorm/serialization","path":"/tinyorm/serialization","sidebar":"tinyormSidebar"}],"draftIds":[],"sidebars":{"tinyormSidebar":{"link":{"path":"/","label":"\ud83d\udd25 Prologue"}}}}],"breadcrumbs":true}},"docusaurus-plugin-google-gtag":{"default":{"trackingID":["G-2QRS622BWQ"],"anonymizeIP":false,"id":"default"}}}'),i=JSON.parse('{"defaultLocale":"en","locales":["en"],"path":"i18n","currentLocale":"en","localeConfigs":{"en":{"label":"English","direction":"ltr","htmlLang":"en","calendar":"gregory","path":"en"}}}');var l=n(2654);const s=JSON.parse('{"docusaurusVersion":"3.5.2","siteVersion":"1.1.3","pluginVersions":{"docusaurus-plugin-content-docs":{"type":"package","name":"@docusaurus/plugin-content-docs","version":"3.5.2"},"docusaurus-plugin-content-pages":{"type":"package","name":"@docusaurus/plugin-content-pages","version":"3.5.2"},"docusaurus-plugin-google-gtag":{"type":"package","name":"@docusaurus/plugin-google-gtag","version":"3.5.2"},"docusaurus-plugin-sitemap":{"type":"package","name":"@docusaurus/plugin-sitemap","version":"3.5.2"},"docusaurus-theme-classic":{"type":"package","name":"@docusaurus/theme-classic","version":"3.5.2"},"docusaurus-theme-search-algolia":{"type":"package","name":"@docusaurus/theme-search-algolia","version":"3.5.2"},"docusaurus-plugin-client-redirects":{"type":"package","name":"@docusaurus/plugin-client-redirects","version":"3.5.2"},"webpack-configuration-plugin":{"type":"local"},"postcss-configuration-plugin":{"type":"local"},"tiny-common":{"type":"local"}}}');var c=n(4848);const u={siteConfig:o.A,siteMetadata:s,globalData:a,i18n:i,codeTranslations:l},d=r.createContext(u);function f(e){let{children:t}=e;return(0,c.jsx)(d.Provider,{value:u,children:t})}},7489:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var r=n(6540),o=n(8193),a=n(5260),i=n(440),l=n(1957),s=n(3102),c=n(4848);function u(e){let{error:t,tryAgain:n}=e;return(0,c.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",minHeight:"100vh",width:"100%",maxWidth:"80ch",fontSize:"20px",margin:"0 auto",padding:"1rem"},children:[(0,c.jsx)("h1",{style:{fontSize:"3rem"},children:"This page crashed"}),(0,c.jsx)("button",{type:"button",onClick:n,style:{margin:"1rem 0",fontSize:"2rem",cursor:"pointer",borderRadius:20,padding:"1rem"},children:"Try again"}),(0,c.jsx)(d,{error:t})]})}function d(e){let{error:t}=e;const n=(0,i.rA)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,c.jsx)("p",{style:{whiteSpace:"pre-wrap"},children:n})}function f(e){let{children:t}=e;return(0,c.jsx)(s.W,{value:{plugin:{name:"docusaurus-core-error-boundary",id:"default"}},children:t})}function p(e){let{error:t,tryAgain:n}=e;return(0,c.jsx)(f,{children:(0,c.jsxs)(h,{fallback:()=>(0,c.jsx)(u,{error:t,tryAgain:n}),children:[(0,c.jsx)(a.A,{children:(0,c.jsx)("title",{children:"Page Error"})}),(0,c.jsx)(l.A,{children:(0,c.jsx)(u,{error:t,tryAgain:n})})]})})}const m=e=>(0,c.jsx)(p,{...e});class h extends r.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){o.A.canUseDOM&&this.setState({error:e})}render(){const{children:e}=this.props,{error:t}=this.state;if(t){const e={error:t,tryAgain:()=>this.setState({error:null})};return(this.props.fallback??m)(e)}return e??null}}},8193:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});const r="undefined"!=typeof window&&"document"in window&&"createElement"in window.document,o={canUseDOM:r,canUseEventListeners:r&&("addEventListener"in window||"attachEvent"in window),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&"screen"in window}},5260:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});n(6540);var r=n(545),o=n(4848);function a(e){return(0,o.jsx)(r.mg,{...e})}},8774:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(6540),o=n(4625),a=n(440),i=n(4586),l=n(6654),s=n(8193),c=n(3427),u=n(6025),d=n(4848);function f(e,t){let{isNavLink:n,to:f,href:p,activeClassName:m,isActive:h,"data-noBrokenLinkCheck":g,autoAddBaseUrl:y=!0,...b}=e;const{siteConfig:v}=(0,i.A)(),{trailingSlash:S,baseUrl:E}=v,w=v.future.experimental_router,{withBaseUrl:_}=(0,u.hH)(),k=(0,c.A)(),O=(0,r.useRef)(null);(0,r.useImperativeHandle)(t,(()=>O.current));const T=f||p;const x=(0,l.A)(T),A=T?.replace("pathname://","");let C=void 0!==A?(I=A,y&&(e=>e.startsWith("/"))(I)?_(I):I):void 0;var I;"hash"===w&&C?.startsWith("./")&&(C=C?.slice(1)),C&&x&&(C=(0,a.Ks)(C,{trailingSlash:S,baseUrl:E}));const R=(0,r.useRef)(!1),P=n?o.k2:o.N_,N=s.A.canUseIntersectionObserver,L=(0,r.useRef)(),D=()=>{R.current||null==C||(window.docusaurus.preload(C),R.current=!0)};(0,r.useEffect)((()=>(!N&&x&&s.A.canUseDOM&&null!=C&&window.docusaurus.prefetch(C),()=>{N&&L.current&&L.current.disconnect()})),[L,C,N,x]);const j=C?.startsWith("#")??!1,M=!b.target||"_self"===b.target,F=!C||!x||!M||j&&"hash"!==w;g||!j&&F||k.collectLink(C),b.id&&k.collectAnchor(b.id);const U={};return F?(0,d.jsx)("a",{ref:O,href:C,...T&&!x&&{target:"_blank",rel:"noopener noreferrer"},...b,...U}):(0,d.jsx)(P,{...b,onMouseEnter:D,onTouchStart:D,innerRef:e=>{O.current=e,N&&e&&x&&(L.current=new window.IntersectionObserver((t=>{t.forEach((t=>{e===t.target&&(t.isIntersecting||t.intersectionRatio>0)&&(L.current.unobserve(e),L.current.disconnect(),null!=C&&window.docusaurus.prefetch(C))}))})),L.current.observe(e))},to:C,...n&&{isActive:h,activeClassName:m},...U})}const p=r.forwardRef(f)},1312:(e,t,n)=>{"use strict";n.d(t,{A:()=>c,T:()=>s});var r=n(6540),o=n(4848);function a(e,t){const n=e.split(/(\{\w+\})/).map(((e,n)=>{if(n%2==1){const n=t?.[e.slice(1,-1)];if(void 0!==n)return n}return e}));return n.some((e=>(0,r.isValidElement)(e)))?n.map(((e,t)=>(0,r.isValidElement)(e)?r.cloneElement(e,{key:t}):e)).filter((e=>""!==e)):n.join("")}var i=n(2654);function l(e){let{id:t,message:n}=e;if(void 0===t&&void 0===n)throw new Error("Docusaurus translation declarations must have at least a translation id or a default translation message");return i[t??n]??n??t}function s(e,t){let{message:n,id:r}=e;return a(l({message:n,id:r}),t)}function c(e){let{children:t,id:n,values:r}=e;if(t&&"string"!=typeof t)throw console.warn("Illegal children",t),new Error("The Docusaurus component only accept simple string values");const i=l({message:t,id:n});return(0,o.jsx)(o.Fragment,{children:a(i,r)})}},7065:(e,t,n)=>{"use strict";n.d(t,{W:()=>r});const r="default"},6654:(e,t,n)=>{"use strict";function r(e){return/^(?:\w*:|\/\/)/.test(e)}function o(e){return void 0!==e&&!r(e)}n.d(t,{A:()=>o,z:()=>r})},6025:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>l,hH:()=>i});var r=n(6540),o=n(4586),a=n(6654);function i(){const{siteConfig:e}=(0,o.A)(),{baseUrl:t,url:n}=e,i=e.future.experimental_router,l=(0,r.useCallback)(((e,r)=>function(e){let{siteUrl:t,baseUrl:n,url:r,options:{forcePrependBaseUrl:o=!1,absolute:i=!1}={},router:l}=e;if(!r||r.startsWith("#")||(0,a.z)(r))return r;if("hash"===l)return r.startsWith("/")?`.${r}`:`./${r}`;if(o)return n+r.replace(/^\//,"");if(r===n.replace(/\/$/,""))return n;const s=r.startsWith(n)?r:n+r.replace(/^\//,"");return i?t+s:s}({siteUrl:n,baseUrl:t,url:e,options:r,router:i})),[n,t,i]);return{withBaseUrl:l}}function l(e,t){void 0===t&&(t={});const{withBaseUrl:n}=i();return n(e,t)}},3427:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(6540);n(4848);const o=r.createContext({collectAnchor:()=>{},collectLink:()=>{}}),a=()=>(0,r.useContext)(o);function i(){return a()}},4586:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(6540),o=n(6988);function a(){return(0,r.useContext)(o.o)}},2303:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(6540),o=n(6125);function a(){return(0,r.useContext)(o.o)}},205:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(6540);const o=n(8193).A.canUseDOM?r.useLayoutEffect:r.useEffect},6921:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});const r=e=>"object"==typeof e&&!!e&&Object.keys(e).length>0;function o(e){const t={};return function e(n,o){Object.entries(n).forEach((n=>{let[a,i]=n;const l=o?`${o}.${a}`:a;r(i)?e(i,l):t[l]=i}))}(e),t}},3102:(e,t,n)=>{"use strict";n.d(t,{W:()=>i,o:()=>a});var r=n(6540),o=n(4848);const a=r.createContext(null);function i(e){let{children:t,value:n}=e;const i=r.useContext(a),l=(0,r.useMemo)((()=>function(e){let{parent:t,value:n}=e;if(!t){if(!n)throw new Error("Unexpected: no Docusaurus route context found");if(!("plugin"in n))throw new Error("Unexpected: Docusaurus topmost route context has no `plugin` attribute");return n}const r={...t.data,...n?.data};return{plugin:t.plugin,data:r}}({parent:i,value:n})),[i,n]);return(0,o.jsx)(a.Provider,{value:l,children:t})}},3886:(e,t,n)=>{"use strict";n.d(t,{VQ:()=>g,XK:()=>v,g1:()=>b});var r=n(6540),o=n(4070),a=n(7065),i=n(6342),l=n(679),s=n(9532),c=n(4848);const u=e=>`docs-preferred-version-${e}`,d={save:(e,t,n)=>{(0,l.Wf)(u(e),{persistence:t}).set(n)},read:(e,t)=>(0,l.Wf)(u(e),{persistence:t}).get(),clear:(e,t)=>{(0,l.Wf)(u(e),{persistence:t}).del()}},f=e=>Object.fromEntries(e.map((e=>[e,{preferredVersionName:null}])));const p=r.createContext(null);function m(){const e=(0,o.Gy)(),t=(0,i.p)().docs.versionPersistence,n=(0,r.useMemo)((()=>Object.keys(e)),[e]),[a,l]=(0,r.useState)((()=>f(n)));(0,r.useEffect)((()=>{l(function(e){let{pluginIds:t,versionPersistence:n,allDocsData:r}=e;function o(e){const t=d.read(e,n);return r[e].versions.some((e=>e.name===t))?{preferredVersionName:t}:(d.clear(e,n),{preferredVersionName:null})}return Object.fromEntries(t.map((e=>[e,o(e)])))}({allDocsData:e,versionPersistence:t,pluginIds:n}))}),[e,t,n]);return[a,(0,r.useMemo)((()=>({savePreferredVersion:function(e,n){d.save(e,t,n),l((t=>({...t,[e]:{preferredVersionName:n}})))}})),[t])]}function h(e){let{children:t}=e;const n=m();return(0,c.jsx)(p.Provider,{value:n,children:t})}function g(e){let{children:t}=e;return(0,c.jsx)(h,{children:t})}function y(){const e=(0,r.useContext)(p);if(!e)throw new s.dV("DocsPreferredVersionContextProvider");return e}function b(e){void 0===e&&(e=a.W);const t=(0,o.ht)(e),[n,i]=y(),{preferredVersionName:l}=n[e];return{preferredVersion:t.versions.find((e=>e.name===l))??null,savePreferredVersionName:(0,r.useCallback)((t=>{i.savePreferredVersion(e,t)}),[i,e])}}function v(){const e=(0,o.Gy)(),[t]=y();function n(n){const r=e[n],{preferredVersionName:o}=t[n];return r.versions.find((e=>e.name===o))??null}const r=Object.keys(e);return Object.fromEntries(r.map((e=>[e,n(e)])))}},2565:(e,t,n)=>{"use strict";n.d(t,{k:()=>a,v:()=>i});var r=n(4070),o=n(3886);function a(e,t){return`docs-${e}-${t}`}function i(){const e=(0,r.Gy)(),t=(0,r.gk)(),n=(0,o.XK)();return[...Object.keys(e).map((function(r){const o=t?.activePlugin.pluginId===r?t.activeVersion:void 0,i=n[r],l=e[r].versions.find((e=>e.isLast));return a(r,(o??i??l).name)}))]}},609:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,t:()=>c});var r=n(6540),o=n(9532),a=n(4848);const i=Symbol("EmptyContext"),l=r.createContext(i);function s(e){let{children:t,name:n,items:o}=e;const i=(0,r.useMemo)((()=>n&&o?{name:n,items:o}:null),[n,o]);return(0,a.jsx)(l.Provider,{value:i,children:t})}function c(){const e=(0,r.useContext)(l);if(e===i)throw new o.dV("DocsSidebarProvider");return e}},6972:(e,t,n)=>{"use strict";n.d(t,{B5:()=>_,Nr:()=>f,OF:()=>v,QB:()=>w,Vd:()=>S,Y:()=>y,fW:()=>E,w8:()=>h});var r=n(6540),o=n(6347),a=n(2831),i=n(4070),l=n(9169),s=n(1682),c=n(3886),u=n(3025),d=n(609);function f(e){return"link"!==e.type||e.unlisted?"category"===e.type?function(e){if(e.href&&!e.linkUnlisted)return e.href;for(const t of e.items){const e=f(t);if(e)return e}}(e):void 0:e.href}const p=(e,t)=>void 0!==e&&(0,l.ys)(e,t),m=(e,t)=>e.some((e=>h(e,t)));function h(e,t){return"link"===e.type?p(e.href,t):"category"===e.type&&(p(e.href,t)||m(e.items,t))}function g(e,t){switch(e.type){case"category":return h(e,t)||e.items.some((e=>g(e,t)));case"link":return!e.unlisted||h(e,t);default:return!0}}function y(e,t){return(0,r.useMemo)((()=>e.filter((e=>g(e,t)))),[e,t])}function b(e){let{sidebarItems:t,pathname:n,onlyCategories:r=!1}=e;const o=[];return function e(t){for(const a of t)if("category"===a.type&&((0,l.ys)(a.href,n)||e(a.items))||"link"===a.type&&(0,l.ys)(a.href,n)){return r&&"category"!==a.type||o.unshift(a),!0}return!1}(t),o}function v(){const e=(0,d.t)(),{pathname:t}=(0,o.zy)(),n=(0,i.vT)()?.pluginData.breadcrumbs;return!1!==n&&e?b({sidebarItems:e.items,pathname:t}):null}function S(e){const{activeVersion:t}=(0,i.zK)(e),{preferredVersion:n}=(0,c.g1)(e),o=(0,i.r7)(e);return(0,r.useMemo)((()=>(0,s.sb)([t,n,o].filter(Boolean))),[t,n,o])}function E(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.sidebars?Object.entries(e.sidebars):[])),r=t.find((t=>t[0]===e));if(!r)throw new Error(`Can't find any sidebar with id "${e}" in version${n.length>1?"s":""} ${n.map((e=>e.name)).join(", ")}".\nAvailable sidebar ids are:\n- ${t.map((e=>e[0])).join("\n- ")}`);return r[1]}),[e,n])}function w(e,t){const n=S(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.docs)),r=t.find((t=>t.id===e));if(!r){if(n.flatMap((e=>e.draftIds)).includes(e))return null;throw new Error(`Couldn't find any doc with id "${e}" in version${n.length>1?"s":""} "${n.map((e=>e.name)).join(", ")}".\nAvailable doc ids are:\n- ${(0,s.sb)(t.map((e=>e.id))).join("\n- ")}`)}return r}),[e,n])}function _(e){let{route:t}=e;const n=(0,o.zy)(),r=(0,u.r)(),i=t.routes,l=i.find((e=>(0,o.B6)(n.pathname,e)));if(!l)return null;const s=l.sidebar,c=s?r.docsSidebars[s]:void 0;return{docElement:(0,a.v)(i),sidebarName:s,sidebarItems:c}}},3025:(e,t,n)=>{"use strict";n.d(t,{n:()=>l,r:()=>s});var r=n(6540),o=n(9532),a=n(4848);const i=r.createContext(null);function l(e){let{children:t,version:n}=e;return(0,a.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(null===e)throw new o.dV("DocsVersionProvider");return e}},4070:(e,t,n)=>{"use strict";n.d(t,{zK:()=>y,vT:()=>p,gk:()=>m,Gy:()=>d,HW:()=>b,ht:()=>f,r7:()=>g,jh:()=>h});var r=n(6347),o=n(4586),a=n(7065);function i(e,t){void 0===t&&(t={});const n=function(){const{globalData:e}=(0,o.A)();return e}()[e];if(!n&&t.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin.`);return n}const l=e=>e.versions.find((e=>e.isLast));function s(e,t){return[...e.versions].sort(((e,t)=>e.path===t.path?0:e.path.includes(t.path)?-1:t.path.includes(e.path)?1:0)).find((e=>!!(0,r.B6)(t,{path:e.path,exact:!1,strict:!1})))}function c(e,t){const n=s(e,t),o=n?.docs.find((e=>!!(0,r.B6)(t,{path:e.path,exact:!0,strict:!1})));return{activeVersion:n,activeDoc:o,alternateDocVersions:o?function(t){const n={};return e.versions.forEach((e=>{e.docs.forEach((r=>{r.id===t&&(n[e.name]=r)}))})),n}(o.id):{}}}const u={},d=()=>i("docusaurus-plugin-content-docs")??u,f=e=>{try{return function(e,t,n){void 0===t&&(t=a.W),void 0===n&&(n={});const r=i(e),o=r?.[t];if(!o&&n.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin with id "${t}".`);return o}("docusaurus-plugin-content-docs",e,{failfast:!0})}catch(t){throw new Error("You are using a feature of the Docusaurus docs plugin, but this plugin does not seem to be enabled"+("Default"===e?"":` (pluginId=${e}`),{cause:t})}};function p(e){void 0===e&&(e={});const t=d(),{pathname:n}=(0,r.zy)();return function(e,t,n){void 0===n&&(n={});const o=Object.entries(e).sort(((e,t)=>t[1].path.localeCompare(e[1].path))).find((e=>{let[,n]=e;return!!(0,r.B6)(t,{path:n.path,exact:!1,strict:!1})})),a=o?{pluginId:o[0],pluginData:o[1]}:void 0;if(!a&&n.failfast)throw new Error(`Can't find active docs plugin for "${t}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(e).map((e=>e.path)).join(", ")}`);return a}(t,n,e)}function m(e){void 0===e&&(e={});const t=p(e),{pathname:n}=(0,r.zy)();if(!t)return;return{activePlugin:t,activeVersion:s(t.pluginData,n)}}function h(e){return f(e).versions}function g(e){const t=f(e);return l(t)}function y(e){const t=f(e),{pathname:n}=(0,r.zy)();return c(t,n)}function b(e){const t=f(e),{pathname:n}=(0,r.zy)();return function(e,t){const n=l(e);return{latestDocSuggestion:c(e,t).alternateDocVersions[n.name],latestVersionSuggestion:n}}(t,n)}},1911:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});const r={onRouteDidUpdate(e){let{location:t,previousLocation:n}=e;!n||t.pathname===n.pathname&&t.search===n.search&&t.hash===n.hash||setTimeout((()=>{window.gtag("set","page_path",t.pathname+t.search+t.hash),window.gtag("event","page_view")}))}}},6294:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var r=n(5947),o=n.n(r);o().configure({showSpinner:!1});const a={onRouteUpdate(e){let{location:t,previousLocation:n}=e;if(n&&t.pathname!==n.pathname){const e=window.setTimeout((()=>{o().start()}),200);return()=>window.clearTimeout(e)}},onRouteDidUpdate(){o().done()}}},6491:(e,t,n)=>{"use strict";var r=n(1765),o=n(4784);!function(e){const{themeConfig:{prism:t}}=o.A,{additionalLanguages:r}=t;globalThis.Prism=e,r.forEach((e=>{"php"===e&&n(9700),n(652)(`./prism-${e}`)})),["qmake"].forEach((e=>n(1910)(`./prism-${e}`))),delete globalThis.Prism}(r.My)},1107:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});n(6540);var r=n(4164),o=n(1312),a=n(6342),i=n(8774),l=n(3427);const s={anchorWithStickyNavbar:"anchorWithStickyNavbar_LWe7",anchorWithHideOnScrollNavbar:"anchorWithHideOnScrollNavbar_WYt5"};var c=n(4848);function u(e){let{as:t,id:n,...u}=e;const d=(0,l.A)(),{navbar:{hideOnScroll:f}}=(0,a.p)();if("h1"===t||!n)return(0,c.jsx)(t,{...u,id:void 0});d.collectAnchor(n);const p=(0,o.T)({id:"theme.common.headingLinkTitle",message:"Direct link to {heading}",description:"Title for link to heading"},{heading:"string"==typeof u.children?u.children:n});return(0,c.jsxs)(t,{...u,className:(0,r.A)("anchor",f?s.anchorWithHideOnScrollNavbar:s.anchorWithStickyNavbar,u.className),id:n,children:[u.children,(0,c.jsx)(i.A,{className:"hash-link",to:`#${n}`,"aria-label":p,title:p,children:"\u200b"})]})}},3186:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});n(6540);const r={iconExternalLink:"iconExternalLink_nPIU"};var o=n(4848);function a(e){let{width:t=13.5,height:n=13.5}=e;return(0,o.jsx)("svg",{width:t,height:n,"aria-hidden":"true",viewBox:"0 0 24 24",className:r.iconExternalLink,children:(0,o.jsx)("path",{fill:"currentColor",d:"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"})})}},1957:(e,t,n)=>{"use strict";n.d(t,{A:()=>Tt});var r=n(6540),o=n(4164),a=n(7489),i=n(9024),l=n(6347),s=n(1312),c=n(5062),u=n(4848);const d="__docusaurus_skipToContent_fallback";function f(e){e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")}function p(){const e=(0,r.useRef)(null),{action:t}=(0,l.W6)(),n=(0,r.useCallback)((e=>{e.preventDefault();const t=document.querySelector("main:first-of-type")??document.getElementById(d);t&&f(t)}),[]);return(0,c.$)((n=>{let{location:r}=n;e.current&&!r.hash&&"PUSH"===t&&f(e.current)})),{containerRef:e,onClick:n}}const m=(0,s.T)({id:"theme.common.skipToMainContent",description:"The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",message:"Skip to main content"});function h(e){const t=e.children??m,{containerRef:n,onClick:r}=p();return(0,u.jsx)("div",{ref:n,role:"region","aria-label":m,children:(0,u.jsx)("a",{...e,href:`#${d}`,onClick:r,children:t})})}var g=n(7559),y=n(4090);const b={skipToContent:"skipToContent_fXgn"};function v(){return(0,u.jsx)(h,{className:b.skipToContent})}var S=n(6342),E=n(5041);function w(e){let{width:t=21,height:n=21,color:r="currentColor",strokeWidth:o=1.2,className:a,...i}=e;return(0,u.jsx)("svg",{viewBox:"0 0 15 15",width:t,height:n,...i,children:(0,u.jsx)("g",{stroke:r,strokeWidth:o,children:(0,u.jsx)("path",{d:"M.75.75l13.5 13.5M14.25.75L.75 14.25"})})})}const _={closeButton:"closeButton_CVFx"};function k(e){return(0,u.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.AnnouncementBar.closeButtonAriaLabel",message:"Close",description:"The ARIA label for close button of announcement bar"}),...e,className:(0,o.A)("clean-btn close",_.closeButton,e.className),children:(0,u.jsx)(w,{width:14,height:14,strokeWidth:3.1})})}const O={content:"content_knG7"};function T(e){const{announcementBar:t}=(0,S.p)(),{content:n}=t;return(0,u.jsx)("div",{...e,className:(0,o.A)(O.content,e.className),dangerouslySetInnerHTML:{__html:n}})}const x={announcementBar:"announcementBar_mb4j",announcementBarPlaceholder:"announcementBarPlaceholder_vyr4",announcementBarClose:"announcementBarClose_gvF7",announcementBarContent:"announcementBarContent_xLdY"};function A(){const{announcementBar:e}=(0,S.p)(),{isActive:t,close:n}=(0,E.M)();if(!t)return null;const{backgroundColor:r,textColor:o,isCloseable:a}=e;return(0,u.jsxs)("div",{className:x.announcementBar,style:{backgroundColor:r,color:o},role:"banner",children:[a&&(0,u.jsx)("div",{className:x.announcementBarPlaceholder}),(0,u.jsx)(T,{className:x.announcementBarContent}),a&&(0,u.jsx)(k,{onClick:n,className:x.announcementBarClose})]})}var C=n(2069),I=n(3104);var R=n(9532),P=n(5600);const N=r.createContext(null);function L(e){let{children:t}=e;const n=function(){const e=(0,C.M)(),t=(0,P.YL)(),[n,o]=(0,r.useState)(!1),a=null!==t.component,i=(0,R.ZC)(a);return(0,r.useEffect)((()=>{a&&!i&&o(!0)}),[a,i]),(0,r.useEffect)((()=>{a?e.shown||o(!0):o(!1)}),[e.shown,a]),(0,r.useMemo)((()=>[n,o]),[n])}();return(0,u.jsx)(N.Provider,{value:n,children:t})}function D(e){if(e.component){const t=e.component;return(0,u.jsx)(t,{...e.props})}}function j(){const e=(0,r.useContext)(N);if(!e)throw new R.dV("NavbarSecondaryMenuDisplayProvider");const[t,n]=e,o=(0,r.useCallback)((()=>n(!1)),[n]),a=(0,P.YL)();return(0,r.useMemo)((()=>({shown:t,hide:o,content:D(a)})),[o,a,t])}function M(e){let{header:t,primaryMenu:n,secondaryMenu:r}=e;const{shown:a}=j();return(0,u.jsxs)("div",{className:"navbar-sidebar",children:[t,(0,u.jsxs)("div",{className:(0,o.A)("navbar-sidebar__items",{"navbar-sidebar__items--show-secondary":a}),children:[(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:n}),(0,u.jsx)("div",{className:"navbar-sidebar__item menu",children:r})]})]})}var F=n(5293),U=n(2303);function B(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"})})}function z(e){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:24,height:24,...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"})})}const $={toggle:"toggle_vylO",toggleButton:"toggleButton_gllP",darkToggleIcon:"darkToggleIcon_wfgR",lightToggleIcon:"lightToggleIcon_pyhR",toggleButtonDisabled:"toggleButtonDisabled_aARS"};function H(e){let{className:t,buttonClassName:n,value:r,onChange:a}=e;const i=(0,U.A)(),l=(0,s.T)({message:"Switch between dark and light mode (currently {mode})",id:"theme.colorToggle.ariaLabel",description:"The ARIA label for the navbar color mode toggle"},{mode:"dark"===r?(0,s.T)({message:"dark mode",id:"theme.colorToggle.ariaLabel.mode.dark",description:"The name for the dark color mode"}):(0,s.T)({message:"light mode",id:"theme.colorToggle.ariaLabel.mode.light",description:"The name for the light color mode"})});return(0,u.jsx)("div",{className:(0,o.A)($.toggle,t),children:(0,u.jsxs)("button",{className:(0,o.A)("clean-btn",$.toggleButton,!i&&$.toggleButtonDisabled,n),type:"button",onClick:()=>a("dark"===r?"light":"dark"),disabled:!i,title:l,"aria-label":l,"aria-live":"polite",children:[(0,u.jsx)(B,{className:(0,o.A)($.toggleIcon,$.lightToggleIcon)}),(0,u.jsx)(z,{className:(0,o.A)($.toggleIcon,$.darkToggleIcon)})]})})}const V=r.memo(H),G={darkNavbarColorModeToggle:"darkNavbarColorModeToggle_X3D1"};function q(e){let{className:t}=e;const n=(0,S.p)().navbar.style,r=(0,S.p)().colorMode.disableSwitch,{colorMode:o,setColorMode:a}=(0,F.G)();return r?null:(0,u.jsx)(V,{className:t,buttonClassName:"dark"===n?G.darkNavbarColorModeToggle:void 0,value:o,onChange:a})}var W=n(3465);function K(){return(0,u.jsx)(W.A,{className:"navbar__brand",imageClassName:"navbar__logo",titleClassName:"navbar__title text--truncate"})}function Y(){const e=(0,C.M)();return(0,u.jsx)("button",{type:"button","aria-label":(0,s.T)({id:"theme.docs.sidebar.closeSidebarButtonAriaLabel",message:"Close navigation bar",description:"The ARIA label for close button of mobile sidebar"}),className:"clean-btn navbar-sidebar__close",onClick:()=>e.toggle(),children:(0,u.jsx)(w,{color:"var(--ifm-color-emphasis-600)"})})}function X(){return(0,u.jsxs)("div",{className:"navbar-sidebar__brand",children:[(0,u.jsx)(K,{}),(0,u.jsx)(q,{className:"margin-right--md"}),(0,u.jsx)(Y,{})]})}var Q=n(8774),Z=n(6025),J=n(6654),ee=n(1252),te=n(3186);function ne(e){let{activeBasePath:t,activeBaseRegex:n,to:r,href:o,label:a,html:i,isDropdownLink:l,prependBaseUrlToHref:s,...c}=e;const d=(0,Z.Ay)(r),f=(0,Z.Ay)(t),p=(0,Z.Ay)(o,{forcePrependBaseUrl:!0}),m=a&&o&&!(0,J.A)(o),h=i?{dangerouslySetInnerHTML:{__html:i}}:{children:(0,u.jsxs)(u.Fragment,{children:[a,m&&(0,u.jsx)(te.A,{...l&&{width:12,height:12}})]})};return o?(0,u.jsx)(Q.A,{href:s?p:o,...c,...h}):(0,u.jsx)(Q.A,{to:d,isNavLink:!0,...(t||n)&&{isActive:(e,t)=>n?(0,ee.G)(n,t.pathname):t.pathname.startsWith(f)},...c,...h})}function re(e){let{className:t,isDropdownItem:n=!1,...r}=e;const a=(0,u.jsx)(ne,{className:(0,o.A)(n?"dropdown__link":"navbar__item navbar__link",t),isDropdownLink:n,...r});return n?(0,u.jsx)("li",{children:a}):a}function oe(e){let{className:t,isDropdownItem:n,...r}=e;return(0,u.jsx)("li",{className:"menu__list-item",children:(0,u.jsx)(ne,{className:(0,o.A)("menu__link",t),...r})})}function ae(e){let{mobile:t=!1,position:n,...r}=e;const o=t?oe:re;return(0,u.jsx)(o,{...r,activeClassName:r.activeClassName??(t?"menu__link--active":"navbar__link--active")})}var ie=n(1422),le=n(9169),se=n(4586);const ce={dropdownNavbarItemMobile:"dropdownNavbarItemMobile_S0Fm"};function ue(e,t){return e.some((e=>function(e,t){return!!(0,le.ys)(e.to,t)||!!(0,ee.G)(e.activeBaseRegex,t)||!(!e.activeBasePath||!t.startsWith(e.activeBasePath))}(e,t)))}function de(e){let{items:t,position:n,className:a,onClick:i,...l}=e;const s=(0,r.useRef)(null),[c,d]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{const e=e=>{s.current&&!s.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("focusin",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("focusin",e)}}),[s]),(0,u.jsxs)("div",{ref:s,className:(0,o.A)("navbar__item","dropdown","dropdown--hoverable",{"dropdown--right":"right"===n,"dropdown--show":c}),children:[(0,u.jsx)(ne,{"aria-haspopup":"true","aria-expanded":c,role:"button",href:l.to?void 0:"#",className:(0,o.A)("navbar__link",a),...l,onClick:l.to?void 0:e=>e.preventDefault(),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d(!c))},children:l.children??l.label}),(0,u.jsx)("ul",{className:"dropdown__menu",children:t.map(((e,t)=>(0,r.createElement)(Fe,{isDropdownItem:!0,activeClassName:"dropdown__link--active",...e,key:t})))})]})}function fe(e){let{items:t,className:n,position:a,onClick:i,...s}=e;const c=function(){const{siteConfig:{baseUrl:e}}=(0,se.A)(),{pathname:t}=(0,l.zy)();return t.replace(e,"/")}(),d=ue(t,c),{collapsed:f,toggleCollapsed:p,setCollapsed:m}=(0,ie.u)({initialState:()=>!d});return(0,r.useEffect)((()=>{d&&m(!d)}),[c,d,m]),(0,u.jsxs)("li",{className:(0,o.A)("menu__list-item",{"menu__list-item--collapsed":f}),children:[(0,u.jsx)(ne,{role:"button",className:(0,o.A)(ce.dropdownNavbarItemMobile,"menu__link menu__link--sublist menu__link--sublist-caret",n),...s,onClick:e=>{e.preventDefault(),p()},children:s.children??s.label}),(0,u.jsx)(ie.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:f,children:t.map(((e,t)=>(0,r.createElement)(Fe,{mobile:!0,isDropdownItem:!0,onClick:i,activeClassName:"menu__link--active",...e,key:t})))})]})}function pe(e){let{mobile:t=!1,...n}=e;const r=t?fe:de;return(0,u.jsx)(r,{...n})}var me=n(2131);function he(e){let{width:t=20,height:n=20,...r}=e;return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:n,"aria-hidden":!0,...r,children:(0,u.jsx)("path",{fill:"currentColor",d:"M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"})})}const ge="iconLanguage_nlXk";var ye=n(961),be=n(3219),ve=n(5260),Se=n(4255),Ee=n(1062),we=n(2967),_e=n(2565);function ke(){return[`language:${(0,se.A)().i18n.currentLocale}`,function(){const e=(0,_e.v)();return[we.C,...e]}().map((e=>`docusaurus_tag:${e}`))]}const Oe={button:{buttonText:(0,s.T)({id:"theme.SearchBar.label",message:"Search",description:"The ARIA label and placeholder for search button"}),buttonAriaLabel:(0,s.T)({id:"theme.SearchBar.label",message:"Search",description:"The ARIA label and placeholder for search button"})},modal:{searchBox:{resetButtonTitle:(0,s.T)({id:"theme.SearchModal.searchBox.resetButtonTitle",message:"Clear the query",description:"The label and ARIA label for search box reset button"}),resetButtonAriaLabel:(0,s.T)({id:"theme.SearchModal.searchBox.resetButtonTitle",message:"Clear the query",description:"The label and ARIA label for search box reset button"}),cancelButtonText:(0,s.T)({id:"theme.SearchModal.searchBox.cancelButtonText",message:"Cancel",description:"The label and ARIA label for search box cancel button"}),cancelButtonAriaLabel:(0,s.T)({id:"theme.SearchModal.searchBox.cancelButtonText",message:"Cancel",description:"The label and ARIA label for search box cancel button"})},startScreen:{recentSearchesTitle:(0,s.T)({id:"theme.SearchModal.startScreen.recentSearchesTitle",message:"Recent",description:"The title for recent searches"}),noRecentSearchesText:(0,s.T)({id:"theme.SearchModal.startScreen.noRecentSearchesText",message:"No recent searches",description:"The text when no recent searches"}),saveRecentSearchButtonTitle:(0,s.T)({id:"theme.SearchModal.startScreen.saveRecentSearchButtonTitle",message:"Save this search",description:"The label for save recent search button"}),removeRecentSearchButtonTitle:(0,s.T)({id:"theme.SearchModal.startScreen.removeRecentSearchButtonTitle",message:"Remove this search from history",description:"The label for remove recent search button"}),favoriteSearchesTitle:(0,s.T)({id:"theme.SearchModal.startScreen.favoriteSearchesTitle",message:"Favorite",description:"The title for favorite searches"}),removeFavoriteSearchButtonTitle:(0,s.T)({id:"theme.SearchModal.startScreen.removeFavoriteSearchButtonTitle",message:"Remove this search from favorites",description:"The label for remove favorite search button"})},errorScreen:{titleText:(0,s.T)({id:"theme.SearchModal.errorScreen.titleText",message:"Unable to fetch results",description:"The title for error screen of search modal"}),helpText:(0,s.T)({id:"theme.SearchModal.errorScreen.helpText",message:"You might want to check your network connection.",description:"The help text for error screen of search modal"})},footer:{selectText:(0,s.T)({id:"theme.SearchModal.footer.selectText",message:"to select",description:"The explanatory text of the action for the enter key"}),selectKeyAriaLabel:(0,s.T)({id:"theme.SearchModal.footer.selectKeyAriaLabel",message:"Enter key",description:"The ARIA label for the Enter key button that makes the selection"}),navigateText:(0,s.T)({id:"theme.SearchModal.footer.navigateText",message:"to navigate",description:"The explanatory text of the action for the Arrow up and Arrow down key"}),navigateUpKeyAriaLabel:(0,s.T)({id:"theme.SearchModal.footer.navigateUpKeyAriaLabel",message:"Arrow up",description:"The ARIA label for the Arrow up key button that makes the navigation"}),navigateDownKeyAriaLabel:(0,s.T)({id:"theme.SearchModal.footer.navigateDownKeyAriaLabel",message:"Arrow down",description:"The ARIA label for the Arrow down key button that makes the navigation"}),closeText:(0,s.T)({id:"theme.SearchModal.footer.closeText",message:"to close",description:"The explanatory text of the action for Escape key"}),closeKeyAriaLabel:(0,s.T)({id:"theme.SearchModal.footer.closeKeyAriaLabel",message:"Escape key",description:"The ARIA label for the Escape key button that close the modal"}),searchByText:(0,s.T)({id:"theme.SearchModal.footer.searchByText",message:"Search by",description:"The text explain that the search is making by Algolia"})},noResultsScreen:{noResultsText:(0,s.T)({id:"theme.SearchModal.noResultsScreen.noResultsText",message:"No results for",description:"The text explains that there are no results for the following search"}),suggestedQueryText:(0,s.T)({id:"theme.SearchModal.noResultsScreen.suggestedQueryText",message:"Try searching for",description:"The text for the suggested query when no results are found for the following search"}),reportMissingResultsText:(0,s.T)({id:"theme.SearchModal.noResultsScreen.reportMissingResultsText",message:"Believe this query should return results?",description:"The text for the question where the user thinks there are missing results"}),reportMissingResultsLinkText:(0,s.T)({id:"theme.SearchModal.noResultsScreen.reportMissingResultsLinkText",message:"Let us know.",description:"The text for the link to report missing results"})}},placeholder:(0,s.T)({id:"theme.SearchModal.placeholder",message:"Search docs",description:"The placeholder of the input of the DocSearch pop-up modal"})};let Te=null;function xe(e){let{hit:t,children:n}=e;return(0,u.jsx)(Q.A,{to:t.url,children:n})}function Ae(e){let{state:t,onClose:n}=e;const r=(0,Se.w)();return(0,u.jsx)(Q.A,{to:r(t.query),onClick:n,children:(0,u.jsx)(s.A,{id:"theme.SearchBar.seeAll",values:{count:t.context.nbHits},children:"See all {count} results"})})}function Ce(e){let{contextualSearch:t,externalUrlRegex:o,...a}=e;const{siteMetadata:i}=(0,se.A)(),s=(0,Ee.C)(),c=ke(),d=a.searchParameters?.facetFilters??[],f=t?function(e,t){const n=e=>"string"==typeof e?[e]:e;return[...n(e),...n(t)]}(c,d):d,p={...a.searchParameters,facetFilters:f},m=(0,l.W6)(),h=(0,r.useRef)(null),g=(0,r.useRef)(null),[y,b]=(0,r.useState)(!1),[v,S]=(0,r.useState)(void 0),E=(0,r.useCallback)((()=>Te?Promise.resolve():Promise.all([n.e(158).then(n.bind(n,8158)),Promise.all([n.e(869),n.e(913)]).then(n.bind(n,8913)),Promise.all([n.e(869),n.e(416)]).then(n.bind(n,416))]).then((e=>{let[{DocSearchModal:t}]=e;Te=t}))),[]),w=(0,r.useCallback)((()=>{if(!h.current){const e=document.createElement("div");h.current=e,document.body.insertBefore(e,document.body.firstChild)}}),[]),_=(0,r.useCallback)((()=>{w(),E().then((()=>b(!0)))}),[E,w]),k=(0,r.useCallback)((()=>{b(!1),g.current?.focus()}),[]),O=(0,r.useCallback)((e=>{"f"===e.key&&(e.metaKey||e.ctrlKey)||(e.preventDefault(),S(e.key),_())}),[_]),T=(0,r.useRef)({navigate(e){let{itemUrl:t}=e;(0,ee.G)(o,t)?window.location.href=t:m.push(t)}}).current,x=(0,r.useRef)((e=>a.transformItems?a.transformItems(e):e.map((e=>({...e,url:s(e.url)}))))).current,A=(0,r.useMemo)((()=>e=>(0,u.jsx)(Ae,{...e,onClose:k})),[k]),C=(0,r.useCallback)((e=>(e.addAlgoliaAgent("docusaurus",i.docusaurusVersion),e)),[i.docusaurusVersion]);return(0,be.E8)({isOpen:y,onOpen:_,onClose:k,onInput:O,searchButtonRef:g}),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ve.A,{children:(0,u.jsx)("link",{rel:"preconnect",href:`https://${a.appId}-dsn.algolia.net`,crossOrigin:"anonymous"})}),(0,u.jsx)(be.Bc,{onTouchStart:E,onFocus:E,onMouseOver:E,onClick:_,ref:g,translations:Oe.button}),y&&Te&&h.current&&(0,ye.createPortal)((0,u.jsx)(Te,{onClose:k,initialScrollY:window.scrollY,initialQuery:v,navigator:T,transformItems:x,hitComponent:xe,transformSearchClient:C,...a.searchPagePath&&{resultsFooterComponent:A},...a,searchParameters:p,placeholder:Oe.placeholder,translations:Oe.modal}),h.current)]})}function Ie(){const{siteConfig:e}=(0,se.A)();return(0,u.jsx)(Ce,{...e.themeConfig.algolia})}const Re={navbarSearchContainer:"navbarSearchContainer_Bca1"};function Pe(e){let{children:t,className:n}=e;return(0,u.jsx)("div",{className:(0,o.A)(n,Re.navbarSearchContainer),children:t})}var Ne=n(4070),Le=n(6972);var De=n(3886);function je(e,t){return t.alternateDocVersions[e.name]??function(e){return e.docs.find((t=>t.id===e.mainDocId))}(e)}const Me={default:ae,localeDropdown:function(e){let{mobile:t,dropdownItemsBefore:n,dropdownItemsAfter:r,queryString:o="",...a}=e;const{i18n:{currentLocale:i,locales:c,localeConfigs:d}}=(0,se.A)(),f=(0,me.o)(),{search:p,hash:m}=(0,l.zy)(),h=[...n,...c.map((e=>{const n=`${`pathname://${f.createUrl({locale:e,fullyQualified:!1})}`}${p}${m}${o}`;return{label:d[e].label,lang:d[e].htmlLang,to:n,target:"_self",autoAddBaseUrl:!1,className:e===i?t?"menu__link--active":"dropdown__link--active":""}})),...r],g=t?(0,s.T)({message:"Languages",id:"theme.navbar.mobileLanguageDropdown.label",description:"The label for the mobile language switcher dropdown"}):d[i].label;return(0,u.jsx)(pe,{...a,mobile:t,label:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(he,{className:ge}),g]}),items:h})},search:function(e){let{mobile:t,className:n}=e;return t?null:(0,u.jsx)(Pe,{className:n,children:(0,u.jsx)(Ie,{})})},dropdown:pe,html:function(e){let{value:t,className:n,mobile:r=!1,isDropdownItem:a=!1}=e;const i=a?"li":"div";return(0,u.jsx)(i,{className:(0,o.A)({navbar__item:!r&&!a,"menu__list-item":r},n),dangerouslySetInnerHTML:{__html:t}})},doc:function(e){let{docId:t,label:n,docsPluginId:r,...o}=e;const{activeDoc:a}=(0,Ne.zK)(r),i=(0,Le.QB)(t,r),l=a?.path===i?.path;return null===i||i.unlisted&&!l?null:(0,u.jsx)(ae,{exact:!0,...o,isActive:()=>l||!!a?.sidebar&&a.sidebar===i.sidebar,label:n??i.id,to:i.path})},docSidebar:function(e){let{sidebarId:t,label:n,docsPluginId:r,...o}=e;const{activeDoc:a}=(0,Ne.zK)(r),i=(0,Le.fW)(t,r).link;if(!i)throw new Error(`DocSidebarNavbarItem: Sidebar with ID "${t}" doesn't have anything to be linked to.`);return(0,u.jsx)(ae,{exact:!0,...o,isActive:()=>a?.sidebar===t,label:n??i.label,to:i.path})},docsVersion:function(e){let{label:t,to:n,docsPluginId:r,...o}=e;const a=(0,Le.Vd)(r)[0],i=t??a.label,l=n??(e=>e.docs.find((t=>t.id===e.mainDocId)))(a).path;return(0,u.jsx)(ae,{...o,label:i,to:l})},docsVersionDropdown:function(e){let{mobile:t,docsPluginId:n,dropdownActiveClassDisabled:r,dropdownItemsBefore:o,dropdownItemsAfter:a,...i}=e;const{search:c,hash:d}=(0,l.zy)(),f=(0,Ne.zK)(n),p=(0,Ne.jh)(n),{savePreferredVersionName:m}=(0,De.g1)(n),h=[...o,...p.map((function(e){const t=je(e,f);return{label:e.label,to:`${t.path}${c}${d}`,isActive:()=>e===f.activeVersion,onClick:()=>m(e.name)}})),...a],g=(0,Le.Vd)(n)[0],y=t&&h.length>1?(0,s.T)({id:"theme.navbar.mobileVersionsDropdown.label",message:"Versions",description:"The label for the navbar versions dropdown on mobile view"}):g.label,b=t&&h.length>1?void 0:je(g,f).path;return h.length<=1?(0,u.jsx)(ae,{...i,mobile:t,label:y,to:b,isActive:r?()=>!1:void 0}):(0,u.jsx)(pe,{...i,mobile:t,label:y,to:b,items:h,isActive:r?()=>!1:void 0})}};function Fe(e){let{type:t,...n}=e;const r=function(e,t){return e&&"default"!==e?e:"items"in t?"dropdown":"default"}(t,n),o=Me[r];if(!o)throw new Error(`No NavbarItem component found for type "${t}".`);return(0,u.jsx)(o,{...n})}function Ue(){const e=(0,C.M)(),t=(0,S.p)().navbar.items;return(0,u.jsx)("ul",{className:"menu__list",children:t.map(((t,n)=>(0,r.createElement)(Fe,{mobile:!0,...t,onClick:()=>e.toggle(),key:n})))})}function Be(e){return(0,u.jsx)("button",{...e,type:"button",className:"clean-btn navbar-sidebar__back",children:(0,u.jsx)(s.A,{id:"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel",description:"The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)",children:"\u2190 Back to main menu"})})}function ze(){const e=0===(0,S.p)().navbar.items.length,t=j();return(0,u.jsxs)(u.Fragment,{children:[!e&&(0,u.jsx)(Be,{onClick:()=>t.hide()}),t.content]})}function $e(){const e=(0,C.M)();var t;return void 0===(t=e.shown)&&(t=!0),(0,r.useEffect)((()=>(document.body.style.overflow=t?"hidden":"visible",()=>{document.body.style.overflow="visible"})),[t]),e.shouldRender?(0,u.jsx)(M,{header:(0,u.jsx)(X,{}),primaryMenu:(0,u.jsx)(Ue,{}),secondaryMenu:(0,u.jsx)(ze,{})}):null}const He={navbarHideable:"navbarHideable_m1mJ",navbarHidden:"navbarHidden_jGov"};function Ve(e){return(0,u.jsx)("div",{role:"presentation",...e,className:(0,o.A)("navbar-sidebar__backdrop",e.className)})}function Ge(e){let{children:t}=e;const{navbar:{hideOnScroll:n,style:a}}=(0,S.p)(),i=(0,C.M)(),{navbarRef:l,isNavbarVisible:d}=function(e){const[t,n]=(0,r.useState)(e),o=(0,r.useRef)(!1),a=(0,r.useRef)(0),i=(0,r.useCallback)((e=>{null!==e&&(a.current=e.getBoundingClientRect().height)}),[]);return(0,I.Mq)(((t,r)=>{let{scrollY:i}=t;if(!e)return;if(i=l?n(!1):i+c{if(!e)return;const r=t.location.hash;if(r?document.getElementById(r.substring(1)):void 0)return o.current=!0,void n(!1);n(!0)})),{navbarRef:i,isNavbarVisible:t}}(n);return(0,u.jsxs)("nav",{ref:l,"aria-label":(0,s.T)({id:"theme.NavBar.navAriaLabel",message:"Main",description:"The ARIA label for the main navigation"}),className:(0,o.A)("navbar","navbar--fixed-top",n&&[He.navbarHideable,!d&&He.navbarHidden],{"navbar--dark":"dark"===a,"navbar--primary":"primary"===a,"navbar-sidebar--show":i.shown}),children:[t,(0,u.jsx)(Ve,{onClick:i.toggle}),(0,u.jsx)($e,{})]})}var qe=n(440);const We={errorBoundaryError:"errorBoundaryError_a6uf",errorBoundaryFallback:"errorBoundaryFallback_VBag"};function Ke(e){return(0,u.jsx)("button",{type:"button",...e,children:(0,u.jsx)(s.A,{id:"theme.ErrorPageContent.tryAgain",description:"The label of the button to try again rendering when the React error boundary captures an error",children:"Try again"})})}function Ye(e){let{error:t}=e;const n=(0,qe.rA)(t).map((e=>e.message)).join("\n\nCause:\n");return(0,u.jsx)("p",{className:We.errorBoundaryError,children:n})}class Xe extends r.Component{componentDidCatch(e,t){throw this.props.onError(e,t)}render(){return this.props.children}}const Qe="right";function Ze(e){let{width:t=30,height:n=30,className:r,...o}=e;return(0,u.jsx)("svg",{className:r,width:t,height:n,viewBox:"0 0 30 30","aria-hidden":"true",...o,children:(0,u.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"})})}function Je(){const{toggle:e,shown:t}=(0,C.M)();return(0,u.jsx)("button",{onClick:e,"aria-label":(0,s.T)({id:"theme.docs.sidebar.toggleSidebarButtonAriaLabel",message:"Toggle navigation bar",description:"The ARIA label for hamburger menu button of mobile navigation"}),"aria-expanded":t,className:"navbar__toggle clean-btn",type:"button",children:(0,u.jsx)(Ze,{})})}const et={colorModeToggle:"colorModeToggle_DEke"};function tt(e){let{items:t}=e;return(0,u.jsx)(u.Fragment,{children:t.map(((e,t)=>(0,u.jsx)(Xe,{onError:t=>new Error(`A theme navbar item failed to render.\nPlease double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:\n${JSON.stringify(e,null,2)}`,{cause:t}),children:(0,u.jsx)(Fe,{...e})},t)))})}function nt(e){let{left:t,right:n}=e;return(0,u.jsxs)("div",{className:"navbar__inner",children:[(0,u.jsx)("div",{className:"navbar__items",children:t}),(0,u.jsx)("div",{className:"navbar__items navbar__items--right",children:n})]})}function rt(){const e=(0,C.M)(),t=(0,S.p)().navbar.items,[n,r]=function(e){function t(e){return"left"===(e.position??Qe)}return[e.filter(t),e.filter((e=>!t(e)))]}(t),o=t.find((e=>"search"===e.type));return(0,u.jsx)(nt,{left:(0,u.jsxs)(u.Fragment,{children:[!e.disabled&&(0,u.jsx)(Je,{}),(0,u.jsx)(K,{}),(0,u.jsx)(tt,{items:n})]}),right:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(tt,{items:r}),(0,u.jsx)(q,{className:et.colorModeToggle}),!o&&(0,u.jsx)(Pe,{children:(0,u.jsx)(Ie,{})})]})})}function ot(){return(0,u.jsx)(Ge,{children:(0,u.jsx)(rt,{})})}function at(e){let{item:t}=e;const{to:n,href:r,label:o,prependBaseUrlToHref:a,...i}=t,l=(0,Z.Ay)(n),s=(0,Z.Ay)(r,{forcePrependBaseUrl:!0});return(0,u.jsxs)(Q.A,{className:"footer__link-item",...r?{href:a?s:r}:{to:l},...i,children:[o,r&&!(0,J.A)(r)&&(0,u.jsx)(te.A,{})]})}function it(e){let{item:t}=e;return t.html?(0,u.jsx)("li",{className:"footer__item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)("li",{className:"footer__item",children:(0,u.jsx)(at,{item:t})},t.href??t.to)}function lt(e){let{column:t}=e;return(0,u.jsxs)("div",{className:"col footer__col",children:[(0,u.jsx)("div",{className:"footer__title",children:t.title}),(0,u.jsx)("ul",{className:"footer__items clean-list",children:t.items.map(((e,t)=>(0,u.jsx)(it,{item:e},t)))})]})}function st(e){let{columns:t}=e;return(0,u.jsx)("div",{className:"row footer__links",children:t.map(((e,t)=>(0,u.jsx)(lt,{column:e},t)))})}function ct(){return(0,u.jsx)("span",{className:"footer__link-separator",children:"\xb7"})}function ut(e){let{item:t}=e;return t.html?(0,u.jsx)("span",{className:"footer__link-item",dangerouslySetInnerHTML:{__html:t.html}}):(0,u.jsx)(at,{item:t})}function dt(e){let{links:t}=e;return(0,u.jsx)("div",{className:"footer__links text--center",children:(0,u.jsx)("div",{className:"footer__links",children:t.map(((e,n)=>(0,u.jsxs)(r.Fragment,{children:[(0,u.jsx)(ut,{item:e}),t.length!==n+1&&(0,u.jsx)(ct,{})]},n)))})})}function ft(e){let{links:t}=e;return function(e){return"title"in e[0]}(t)?(0,u.jsx)(st,{columns:t}):(0,u.jsx)(dt,{links:t})}var pt=n(1122);const mt={footerLogoLink:"footerLogoLink_BH7S"};function ht(e){let{logo:t}=e;const{withBaseUrl:n}=(0,Z.hH)(),r={light:n(t.src),dark:n(t.srcDark??t.src)};return(0,u.jsx)(pt.A,{className:(0,o.A)("footer__logo",t.className),alt:t.alt,sources:r,width:t.width,height:t.height,style:t.style})}function gt(e){let{logo:t}=e;return t.href?(0,u.jsx)(Q.A,{href:t.href,className:mt.footerLogoLink,target:t.target,children:(0,u.jsx)(ht,{logo:t})}):(0,u.jsx)(ht,{logo:t})}function yt(e){let{copyright:t}=e;return(0,u.jsx)("div",{className:"footer__copyright",dangerouslySetInnerHTML:{__html:t}})}function bt(e){let{style:t,links:n,logo:r,copyright:a}=e;return(0,u.jsx)("footer",{className:(0,o.A)("footer",{"footer--dark":"dark"===t}),children:(0,u.jsxs)("div",{className:"container container-fluid",children:[n,(r||a)&&(0,u.jsxs)("div",{className:"footer__bottom text--center",children:[r&&(0,u.jsx)("div",{className:"margin-bottom--sm",children:r}),a]})]})})}function vt(){const{footer:e}=(0,S.p)();if(!e)return null;const{copyright:t,links:n,logo:r,style:o}=e;return(0,u.jsx)(bt,{style:o,links:n&&n.length>0&&(0,u.jsx)(ft,{links:n}),logo:r&&(0,u.jsx)(gt,{logo:r}),copyright:t&&(0,u.jsx)(yt,{copyright:t})})}const St=r.memo(vt),Et=(0,R.fM)([F.a,E.o,I.Tv,De.VQ,i.Jx,function(e){let{children:t}=e;return(0,u.jsx)(P.y_,{children:(0,u.jsx)(C.e,{children:(0,u.jsx)(L,{children:t})})})}]);function wt(e){let{children:t}=e;return(0,u.jsx)(Et,{children:t})}var _t=n(1107);function kt(e){let{error:t,tryAgain:n}=e;return(0,u.jsx)("main",{className:"container margin-vert--xl",children:(0,u.jsx)("div",{className:"row",children:(0,u.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,u.jsx)(_t.A,{as:"h1",className:"hero__title",children:(0,u.jsx)(s.A,{id:"theme.ErrorPageContent.title",description:"The title of the fallback page when the page crashed",children:"This page crashed."})}),(0,u.jsx)("div",{className:"margin-vert--lg",children:(0,u.jsx)(Ke,{onClick:n,className:"button button--primary shadow--lw"})}),(0,u.jsx)("hr",{}),(0,u.jsx)("div",{className:"margin-vert--md",children:(0,u.jsx)(Ye,{error:t})})]})})})}const Ot={mainWrapper:"mainWrapper_z2l0"};function Tt(e){const{children:t,noFooter:n,wrapperClassName:r,title:l,description:s}=e;return(0,y.J)(),(0,u.jsxs)(wt,{children:[(0,u.jsx)(i.be,{title:l,description:s}),(0,u.jsx)(v,{}),(0,u.jsx)(A,{}),(0,u.jsx)(ot,{}),(0,u.jsx)("div",{id:d,className:(0,o.A)(g.G.wrapper.main,Ot.mainWrapper,r),children:(0,u.jsx)(a.A,{fallback:e=>(0,u.jsx)(kt,{...e}),children:t})}),!n&&(0,u.jsx)(St,{})]})}},3465:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});n(6540);var r=n(8774),o=n(6025),a=n(4586),i=n(6342),l=n(1122),s=n(4848);function c(e){let{logo:t,alt:n,imageClassName:r}=e;const a={light:(0,o.Ay)(t.src),dark:(0,o.Ay)(t.srcDark||t.src)},i=(0,s.jsx)(l.A,{className:t.className,sources:a,height:t.height,width:t.width,alt:n,style:t.style});return r?(0,s.jsx)("div",{className:r,children:i}):i}function u(e){const{siteConfig:{title:t}}=(0,a.A)(),{navbar:{title:n,logo:l}}=(0,i.p)(),{imageClassName:u,titleClassName:d,...f}=e,p=(0,o.Ay)(l?.href||"/"),m=n?"":t,h=l?.alt??m;return(0,s.jsxs)(r.A,{to:p,...f,...l?.target&&{target:l.target},children:[l&&(0,s.jsx)(c,{logo:l,alt:h,imageClassName:u}),null!=n&&(0,s.jsx)("b",{className:d,children:n})]})}},1463:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});n(6540);var r=n(5260),o=n(4848);function a(e){let{locale:t,version:n,tag:a}=e;const i=t;return(0,o.jsxs)(r.A,{children:[t&&(0,o.jsx)("meta",{name:"docusaurus_locale",content:t}),n&&(0,o.jsx)("meta",{name:"docusaurus_version",content:n}),a&&(0,o.jsx)("meta",{name:"docusaurus_tag",content:a}),i&&(0,o.jsx)("meta",{name:"docsearch:language",content:i}),n&&(0,o.jsx)("meta",{name:"docsearch:version",content:n}),a&&(0,o.jsx)("meta",{name:"docsearch:docusaurus_tag",content:a})]})}},1122:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var r=n(6540),o=n(4164),a=n(2303),i=n(5293);const l={themedComponent:"themedComponent_mlkZ","themedComponent--light":"themedComponent--light_NVdE","themedComponent--dark":"themedComponent--dark_xIcU"};var s=n(4848);function c(e){let{className:t,children:n}=e;const c=(0,a.A)(),{colorMode:u}=(0,i.G)();return(0,s.jsx)(s.Fragment,{children:(c?"dark"===u?["dark"]:["light"]:["light","dark"]).map((e=>{const a=n({theme:e,className:(0,o.A)(t,l.themedComponent,l[`themedComponent--${e}`])});return(0,s.jsx)(r.Fragment,{children:a},e)}))})}function u(e){const{sources:t,className:n,alt:r,...o}=e;return(0,s.jsx)(c,{className:n,children:e=>{let{theme:n,className:a}=e;return(0,s.jsx)("img",{src:t[n],alt:r,className:a,...o})}})}},1422:(e,t,n)=>{"use strict";n.d(t,{N:()=>y,u:()=>c});var r=n(6540),o=n(8193),a=n(205),i=n(3109),l=n(4848);const s="ease-in-out";function c(e){let{initialState:t}=e;const[n,o]=(0,r.useState)(t??!1),a=(0,r.useCallback)((()=>{o((e=>!e))}),[]);return{collapsed:n,setCollapsed:o,toggleCollapsed:a}}const u={display:"none",overflow:"hidden",height:"0px"},d={display:"block",overflow:"visible",height:"auto"};function f(e,t){const n=t?u:d;e.style.display=n.display,e.style.overflow=n.overflow,e.style.height=n.height}function p(e){let{collapsibleRef:t,collapsed:n,animation:o}=e;const a=(0,r.useRef)(!1);(0,r.useEffect)((()=>{const e=t.current;function r(){const t=e.scrollHeight,n=o?.duration??function(e){if((0,i.O)())return 1;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}(t);return{transition:`height ${n}ms ${o?.easing??s}`,height:`${t}px`}}function l(){const t=r();e.style.transition=t.transition,e.style.height=t.height}if(!a.current)return f(e,n),void(a.current=!0);return e.style.willChange="height",function(){const t=requestAnimationFrame((()=>{n?(l(),requestAnimationFrame((()=>{e.style.height=u.height,e.style.overflow=u.overflow}))):(e.style.display="block",requestAnimationFrame((()=>{l()})))}));return()=>cancelAnimationFrame(t)}()}),[t,n,o])}function m(e){if(!o.A.canUseDOM)return e?u:d}function h(e){let{as:t="div",collapsed:n,children:o,animation:a,onCollapseTransitionEnd:i,className:s,disableSSRStyle:c}=e;const u=(0,r.useRef)(null);return p({collapsibleRef:u,collapsed:n,animation:a}),(0,l.jsx)(t,{ref:u,style:c?void 0:m(n),onTransitionEnd:e=>{"height"===e.propertyName&&(f(u.current,n),i?.(n))},className:s,children:o})}function g(e){let{collapsed:t,...n}=e;const[o,i]=(0,r.useState)(!t),[s,c]=(0,r.useState)(t);return(0,a.A)((()=>{t||i(!0)}),[t]),(0,a.A)((()=>{o&&c(t)}),[o,t]),o?(0,l.jsx)(h,{...n,collapsed:s}):null}function y(e){let{lazy:t,...n}=e;const r=t?g:h;return(0,l.jsx)(r,{...n})}},5041:(e,t,n)=>{"use strict";n.d(t,{M:()=>h,o:()=>m});var r=n(6540),o=n(2303),a=n(679),i=n(9532),l=n(6342),s=n(4848);const c=(0,a.Wf)("docusaurus.announcement.dismiss"),u=(0,a.Wf)("docusaurus.announcement.id"),d=()=>"true"===c.get(),f=e=>c.set(String(e)),p=r.createContext(null);function m(e){let{children:t}=e;const n=function(){const{announcementBar:e}=(0,l.p)(),t=(0,o.A)(),[n,a]=(0,r.useState)((()=>!!t&&d()));(0,r.useEffect)((()=>{a(d())}),[]);const i=(0,r.useCallback)((()=>{f(!0),a(!0)}),[]);return(0,r.useEffect)((()=>{if(!e)return;const{id:t}=e;let n=u.get();"annoucement-bar"===n&&(n="announcement-bar");const r=t!==n;u.set(t),r&&f(!1),!r&&d()||a(!1)}),[e]),(0,r.useMemo)((()=>({isActive:!!e&&!n,close:i})),[e,n,i])}();return(0,s.jsx)(p.Provider,{value:n,children:t})}function h(){const e=(0,r.useContext)(p);if(!e)throw new i.dV("AnnouncementBarProvider");return e}},5293:(e,t,n)=>{"use strict";n.d(t,{G:()=>y,a:()=>g});var r=n(6540),o=n(8193),a=n(9532),i=n(679),l=n(6342),s=n(4848);const c=r.createContext(void 0),u="theme",d=(0,i.Wf)(u),f={light:"light",dark:"dark"},p=e=>e===f.dark?f.dark:f.light,m=e=>o.A.canUseDOM?p(document.documentElement.getAttribute("data-theme")):p(e),h=e=>{d.set(p(e))};function g(e){let{children:t}=e;const n=function(){const{colorMode:{defaultMode:e,disableSwitch:t,respectPrefersColorScheme:n}}=(0,l.p)(),[o,a]=(0,r.useState)(m(e));(0,r.useEffect)((()=>{t&&d.del()}),[t]);const i=(0,r.useCallback)((function(t,r){void 0===r&&(r={});const{persist:o=!0}=r;t?(a(t),o&&h(t)):(a(n?window.matchMedia("(prefers-color-scheme: dark)").matches?f.dark:f.light:e),d.del())}),[n,e]);(0,r.useEffect)((()=>{document.documentElement.setAttribute("data-theme",p(o))}),[o]),(0,r.useEffect)((()=>{if(t)return;const e=e=>{if(e.key!==u)return;const t=d.get();null!==t&&i(p(t))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[t,i]);const s=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(t&&!n)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{window.matchMedia("print").matches||s.current?s.current=window.matchMedia("print").matches:i(null)};return e.addListener(r),()=>e.removeListener(r)}),[i,t,n]),(0,r.useMemo)((()=>({colorMode:o,setColorMode:i,get isDarkTheme(){return o===f.dark},setLightTheme(){i(f.light)},setDarkTheme(){i(f.dark)}})),[o,i])}();return(0,s.jsx)(c.Provider,{value:n,children:t})}function y(){const e=(0,r.useContext)(c);if(null==e)throw new a.dV("ColorModeProvider","Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.");return e}},2069:(e,t,n)=>{"use strict";n.d(t,{M:()=>p,e:()=>f});var r=n(6540),o=n(5600),a=n(4581),i=n(7485),l=n(6342),s=n(9532),c=n(4848);const u=r.createContext(void 0);function d(){const e=function(){const e=(0,o.YL)(),{items:t}=(0,l.p)().navbar;return 0===t.length&&!e.component}(),t=(0,a.l)(),n=!e&&"mobile"===t,[s,c]=(0,r.useState)(!1);(0,i.$Z)((()=>{if(s)return c(!1),!1}));const u=(0,r.useCallback)((()=>{c((e=>!e))}),[]);return(0,r.useEffect)((()=>{"desktop"===t&&c(!1)}),[t]),(0,r.useMemo)((()=>({disabled:e,shouldRender:n,toggle:u,shown:s})),[e,n,u,s])}function f(e){let{children:t}=e;const n=d();return(0,c.jsx)(u.Provider,{value:n,children:t})}function p(){const e=r.useContext(u);if(void 0===e)throw new s.dV("NavbarMobileSidebarProvider");return e}},5600:(e,t,n)=>{"use strict";n.d(t,{GX:()=>c,YL:()=>s,y_:()=>l});var r=n(6540),o=n(9532),a=n(4848);const i=r.createContext(null);function l(e){let{children:t}=e;const n=(0,r.useState)({component:null,props:null});return(0,a.jsx)(i.Provider,{value:n,children:t})}function s(){const e=(0,r.useContext)(i);if(!e)throw new o.dV("NavbarSecondaryMenuContentProvider");return e[0]}function c(e){let{component:t,props:n}=e;const a=(0,r.useContext)(i);if(!a)throw new o.dV("NavbarSecondaryMenuContentProvider");const[,l]=a,s=(0,o.Be)(n);return(0,r.useEffect)((()=>{l({component:t,props:s})}),[l,t,s]),(0,r.useEffect)((()=>()=>l({component:null,props:null})),[l]),null}},4090:(e,t,n)=>{"use strict";n.d(t,{w:()=>o,J:()=>a});var r=n(6540);const o="navigation-with-keyboard";function a(){(0,r.useEffect)((()=>{function e(e){"keydown"===e.type&&"Tab"===e.key&&document.body.classList.add(o),"mousedown"===e.type&&document.body.classList.remove(o)}return document.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{document.body.classList.remove(o),document.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}}),[])}},4255:(e,t,n)=>{"use strict";n.d(t,{b:()=>l,w:()=>s});var r=n(6540),o=n(4586),a=n(7485);const i="q";function l(){return(0,a.l)(i)}function s(){const{siteConfig:{baseUrl:e,themeConfig:t}}=(0,o.A)(),{algolia:{searchPagePath:n}}=t;return(0,r.useCallback)((t=>`${e}${n}?${i}=${encodeURIComponent(t)}`),[e,n])}},4581:(e,t,n)=>{"use strict";n.d(t,{l:()=>l});var r=n(6540),o=n(8193);const a={desktop:"desktop",mobile:"mobile",ssr:"ssr"},i=996;function l(e){let{desktopBreakpoint:t=i}=void 0===e?{}:e;const[n,l]=(0,r.useState)((()=>"ssr"));return(0,r.useEffect)((()=>{function e(){l(function(e){if(!o.A.canUseDOM)throw new Error("getWindowSize() should only be called after React hydration");return window.innerWidth>e?a.desktop:a.mobile}(t))}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[t]),n}},7559:(e,t,n)=>{"use strict";n.d(t,{G:()=>r});const r={page:{blogListPage:"blog-list-page",blogPostPage:"blog-post-page",blogTagsListPage:"blog-tags-list-page",blogTagPostListPage:"blog-tags-post-list-page",blogAuthorsListPage:"blog-authors-list-page",blogAuthorsPostsPage:"blog-authors-posts-page",docsDocPage:"docs-doc-page",docsTagsListPage:"docs-tags-list-page",docsTagDocListPage:"docs-tags-doc-list-page",mdxPage:"mdx-page"},wrapper:{main:"main-wrapper",blogPages:"blog-wrapper",docsPages:"docs-wrapper",mdxPages:"mdx-wrapper"},common:{editThisPage:"theme-edit-this-page",lastUpdated:"theme-last-updated",backToTopButton:"theme-back-to-top-button",codeBlock:"theme-code-block",admonition:"theme-admonition",unlistedBanner:"theme-unlisted-banner",draftBanner:"theme-draft-banner",admonitionType:e=>`theme-admonition-${e}`},layout:{},docs:{docVersionBanner:"theme-doc-version-banner",docVersionBadge:"theme-doc-version-badge",docBreadcrumbs:"theme-doc-breadcrumbs",docMarkdown:"theme-doc-markdown",docTocMobile:"theme-doc-toc-mobile",docTocDesktop:"theme-doc-toc-desktop",docFooter:"theme-doc-footer",docFooterTagsRow:"theme-doc-footer-tags-row",docFooterEditMetaRow:"theme-doc-footer-edit-meta-row",docSidebarContainer:"theme-doc-sidebar-container",docSidebarMenu:"theme-doc-sidebar-menu",docSidebarItemCategory:"theme-doc-sidebar-item-category",docSidebarItemLink:"theme-doc-sidebar-item-link",docSidebarItemCategoryLevel:e=>`theme-doc-sidebar-item-category-level-${e}`,docSidebarItemLinkLevel:e=>`theme-doc-sidebar-item-link-level-${e}`},blog:{blogFooterTagsRow:"theme-blog-footer-tags-row",blogFooterEditMetaRow:"theme-blog-footer-edit-meta-row"},pages:{pageFooterEditMetaRow:"theme-pages-footer-edit-meta-row"}}},3109:(e,t,n)=>{"use strict";function r(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}n.d(t,{O:()=>r})},481:(e,t,n)=>{"use strict";n.d(t,{s:()=>o});var r=n(4586);function o(e){const{siteConfig:t}=(0,r.A)(),{title:n,titleDelimiter:o}=t;return e?.trim().length?`${e.trim()} ${o} ${n}`:n}},7485:(e,t,n)=>{"use strict";n.d(t,{$Z:()=>i,aZ:()=>s,l:()=>c});var r=n(6540),o=n(6347),a=n(9532);function i(e){!function(e){const t=(0,o.W6)(),n=(0,a._q)(e);(0,r.useEffect)((()=>t.block(((e,t)=>n(e,t)))),[t,n])}(((t,n)=>{if("POP"===n)return e(t,n)}))}function l(e){const t=(0,o.W6)();return(0,r.useSyncExternalStore)(t.listen,(()=>e(t)),(()=>e(t)))}function s(e){return l((t=>null===e?null:new URLSearchParams(t.location.search).get(e)))}function c(e){const t=s(e)??"",n=function(e){const t=(0,o.W6)();return(0,r.useCallback)(((n,r)=>{const o=new URLSearchParams(t.location.search);n?o.set(e,n):o.delete(e),(r?.push?t.push:t.replace)({search:o.toString()})}),[e,t])}(e);return[t,n]}},1682:(e,t,n)=>{"use strict";function r(e,t){return void 0===t&&(t=(e,t)=>e===t),e.filter(((n,r)=>e.findIndex((e=>t(e,n)))!==r))}function o(e){return Array.from(new Set(e))}n.d(t,{XI:()=>r,sb:()=>o})},9024:(e,t,n)=>{"use strict";n.d(t,{e3:()=>p,be:()=>d,Jx:()=>m});var r=n(6540),o=n(4164),a=n(5260),i=n(3102);function l(){const e=r.useContext(i.o);if(!e)throw new Error("Unexpected: no Docusaurus route context found");return e}var s=n(6025),c=n(481),u=n(4848);function d(e){let{title:t,description:n,keywords:r,image:o,children:i}=e;const l=(0,c.s)(t),{withBaseUrl:d}=(0,s.hH)(),f=o?d(o,{absolute:!0}):void 0;return(0,u.jsxs)(a.A,{children:[t&&(0,u.jsx)("title",{children:l}),t&&(0,u.jsx)("meta",{property:"og:title",content:l}),n&&(0,u.jsx)("meta",{name:"description",content:n}),n&&(0,u.jsx)("meta",{property:"og:description",content:n}),r&&(0,u.jsx)("meta",{name:"keywords",content:Array.isArray(r)?r.join(","):r}),f&&(0,u.jsx)("meta",{property:"og:image",content:f}),f&&(0,u.jsx)("meta",{name:"twitter:image",content:f}),i]})}const f=r.createContext(void 0);function p(e){let{className:t,children:n}=e;const i=r.useContext(f),l=(0,o.A)(i,t);return(0,u.jsxs)(f.Provider,{value:l,children:[(0,u.jsx)(a.A,{children:(0,u.jsx)("html",{className:l})}),n]})}function m(e){let{children:t}=e;const n=l(),r=`plugin-${n.plugin.name.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi,"")}`;const a=`plugin-id-${n.plugin.id}`;return(0,u.jsx)(p,{className:(0,o.A)(r,a),children:t})}},9532:(e,t,n)=>{"use strict";n.d(t,{Be:()=>c,ZC:()=>l,_q:()=>i,dV:()=>s,fM:()=>u});var r=n(6540),o=n(205),a=n(4848);function i(e){const t=(0,r.useRef)(e);return(0,o.A)((()=>{t.current=e}),[e]),(0,r.useCallback)((function(){return t.current(...arguments)}),[])}function l(e){const t=(0,r.useRef)();return(0,o.A)((()=>{t.current=e})),t.current}class s extends Error{constructor(e,t){super(),this.name="ReactContextError",this.message=`Hook ${this.stack?.split("\n")[1]?.match(/at (?:\w+\.)?(?\w+)/)?.groups.name??""} is called outside the <${e}>. ${t??""}`}}function c(e){const t=Object.entries(e);return t.sort(((e,t)=>e[0].localeCompare(t[0]))),(0,r.useMemo)((()=>e),t.flat())}function u(e){return t=>{let{children:n}=t;return(0,a.jsx)(a.Fragment,{children:e.reduceRight(((e,t)=>(0,a.jsx)(t,{children:e})),n)})}}},1252:(e,t,n)=>{"use strict";function r(e,t){return void 0!==e&&void 0!==t&&new RegExp(e,"gi").test(t)}n.d(t,{G:()=>r})},9169:(e,t,n)=>{"use strict";n.d(t,{Dt:()=>l,ys:()=>i});var r=n(6540),o=n(8328),a=n(4586);function i(e,t){const n=e=>(!e||e.endsWith("/")?e:`${e}/`)?.toLowerCase();return n(e)===n(t)}function l(){const{baseUrl:e}=(0,a.A)().siteConfig;return(0,r.useMemo)((()=>function(e){let{baseUrl:t,routes:n}=e;function r(e){return e.path===t&&!0===e.exact}function o(e){return e.path===t&&!e.exact}return function e(t){if(0===t.length)return;return t.find(r)||e(t.filter(o).flatMap((e=>e.routes??[])))}(n)}({routes:o.A,baseUrl:e})),[e])}},3104:(e,t,n)=>{"use strict";n.d(t,{Mq:()=>p,Tv:()=>u,a_:()=>m,gk:()=>h});var r=n(6540),o=n(8193),a=n(2303),i=n(205),l=n(9532),s=n(4848);const c=r.createContext(void 0);function u(e){let{children:t}=e;const n=function(){const e=(0,r.useRef)(!0);return(0,r.useMemo)((()=>({scrollEventsEnabledRef:e,enableScrollEvents:()=>{e.current=!0},disableScrollEvents:()=>{e.current=!1}})),[])}();return(0,s.jsx)(c.Provider,{value:n,children:t})}function d(){const e=(0,r.useContext)(c);if(null==e)throw new l.dV("ScrollControllerProvider");return e}const f=()=>o.A.canUseDOM?{scrollX:window.pageXOffset,scrollY:window.pageYOffset}:null;function p(e,t){void 0===t&&(t=[]);const{scrollEventsEnabledRef:n}=d(),o=(0,r.useRef)(f()),a=(0,l._q)(e);(0,r.useEffect)((()=>{const e=()=>{if(!n.current)return;const e=f();a(e,o.current),o.current=e},t={passive:!0};return e(),window.addEventListener("scroll",e,t),()=>window.removeEventListener("scroll",e,t)}),[a,n,...t])}function m(){const e=d(),t=function(){const e=(0,r.useRef)({elem:null,top:0}),t=(0,r.useCallback)((t=>{e.current={elem:t,top:t.getBoundingClientRect().top}}),[]),n=(0,r.useCallback)((()=>{const{current:{elem:t,top:n}}=e;if(!t)return{restored:!1};const r=t.getBoundingClientRect().top-n;return r&&window.scrollBy({left:0,top:r}),e.current={elem:null,top:0},{restored:0!==r}}),[]);return(0,r.useMemo)((()=>({save:t,restore:n})),[n,t])}(),n=(0,r.useRef)(void 0),o=(0,r.useCallback)((r=>{t.save(r),e.disableScrollEvents(),n.current=()=>{const{restored:r}=t.restore();if(n.current=void 0,r){const t=()=>{e.enableScrollEvents(),window.removeEventListener("scroll",t)};window.addEventListener("scroll",t)}else e.enableScrollEvents()}}),[e,t]);return(0,i.A)((()=>{queueMicrotask((()=>n.current?.()))})),{blockElementScrollPositionUntilNextRender:o}}function h(){const e=(0,r.useRef)(null),t=(0,a.A)()&&"smooth"===getComputedStyle(document.documentElement).scrollBehavior;return{startScroll:n=>{e.current=t?function(e){return window.scrollTo({top:e,behavior:"smooth"}),()=>{}}(n):function(e){let t=null;const n=document.documentElement.scrollTop>e;return function r(){const o=document.documentElement.scrollTop;(n&&o>e||!n&&ot&&cancelAnimationFrame(t)}(n)},cancelScroll:()=>e.current?.()}}},2967:(e,t,n)=>{"use strict";n.d(t,{C:()=>r});const r="default"},679:(e,t,n)=>{"use strict";n.d(t,{Wf:()=>u,Eo:()=>f,Dv:()=>d});var r=n(6540);const o=JSON.parse('{"N":"localStorage","M":""}'),a=o.N;function i(e){let{key:t,oldValue:n,newValue:r,storage:o}=e;if(n===r)return;const a=document.createEvent("StorageEvent");a.initStorageEvent("storage",!1,!1,t,n,r,window.location.href,o),window.dispatchEvent(a)}function l(e){if(void 0===e&&(e=a),"undefined"==typeof window)throw new Error("Browser storage is not available on Node.js/Docusaurus SSR process.");if("none"===e)return null;try{return window[e]}catch(n){return t=n,s||(console.warn("Docusaurus browser storage is not available.\nPossible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.",t),s=!0),null}var t}let s=!1;const c={get:()=>null,set:()=>{},del:()=>{},listen:()=>()=>{}};function u(e,t){const n=`${e}${o.M}`;if("undefined"==typeof window)return function(e){function t(){throw new Error(`Illegal storage API usage for storage key "${e}".\nDocusaurus storage APIs are not supposed to be called on the server-rendering process.\nPlease only call storage APIs in effects and event handlers.`)}return{get:t,set:t,del:t,listen:t}}(n);const r=l(t?.persistence);return null===r?c:{get:()=>{try{return r.getItem(n)}catch(e){return console.error(`Docusaurus storage error, can't get key=${n}`,e),null}},set:e=>{try{const t=r.getItem(n);r.setItem(n,e),i({key:n,oldValue:t,newValue:e,storage:r})}catch(t){console.error(`Docusaurus storage error, can't set ${n}=${e}`,t)}},del:()=>{try{const e=r.getItem(n);r.removeItem(n),i({key:n,oldValue:e,newValue:null,storage:r})}catch(e){console.error(`Docusaurus storage error, can't delete key=${n}`,e)}},listen:e=>{try{const t=t=>{t.storageArea===r&&t.key===n&&e(t)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}catch(t){return console.error(`Docusaurus storage error, can't listen for changes of key=${n}`,t),()=>{}}}}}function d(e,t){const n=(0,r.useRef)((()=>null===e?c:u(e,t))).current(),o=(0,r.useCallback)((e=>"undefined"==typeof window?()=>{}:n.listen(e)),[n]);return[(0,r.useSyncExternalStore)(o,(()=>"undefined"==typeof window?null:n.get()),(()=>null)),n]}function f(e){void 0===e&&(e=a);const t=l(e);if(!t)return[];const n=[];for(let r=0;r{"use strict";n.d(t,{o:()=>i});var r=n(4586),o=n(6347),a=n(440);function i(){const{siteConfig:{baseUrl:e,url:t,trailingSlash:n},i18n:{defaultLocale:i,currentLocale:l}}=(0,r.A)(),{pathname:s}=(0,o.zy)(),c=(0,a.Ks)(s,{trailingSlash:n,baseUrl:e}),u=l===i?e:e.replace(`/${l}/`,"/"),d=c.replace(e,"");return{createUrl:function(e){let{locale:n,fullyQualified:r}=e;return`${r?t:""}${function(e){return e===i?`${u}`:`${u}${e}/`}(n)}${d}`}}}},5062:(e,t,n)=>{"use strict";n.d(t,{$:()=>i});var r=n(6540),o=n(6347),a=n(9532);function i(e){const t=(0,o.zy)(),n=(0,a.ZC)(t),i=(0,a._q)(e);(0,r.useEffect)((()=>{n&&t!==n&&i({location:t,previousLocation:n})}),[i,t,n])}},6342:(e,t,n)=>{"use strict";n.d(t,{p:()=>o});var r=n(4586);function o(){return(0,r.A)().siteConfig.themeConfig}},8126:(e,t,n)=>{"use strict";n.d(t,{c:()=>o});var r=n(4586);function o(){const{siteConfig:{themeConfig:e}}=(0,r.A)();return e}},1062:(e,t,n)=>{"use strict";n.d(t,{C:()=>l});var r=n(6540),o=n(1252),a=n(6025),i=n(8126);function l(){const{withBaseUrl:e}=(0,a.hH)(),{algolia:{externalUrlRegex:t,replaceSearchResultPathname:n}}=(0,i.c)();return(0,r.useCallback)((r=>{const a=new URL(r);if((0,o.G)(t,a.href))return r;const i=`${a.pathname+a.hash}`;return e(function(e,t){return t?e.replaceAll(new RegExp(t.from,"g"),t.to):e}(i,n))}),[e,t,n])}},2983:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addTrailingSlash=o,t.default=function(e,t){const{trailingSlash:n,baseUrl:r}=t;if(e.startsWith("#"))return e;if(void 0===n)return e;const[i]=e.split(/[#?]/),l="/"===i||i===r?i:(s=i,c=n,c?o(s):a(s));var s,c;return e.replace(i,l)},t.addLeadingSlash=function(e){return(0,r.addPrefix)(e,"/")},t.removeTrailingSlash=a;const r=n(2566);function o(e){return e.endsWith("/")?e:`${e}/`}function a(e){return(0,r.removeSuffix)(e,"/")}},253:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=function e(t){if(t.cause)return[t,...e(t.cause)];return[t]}},440:(e,t,n)=>{"use strict";t.rA=t.Ks=void 0;const r=n(1635);var o=n(2983);Object.defineProperty(t,"Ks",{enumerable:!0,get:function(){return r.__importDefault(o).default}});var a=n(2566);var i=n(253);Object.defineProperty(t,"rA",{enumerable:!0,get:function(){return i.getErrorCausalChain}})},2566:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addPrefix=function(e,t){return e.startsWith(t)?e:`${t}${e}`},t.removeSuffix=function(e,t){if(""===t)return e;return e.endsWith(t)?e.slice(0,-t.length):e},t.addSuffix=function(e,t){return e.endsWith(t)?e:`${e}${t}`},t.removePrefix=function(e,t){return e.startsWith(t)?e.slice(t.length):e}},6094:()=>{Prism.languages.qmake={comment:/#.*/,variable:/(?:(?:^|\s)[a-z_A-Z]\w+(?=\s*(?:=|\+=|-=|\*=|~=))\b|\${2}[a-z_A-Z]\w+\b(?!\()|\${2}{[a-z_A-Z]\w+}|\b(?:QT|TEMPLATE|CONFIG|DEFINES|SOURCES|HEADERS|INCLUDEPATH|LIBS|QMAKE_CXXFLAGS)\b)/,boolean:/\b(?:true|false)\b/,operator:/(=|\+=|-=|\*=|~=)/,number:/\b\d+(?:\.\d+)*\b/,function:/(?:\b[a-z_]\w*(?=\s*\()\b|\${2}[a-z_]\w+(?=\s*\()\b)/i}},1838:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});const r=(0,n(6540).createContext)(void 0);r.displayName="RootFolderContext";const o=r},1513:(e,t,n)=>{"use strict";n.d(t,{zR:()=>S,TM:()=>T,yJ:()=>p,sC:()=>A,AO:()=>f});var r=n(8168);function o(e){return"/"===e.charAt(0)}function a(e,t){for(var n=t,r=n+1,o=e.length;r=0;f--){var p=i[f];"."===p?a(i,f):".."===p?(a(i,f),d++):d&&(a(i,f),d--)}if(!c)for(;d--;d)i.unshift("..");!c||""===i[0]||i[0]&&o(i[0])||i.unshift("");var m=i.join("/");return n&&"/"!==m.substr(-1)&&(m+="/"),m};var l=n(1561);function s(e){return"/"===e.charAt(0)?e:"/"+e}function c(e){return"/"===e.charAt(0)?e.substr(1):e}function u(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function d(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function f(e){var t=e.pathname,n=e.search,r=e.hash,o=t||"/";return n&&"?"!==n&&(o+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}function p(e,t,n,o){var a;"string"==typeof e?(a=function(e){var t=e||"/",n="",r="",o=t.indexOf("#");-1!==o&&(r=t.substr(o),t=t.substr(0,o));var a=t.indexOf("?");return-1!==a&&(n=t.substr(a),t=t.substr(0,a)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),a.state=t):(void 0===(a=(0,r.A)({},e)).pathname&&(a.pathname=""),a.search?"?"!==a.search.charAt(0)&&(a.search="?"+a.search):a.search="",a.hash?"#"!==a.hash.charAt(0)&&(a.hash="#"+a.hash):a.hash="",void 0!==t&&void 0===a.state&&(a.state=t));try{a.pathname=decodeURI(a.pathname)}catch(l){throw l instanceof URIError?new URIError('Pathname "'+a.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):l}return n&&(a.key=n),o?a.pathname?"/"!==a.pathname.charAt(0)&&(a.pathname=i(a.pathname,o.pathname)):a.pathname=o.pathname:a.pathname||(a.pathname="/"),a}function m(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,o){if(null!=e){var a="function"==typeof e?e(t,n):e;"string"==typeof a?"function"==typeof r?r(a,o):o(!0):o(!1!==a)}else o(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;rt?n.splice(t,n.length-t,o):n.push(o),d({action:r,location:o,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",o=p(e,t,h(),S.location);u.confirmTransitionTo(o,r,n,(function(e){e&&(S.entries[S.index]=o,d({action:r,location:o}))}))},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(e){var t=S.index+e;return t>=0&&t{"use strict";var r=n(4363),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},a={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},l={};function s(e){return r.isMemo(e)?i:l[e.$$typeof]||o}l[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l[r.Memo]=i;var c=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(m){var o=p(n);o&&o!==m&&e(t,o,r)}var i=u(n);d&&(i=i.concat(d(n)));for(var l=s(t),h=s(n),g=0;g{"use strict";e.exports=function(e,t,n,r,o,a,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,i,l],u=0;(s=new Error(t.replace(/%s/g,(function(){return c[u++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}},4634:e=>{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},119:(e,t,n)=>{"use strict";n.r(t)},1043:(e,t,n)=>{"use strict";n.r(t)},5947:function(e,t,n){var r,o;r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'
'};function o(e,t,n){return en?n:e}function a(e){return 100*(-1+e)}function i(e,t,n){var o;return(o="translate3d"===r.positionUsing?{transform:"translate3d("+a(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+a(e)+"%,0)"}:{"margin-left":a(e)+"%"}).transition="all "+t+"ms "+n,o}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=o(e,r.minimum,1),n.status=1===e?null:e;var a=n.render(!t),c=a.querySelector(r.barSelector),u=r.speed,d=r.easing;return a.offsetWidth,l((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(c,i(e,u,d)),1===e?(s(a,{transition:"none",opacity:1}),a.offsetWidth,setTimeout((function(){s(a,{transition:"all "+u+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),u)}),u)):setTimeout(t,u)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*o(Math.random()*t,.1,.95)),t=o(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");u(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var o,i=t.querySelector(r.barSelector),l=e?"-100":a(n.status||0),c=document.querySelector(r.parent);return s(i,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(o=t.querySelector(r.spinnerSelector))&&p(o),c!=document.body&&u(c,"nprogress-custom-parent"),c.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&p(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var l=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),s=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,o=e.length,a=t.charAt(0).toUpperCase()+t.slice(1);o--;)if((r=e[o]+a)in n)return r;return t}function o(e){return e=n(e),t[e]||(t[e]=r(e))}function a(e,t,n){t=o(t),e.style[t]=n}return function(e,t){var n,r,o=arguments;if(2==o.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&a(e,n,r);else a(e,o[1],o[2])}}();function c(e,t){return("string"==typeof e?e:f(e)).indexOf(" "+t+" ")>=0}function u(e,t){var n=f(e),r=n+t;c(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=f(e);c(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function f(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function p(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n},void 0===(o="function"==typeof r?r.call(t,n,t,e):r)||(e.exports=o)},5302:(e,t,n)=>{var r=n(4634);e.exports=p,e.exports.parse=a,e.exports.compile=function(e,t){return l(a(e,t),t)},e.exports.tokensToFunction=l,e.exports.tokensToRegExp=f;var o=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function a(e,t){for(var n,r=[],a=0,i=0,l="",u=t&&t.delimiter||"/";null!=(n=o.exec(e));){var d=n[0],f=n[1],p=n.index;if(l+=e.slice(i,p),i=p+d.length,f)l+=f[1];else{var m=e[i],h=n[2],g=n[3],y=n[4],b=n[5],v=n[6],S=n[7];l&&(r.push(l),l="");var E=null!=h&&null!=m&&m!==h,w="+"===v||"*"===v,_="?"===v||"*"===v,k=n[2]||u,O=y||b;r.push({name:g||a++,prefix:h||"",delimiter:k,optional:_,repeat:w,partial:E,asterisk:!!S,pattern:O?c(O):S?".*":"[^"+s(k)+"]+?"})}}return i{!function(e){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var o=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,i=0;i{Prism.languages.cmake={comment:/#.*/,string:{pattern:/"(?:[^\\"]|\\.)*"/,greedy:!0,inside:{interpolation:{pattern:/\$\{(?:[^{}$]|\$\{[^{}$]*\})*\}/,inside:{punctuation:/\$\{|\}/,variable:/\w+/}}}},variable:/\b(?:CMAKE_\w+|\w+_(?:(?:BINARY|SOURCE)_DIR|DESCRIPTION|HOMEPAGE_URL|ROOT|VERSION(?:_MAJOR|_MINOR|_PATCH|_TWEAK)?)|(?:ANDROID|APPLE|BORLAND|BUILD_SHARED_LIBS|CACHE|CPACK_(?:ABSOLUTE_DESTINATION_FILES|COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY|ERROR_ON_ABSOLUTE_INSTALL_DESTINATION|INCLUDE_TOPLEVEL_DIRECTORY|INSTALL_DEFAULT_DIRECTORY_PERMISSIONS|INSTALL_SCRIPT|PACKAGING_INSTALL_PREFIX|SET_DESTDIR|WARN_ON_ABSOLUTE_INSTALL_DESTINATION)|CTEST_(?:BINARY_DIRECTORY|BUILD_COMMAND|BUILD_NAME|BZR_COMMAND|BZR_UPDATE_OPTIONS|CHANGE_ID|CHECKOUT_COMMAND|CONFIGURATION_TYPE|CONFIGURE_COMMAND|COVERAGE_COMMAND|COVERAGE_EXTRA_FLAGS|CURL_OPTIONS|CUSTOM_(?:COVERAGE_EXCLUDE|ERROR_EXCEPTION|ERROR_MATCH|ERROR_POST_CONTEXT|ERROR_PRE_CONTEXT|MAXIMUM_FAILED_TEST_OUTPUT_SIZE|MAXIMUM_NUMBER_OF_(?:ERRORS|WARNINGS)|MAXIMUM_PASSED_TEST_OUTPUT_SIZE|MEMCHECK_IGNORE|POST_MEMCHECK|POST_TEST|PRE_MEMCHECK|PRE_TEST|TESTS_IGNORE|WARNING_EXCEPTION|WARNING_MATCH)|CVS_CHECKOUT|CVS_COMMAND|CVS_UPDATE_OPTIONS|DROP_LOCATION|DROP_METHOD|DROP_SITE|DROP_SITE_CDASH|DROP_SITE_PASSWORD|DROP_SITE_USER|EXTRA_COVERAGE_GLOB|GIT_COMMAND|GIT_INIT_SUBMODULES|GIT_UPDATE_CUSTOM|GIT_UPDATE_OPTIONS|HG_COMMAND|HG_UPDATE_OPTIONS|LABELS_FOR_SUBPROJECTS|MEMORYCHECK_(?:COMMAND|COMMAND_OPTIONS|SANITIZER_OPTIONS|SUPPRESSIONS_FILE|TYPE)|NIGHTLY_START_TIME|P4_CLIENT|P4_COMMAND|P4_OPTIONS|P4_UPDATE_OPTIONS|RUN_CURRENT_SCRIPT|SCP_COMMAND|SITE|SOURCE_DIRECTORY|SUBMIT_URL|SVN_COMMAND|SVN_OPTIONS|SVN_UPDATE_OPTIONS|TEST_LOAD|TEST_TIMEOUT|TRIGGER_SITE|UPDATE_COMMAND|UPDATE_OPTIONS|UPDATE_VERSION_ONLY|USE_LAUNCHERS)|CYGWIN|ENV|EXECUTABLE_OUTPUT_PATH|GHS-MULTI|IOS|LIBRARY_OUTPUT_PATH|MINGW|MSVC(?:10|11|12|14|60|70|71|80|90|_IDE|_TOOLSET_VERSION|_VERSION)?|MSYS|PROJECT_NAME|UNIX|WIN32|WINCE|WINDOWS_PHONE|WINDOWS_STORE|XCODE))\b/,property:/\b(?:cxx_\w+|(?:ARCHIVE_OUTPUT_(?:DIRECTORY|NAME)|COMPILE_DEFINITIONS|COMPILE_PDB_NAME|COMPILE_PDB_OUTPUT_DIRECTORY|EXCLUDE_FROM_DEFAULT_BUILD|IMPORTED_(?:IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_LANGUAGES|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|NO_SONAME|OBJECTS|SONAME)|INTERPROCEDURAL_OPTIMIZATION|LIBRARY_OUTPUT_DIRECTORY|LIBRARY_OUTPUT_NAME|LINK_FLAGS|LINK_INTERFACE_LIBRARIES|LINK_INTERFACE_MULTIPLICITY|LOCATION|MAP_IMPORTED_CONFIG|OSX_ARCHITECTURES|OUTPUT_NAME|PDB_NAME|PDB_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_DIRECTORY|RUNTIME_OUTPUT_NAME|STATIC_LIBRARY_FLAGS|VS_CSHARP|VS_DOTNET_REFERENCEPROP|VS_DOTNET_REFERENCE|VS_GLOBAL_SECTION_POST|VS_GLOBAL_SECTION_PRE|VS_GLOBAL|XCODE_ATTRIBUTE)_\w+|\w+_(?:CLANG_TIDY|COMPILER_LAUNCHER|CPPCHECK|CPPLINT|INCLUDE_WHAT_YOU_USE|OUTPUT_NAME|POSTFIX|VISIBILITY_PRESET)|ABSTRACT|ADDITIONAL_MAKE_CLEAN_FILES|ADVANCED|ALIASED_TARGET|ALLOW_DUPLICATE_CUSTOM_TARGETS|ANDROID_(?:ANT_ADDITIONAL_OPTIONS|API|API_MIN|ARCH|ASSETS_DIRECTORIES|GUI|JAR_DEPENDENCIES|NATIVE_LIB_DEPENDENCIES|NATIVE_LIB_DIRECTORIES|PROCESS_MAX|PROGUARD|PROGUARD_CONFIG_PATH|SECURE_PROPS_PATH|SKIP_ANT_STEP|STL_TYPE)|ARCHIVE_OUTPUT_DIRECTORY|ATTACHED_FILES|ATTACHED_FILES_ON_FAIL|AUTOGEN_(?:BUILD_DIR|ORIGIN_DEPENDS|PARALLEL|SOURCE_GROUP|TARGETS_FOLDER|TARGET_DEPENDS)|AUTOMOC|AUTOMOC_(?:COMPILER_PREDEFINES|DEPEND_FILTERS|EXECUTABLE|MACRO_NAMES|MOC_OPTIONS|SOURCE_GROUP|TARGETS_FOLDER)|AUTORCC|AUTORCC_EXECUTABLE|AUTORCC_OPTIONS|AUTORCC_SOURCE_GROUP|AUTOUIC|AUTOUIC_EXECUTABLE|AUTOUIC_OPTIONS|AUTOUIC_SEARCH_PATHS|BINARY_DIR|BUILDSYSTEM_TARGETS|BUILD_RPATH|BUILD_RPATH_USE_ORIGIN|BUILD_WITH_INSTALL_NAME_DIR|BUILD_WITH_INSTALL_RPATH|BUNDLE|BUNDLE_EXTENSION|CACHE_VARIABLES|CLEAN_NO_CUSTOM|COMMON_LANGUAGE_RUNTIME|COMPATIBLE_INTERFACE_(?:BOOL|NUMBER_MAX|NUMBER_MIN|STRING)|COMPILE_(?:DEFINITIONS|FEATURES|FLAGS|OPTIONS|PDB_NAME|PDB_OUTPUT_DIRECTORY)|COST|CPACK_DESKTOP_SHORTCUTS|CPACK_NEVER_OVERWRITE|CPACK_PERMANENT|CPACK_STARTUP_SHORTCUTS|CPACK_START_MENU_SHORTCUTS|CPACK_WIX_ACL|CROSSCOMPILING_EMULATOR|CUDA_EXTENSIONS|CUDA_PTX_COMPILATION|CUDA_RESOLVE_DEVICE_SYMBOLS|CUDA_SEPARABLE_COMPILATION|CUDA_STANDARD|CUDA_STANDARD_REQUIRED|CXX_EXTENSIONS|CXX_STANDARD|CXX_STANDARD_REQUIRED|C_EXTENSIONS|C_STANDARD|C_STANDARD_REQUIRED|DEBUG_CONFIGURATIONS|DEFINE_SYMBOL|DEFINITIONS|DEPENDS|DEPLOYMENT_ADDITIONAL_FILES|DEPLOYMENT_REMOTE_DIRECTORY|DISABLED|DISABLED_FEATURES|ECLIPSE_EXTRA_CPROJECT_CONTENTS|ECLIPSE_EXTRA_NATURES|ENABLED_FEATURES|ENABLED_LANGUAGES|ENABLE_EXPORTS|ENVIRONMENT|EXCLUDE_FROM_ALL|EXCLUDE_FROM_DEFAULT_BUILD|EXPORT_NAME|EXPORT_PROPERTIES|EXTERNAL_OBJECT|EchoString|FAIL_REGULAR_EXPRESSION|FIND_LIBRARY_USE_LIB32_PATHS|FIND_LIBRARY_USE_LIB64_PATHS|FIND_LIBRARY_USE_LIBX32_PATHS|FIND_LIBRARY_USE_OPENBSD_VERSIONING|FIXTURES_CLEANUP|FIXTURES_REQUIRED|FIXTURES_SETUP|FOLDER|FRAMEWORK|Fortran_FORMAT|Fortran_MODULE_DIRECTORY|GENERATED|GENERATOR_FILE_NAME|GENERATOR_IS_MULTI_CONFIG|GHS_INTEGRITY_APP|GHS_NO_SOURCE_GROUP_FILE|GLOBAL_DEPENDS_DEBUG_MODE|GLOBAL_DEPENDS_NO_CYCLES|GNUtoMS|HAS_CXX|HEADER_FILE_ONLY|HELPSTRING|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|IMPORTED|IMPORTED_(?:COMMON_LANGUAGE_RUNTIME|CONFIGURATIONS|GLOBAL|IMPLIB|LIBNAME|LINK_DEPENDENT_LIBRARIES|LINK_INTERFACE_(?:LANGUAGES|LIBRARIES|MULTIPLICITY)|LOCATION|NO_SONAME|OBJECTS|SONAME)|IMPORT_PREFIX|IMPORT_SUFFIX|INCLUDE_DIRECTORIES|INCLUDE_REGULAR_EXPRESSION|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|INTERFACE_(?:AUTOUIC_OPTIONS|COMPILE_DEFINITIONS|COMPILE_FEATURES|COMPILE_OPTIONS|INCLUDE_DIRECTORIES|LINK_DEPENDS|LINK_DIRECTORIES|LINK_LIBRARIES|LINK_OPTIONS|POSITION_INDEPENDENT_CODE|SOURCES|SYSTEM_INCLUDE_DIRECTORIES)|INTERPROCEDURAL_OPTIMIZATION|IN_TRY_COMPILE|IOS_INSTALL_COMBINED|JOB_POOLS|JOB_POOL_COMPILE|JOB_POOL_LINK|KEEP_EXTENSION|LABELS|LANGUAGE|LIBRARY_OUTPUT_DIRECTORY|LINKER_LANGUAGE|LINK_(?:DEPENDS|DEPENDS_NO_SHARED|DIRECTORIES|FLAGS|INTERFACE_LIBRARIES|INTERFACE_MULTIPLICITY|LIBRARIES|OPTIONS|SEARCH_END_STATIC|SEARCH_START_STATIC|WHAT_YOU_USE)|LISTFILE_STACK|LOCATION|MACOSX_BUNDLE|MACOSX_BUNDLE_INFO_PLIST|MACOSX_FRAMEWORK_INFO_PLIST|MACOSX_PACKAGE_LOCATION|MACOSX_RPATH|MACROS|MANUALLY_ADDED_DEPENDENCIES|MEASUREMENT|MODIFIED|NAME|NO_SONAME|NO_SYSTEM_FROM_IMPORTED|OBJECT_DEPENDS|OBJECT_OUTPUTS|OSX_ARCHITECTURES|OUTPUT_NAME|PACKAGES_FOUND|PACKAGES_NOT_FOUND|PARENT_DIRECTORY|PASS_REGULAR_EXPRESSION|PDB_NAME|PDB_OUTPUT_DIRECTORY|POSITION_INDEPENDENT_CODE|POST_INSTALL_SCRIPT|PREDEFINED_TARGETS_FOLDER|PREFIX|PRE_INSTALL_SCRIPT|PRIVATE_HEADER|PROCESSORS|PROCESSOR_AFFINITY|PROJECT_LABEL|PUBLIC_HEADER|REPORT_UNDEFINED_PROPERTIES|REQUIRED_FILES|RESOURCE|RESOURCE_LOCK|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|RULE_MESSAGES|RUNTIME_OUTPUT_DIRECTORY|RUN_SERIAL|SKIP_AUTOGEN|SKIP_AUTOMOC|SKIP_AUTORCC|SKIP_AUTOUIC|SKIP_BUILD_RPATH|SKIP_RETURN_CODE|SOURCES|SOURCE_DIR|SOVERSION|STATIC_LIBRARY_FLAGS|STATIC_LIBRARY_OPTIONS|STRINGS|SUBDIRECTORIES|SUFFIX|SYMBOLIC|TARGET_ARCHIVES_MAY_BE_SHARED_LIBS|TARGET_MESSAGES|TARGET_SUPPORTS_SHARED_LIBS|TESTS|TEST_INCLUDE_FILE|TEST_INCLUDE_FILES|TIMEOUT|TIMEOUT_AFTER_MATCH|TYPE|USE_FOLDERS|VALUE|VARIABLES|VERSION|VISIBILITY_INLINES_HIDDEN|VS_(?:CONFIGURATION_TYPE|COPY_TO_OUT_DIR|DEBUGGER_(?:COMMAND|COMMAND_ARGUMENTS|ENVIRONMENT|WORKING_DIRECTORY)|DEPLOYMENT_CONTENT|DEPLOYMENT_LOCATION|DOTNET_REFERENCES|DOTNET_REFERENCES_COPY_LOCAL|INCLUDE_IN_VSIX|IOT_STARTUP_TASK|KEYWORD|RESOURCE_GENERATOR|SCC_AUXPATH|SCC_LOCALPATH|SCC_PROJECTNAME|SCC_PROVIDER|SDK_REFERENCES|SHADER_(?:DISABLE_OPTIMIZATIONS|ENABLE_DEBUG|ENTRYPOINT|FLAGS|MODEL|OBJECT_FILE_NAME|OUTPUT_HEADER_FILE|TYPE|VARIABLE_NAME)|STARTUP_PROJECT|TOOL_OVERRIDE|USER_PROPS|WINRT_COMPONENT|WINRT_EXTENSIONS|WINRT_REFERENCES|XAML_TYPE)|WILL_FAIL|WIN32_EXECUTABLE|WINDOWS_EXPORT_ALL_SYMBOLS|WORKING_DIRECTORY|WRAP_EXCLUDE|XCODE_(?:EMIT_EFFECTIVE_PLATFORM_NAME|EXPLICIT_FILE_TYPE|FILE_ATTRIBUTES|LAST_KNOWN_FILE_TYPE|PRODUCT_TYPE|SCHEME_(?:ADDRESS_SANITIZER|ADDRESS_SANITIZER_USE_AFTER_RETURN|ARGUMENTS|DISABLE_MAIN_THREAD_CHECKER|DYNAMIC_LIBRARY_LOADS|DYNAMIC_LINKER_API_USAGE|ENVIRONMENT|EXECUTABLE|GUARD_MALLOC|MAIN_THREAD_CHECKER_STOP|MALLOC_GUARD_EDGES|MALLOC_SCRIBBLE|MALLOC_STACK|THREAD_SANITIZER(?:_STOP)?|UNDEFINED_BEHAVIOUR_SANITIZER(?:_STOP)?|ZOMBIE_OBJECTS))|XCTEST)\b/,keyword:/\b(?:add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|break|build_command|build_name|cmake_host_system_information|cmake_minimum_required|cmake_parse_arguments|cmake_policy|configure_file|continue|create_test_sourcelist|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload|define_property|else|elseif|enable_language|enable_testing|endforeach|endfunction|endif|endmacro|endwhile|exec_program|execute_process|export|export_library_dependencies|file|find_file|find_library|find_package|find_path|find_program|fltk_wrap_ui|foreach|function|get_cmake_property|get_directory_property|get_filename_component|get_property|get_source_file_property|get_target_property|get_test_property|if|include|include_directories|include_external_msproject|include_guard|include_regular_expression|install|install_files|install_programs|install_targets|link_directories|link_libraries|list|load_cache|load_command|macro|make_directory|mark_as_advanced|math|message|option|output_required_files|project|qt_wrap_cpp|qt_wrap_ui|remove|remove_definitions|return|separate_arguments|set|set_directory_properties|set_property|set_source_files_properties|set_target_properties|set_tests_properties|site_name|source_group|string|subdir_depends|subdirs|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_sources|try_compile|try_run|unset|use_mangled_mesa|utility_source|variable_requires|variable_watch|while|write_file)(?=\s*\()\b/,boolean:/\b(?:FALSE|OFF|ON|TRUE)\b/,namespace:/\b(?:INTERFACE|PRIVATE|PROPERTIES|PUBLIC|SHARED|STATIC|TARGET_OBJECTS)\b/,operator:/\b(?:AND|DEFINED|EQUAL|GREATER|LESS|MATCHES|NOT|OR|STREQUAL|STRGREATER|STRLESS|VERSION_EQUAL|VERSION_GREATER|VERSION_LESS)\b/,inserted:{pattern:/\b\w+::\w+\b/,alias:"class-name"},number:/\b\d+(?:\.\d+)*\b/,function:/\b[a-z_]\w*(?=\s*\()\b/i,punctuation:/[()>}]|\$[<{]/}},9700:()=>{!function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,o,a){if(n.language===r){var i=n.tokenStack=[];n.code=n.code.replace(o,(function(e){if("function"==typeof a&&!a(e))return e;for(var o,l=i.length;-1!==n.code.indexOf(o=t(r,l));)++l;return i[l]=e,o})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var o=0,a=Object.keys(n.tokenStack);!function i(l){for(var s=0;s=a.length);s++){var c=l[s];if("string"==typeof c||c.content&&"string"==typeof c.content){var u=a[o],d=n.tokenStack[u],f="string"==typeof c?c:c.content,p=t(r,u),m=f.indexOf(p);if(m>-1){++o;var h=f.substring(0,m),g=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),y=f.substring(m+p.length),b=[];h&&b.push.apply(b,i([h])),b.push(g),y&&b.push.apply(b,i([y])),"string"==typeof c?l.splice.apply(l,[s,1].concat(b)):c.content=b}}else c.content&&i(c.content)}return l}(n.tokens)}}}})}(Prism)},905:()=>{!function(e){var t=e.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/};t.string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:t},boolean:t.boolean,variable:t.variable}}(Prism)},652:(e,t,n)=>{var r={"./prism-bash":7022,"./prism-cmake":2509,"./prism-powershell":905};function o(e){var t=a(e);return n(t)}function a(e){if(!n.o(r,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return r[e]}o.keys=function(){return Object.keys(r)},o.resolve=a,e.exports=o,o.id=652},2694:(e,t,n)=>{"use strict";var r=n(6925);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},2551:(e,t,n)=>{"use strict";var r=n(6540),o=n(9982);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n