相关文章推荐
爱吹牛的水煮肉
·
【麒麟990手机】报价_麒麟990手机大全_ ...
·
5 月前
·
胡子拉碴的便当
·
这些新型骗术你一定要知道-信息与网络管理中心
·
1 年前
·
威武的煎饼
·
拖拉机自卸车工地干活图片-中国路面机械网
·
1 年前
·
豪情万千的单车
·
陶喆专辑封-抖音
·
1 年前
·
迷茫的手术刀
·
特朗普宣布参加2024年总统竞选:“美国现在 ...
·
1 年前
·
小百科
›
Prisma Client API
email
prisma
高大的大象
9 月前
</noscript><div id="___gatsby"><div style="outline:none" tabindex="-1" id="gatsby-focus-wrapper"><div class="layout__LayoutWrapper-sc-bupt9j-9 dark"><div class="header__HeaderWrapper-sc-1w16195-4 hAoImM"><div class="header__BucketHeader-sc-1w16195-0 gMrSws"><div class="header__HomeIcons-sc-1w16195-11 euTKSS"><button class="customLink__CustomButton-sc-1xpvtl4-0 hyHLmQ"><svg viewbox="0 0 90 24" fill="#2d3748" xmlns="http://www.w3.org/2000/svg" class="Logo-sc-c81z3l-0 beNtqd light"><path fill-rule="evenodd" clip-rule="evenodd" d="M34.736 11.947h.9c.842 0 1.471-.168 1.89-.502.417-.335.626-.822.626-1.462 0-.645-.175-1.122-.525-1.43-.35-.308-.899-.462-1.646-.462h-1.245v3.856zm6.179-2.061c0 1.398-.434 2.466-1.303 3.206-.867.741-2.101 1.11-3.702 1.11h-1.174v4.62H32V5.835h4.122c1.565 0 2.755.34 3.57 1.017.815.678 1.223 1.69 1.223 3.034zM48.167 8.704c.365 0 .668.027.91.08l-.203 2.54a3.08 3.08 0 00-.795-.088c-.859 0-1.528.222-2.008.666-.48.444-.72 1.066-.72 1.866v5.054H42.66V8.891h2.039l.397 1.67h.132a3.726 3.726 0 011.24-1.346c.521-.34 1.087-.51 1.7-.51zM50.505 18.822h2.692V8.891h-2.692v9.931zM50.39 6.323c0-.882.489-1.323 1.465-1.323.977 0 1.466.441 1.466 1.323 0 .421-.122.748-.366.982-.245.234-.611.35-1.1.35-.976 0-1.465-.443-1.465-1.332zM62.675 15.873c0 1.019-.352 1.795-1.055 2.328-.703.532-1.755.799-3.155.799-.719 0-1.33-.049-1.836-.147a6.904 6.904 0 01-1.421-.43v-2.24c.5.238 1.063.436 1.69.596.627.16 1.178.24 1.655.24.977 0 1.465-.284 1.465-.853a.715.715 0 00-.194-.52c-.13-.133-.353-.284-.67-.453a16.977 16.977 0 00-1.272-.59c-.759-.32-1.317-.616-1.672-.889a2.488 2.488 0 01-.777-.937c-.162-.352-.243-.786-.243-1.301 0-.883.34-1.565 1.02-2.048.68-.482 1.642-.724 2.89-.724 1.189 0 2.345.261 3.469.782l-.812 1.954a14.913 14.913 0 00-1.386-.524 4.326 4.326 0 00-1.315-.204c-.794 0-1.192.216-1.192.648 0 .243.129.454.384.631.257.178.817.441 1.682.79.77.315 1.336.608 1.695.88.358.273.623.586.794.942.17.355.256.779.256 1.27zM73.34 18.822h-2.693v-5.8c0-.717-.119-1.255-.357-1.613-.238-.358-.613-.537-1.125-.537-.689 0-1.189.254-1.5.764-.313.51-.469 1.347-.469 2.514v4.672h-2.692V8.891h2.057l.362 1.27h.15a2.741 2.741 0 011.147-1.07c.5-.258 1.074-.387 1.722-.387 1.477 0 2.477.486 3 1.457h.239c.265-.462.654-.82 1.17-1.075.514-.255 1.095-.382 1.743-.382 1.118 0 1.964.289 2.537.866.574.578.86 1.503.86 2.776v6.476h-2.7v-5.8c0-.717-.12-1.255-.358-1.613-.238-.358-.613-.537-1.125-.537-.66 0-1.152.237-1.479.71-.326.474-.49 1.226-.49 2.257v4.983zM87.326 14.22l-1.042.036c-.783.024-1.365.166-1.747.427-.383.26-.574.657-.574 1.19 0 .764.435 1.146 1.306 1.146.624 0 1.123-.18 1.496-.542.374-.361.56-.84.56-1.44v-.816zm.794 4.602l-.52-1.35h-.072c-.453.575-.919.973-1.399 1.195-.479.222-1.104.333-1.875.333-.948 0-1.693-.273-2.238-.817-.544-.545-.816-1.32-.816-2.328 0-1.054.366-1.831 1.099-2.332.733-.5 1.837-.777 3.314-.83l1.713-.053v-.436c0-1.006-.512-1.51-1.536-1.51-.789 0-1.716.24-2.78.72l-.892-1.83c1.136-.598 2.395-.898 3.778-.898 1.324 0 2.339.29 3.045.871.706.58 1.059 1.463 1.059 2.647v6.618h-1.88zM18.01 19.037L7.163 22.224a.454.454 0 01-.58-.52L10.46 3.267c.073-.345.552-.4.704-.08l7.173 15.138a.514.514 0 01-.327.713zm1.86-.752L11.562.757a1.333 1.333 0 00-1.136-.755 1.32 1.32 0 00-1.213.626l-9.009 14.5c-.279.451-.273 1.008.016 1.455l4.404 6.778a1.419 1.419 0 001.59.581l12.782-3.756c.392-.116.712-.39.88-.756a1.354 1.354 0 00-.008-1.145z" class="jsx-3616046384"/></svg><svg viewbox="0 0 90 24" fill="#ffffff" xmlns="http://www.w3.org/2000/svg" class="Logo-sc-c81z3l-0 clMfPP dark"><path fill-rule="evenodd" clip-rule="evenodd" d="M34.736 11.947h.9c.842 0 1.471-.168 1.89-.502.417-.335.626-.822.626-1.462 0-.645-.175-1.122-.525-1.43-.35-.308-.899-.462-1.646-.462h-1.245v3.856zm6.179-2.061c0 1.398-.434 2.466-1.303 3.206-.867.741-2.101 1.11-3.702 1.11h-1.174v4.62H32V5.835h4.122c1.565 0 2.755.34 3.57 1.017.815.678 1.223 1.69 1.223 3.034zM48.167 8.704c.365 0 .668.027.91.08l-.203 2.54a3.08 3.08 0 00-.795-.088c-.859 0-1.528.222-2.008.666-.48.444-.72 1.066-.72 1.866v5.054H42.66V8.891h2.039l.397 1.67h.132a3.726 3.726 0 011.24-1.346c.521-.34 1.087-.51 1.7-.51zM50.505 18.822h2.692V8.891h-2.692v9.931zM50.39 6.323c0-.882.489-1.323 1.465-1.323.977 0 1.466.441 1.466 1.323 0 .421-.122.748-.366.982-.245.234-.611.35-1.1.35-.976 0-1.465-.443-1.465-1.332zM62.675 15.873c0 1.019-.352 1.795-1.055 2.328-.703.532-1.755.799-3.155.799-.719 0-1.33-.049-1.836-.147a6.904 6.904 0 01-1.421-.43v-2.24c.5.238 1.063.436 1.69.596.627.16 1.178.24 1.655.24.977 0 1.465-.284 1.465-.853a.715.715 0 00-.194-.52c-.13-.133-.353-.284-.67-.453a16.977 16.977 0 00-1.272-.59c-.759-.32-1.317-.616-1.672-.889a2.488 2.488 0 01-.777-.937c-.162-.352-.243-.786-.243-1.301 0-.883.34-1.565 1.02-2.048.68-.482 1.642-.724 2.89-.724 1.189 0 2.345.261 3.469.782l-.812 1.954a14.913 14.913 0 00-1.386-.524 4.326 4.326 0 00-1.315-.204c-.794 0-1.192.216-1.192.648 0 .243.129.454.384.631.257.178.817.441 1.682.79.77.315 1.336.608 1.695.88.358.273.623.586.794.942.17.355.256.779.256 1.27zM73.34 18.822h-2.693v-5.8c0-.717-.119-1.255-.357-1.613-.238-.358-.613-.537-1.125-.537-.689 0-1.189.254-1.5.764-.313.51-.469 1.347-.469 2.514v4.672h-2.692V8.891h2.057l.362 1.27h.15a2.741 2.741 0 011.147-1.07c.5-.258 1.074-.387 1.722-.387 1.477 0 2.477.486 3 1.457h.239c.265-.462.654-.82 1.17-1.075.514-.255 1.095-.382 1.743-.382 1.118 0 1.964.289 2.537.866.574.578.86 1.503.86 2.776v6.476h-2.7v-5.8c0-.717-.12-1.255-.358-1.613-.238-.358-.613-.537-1.125-.537-.66 0-1.152.237-1.479.71-.326.474-.49 1.226-.49 2.257v4.983zM87.326 14.22l-1.042.036c-.783.024-1.365.166-1.747.427-.383.26-.574.657-.574 1.19 0 .764.435 1.146 1.306 1.146.624 0 1.123-.18 1.496-.542.374-.361.56-.84.56-1.44v-.816zm.794 4.602l-.52-1.35h-.072c-.453.575-.919.973-1.399 1.195-.479.222-1.104.333-1.875.333-.948 0-1.693-.273-2.238-.817-.544-.545-.816-1.32-.816-2.328 0-1.054.366-1.831 1.099-2.332.733-.5 1.837-.777 3.314-.83l1.713-.053v-.436c0-1.006-.512-1.51-1.536-1.51-.789 0-1.716.24-2.78.72l-.892-1.83c1.136-.598 2.395-.898 3.778-.898 1.324 0 2.339.29 3.045.871.706.58 1.059 1.463 1.059 2.647v6.618h-1.88zM18.01 19.037L7.163 22.224a.454.454 0 01-.58-.52L10.46 3.267c.073-.345.552-.4.704-.08l7.173 15.138a.514.514 0 01-.327.713zm1.86-.752L11.562.757a1.333 1.333 0 00-1.136-.755 1.32 1.32 0 00-1.213.626l-9.009 14.5c-.279.451-.273 1.008.016 1.455l4.404 6.778a1.419 1.419 0 001.59.581l12.782-3.756c.392-.116.712-.39.88-.756a1.354 1.354 0 00-.008-1.145z" class="jsx-3616046384"/></svg></button><button class="customLink__CustomButton-sc-1xpvtl4-0 hyHLmQ">Docs</button></div><div class="header__NonMobileMenu-sc-1w16195-5 fFnNKf"><div class="header__SecondLevelNav-sc-1w16195-10 kWvzUe"><div><a class="header__NavLink-sc-1w16195-6 header__DarkNavLink-sc-1w16195-7 lcEBVH cMhiDt non-active" href="/docs/getting-started"><span>Get Started</span></a><a class="header__NavLink-sc-1w16195-6 header__DarkNavLink-sc-1w16195-7 lcEBVH cMhiDt active-item" href="/docs/orm"><span>ORM</span></a><a class="header__NavLink-sc-1w16195-6 header__DarkNavLink-sc-1w16195-7 lcEBVH fqsarI non-active" href="/docs/accelerate"><span>Accelerate</span></a><a class="header__NavLink-sc-1w16195-6 header__DarkNavLink-sc-1w16195-7 lcEBVH fqsarI non-active" href="/docs/pulse"><span>Pulse</span></a></div></div></div><a href="https://github.com/prisma" target="_blank" class="header__GithubLink-sc-1w16195-13 jVdqoJ"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 496 512" class="light" fill="#2d3748" width="24" height="24"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 496 512" class="dark" fill="#ffffff" width="24" height="24"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg></a><a href="https://console.prisma.io/login?utm_source=docs&utm_medium=login" type="primary" color="teal" class="button__StyledLink-sc-187srku-0 jcobFZ log-btn">Login</a><div class="header__DocsMobileButton-sc-1w16195-1 itgNGF"><i class="fa-regular fa-bars undefined" style="text-align:center;font-size:28px;color:currentcolor;margin:"/></div></div></div><div class="header__SearchComponentDesktop-sc-1w16195-9 deKFiy"><div class="overlay__StyledOverlay-sc-1uuldzq-0 jRFKZl"/><div class="input__SearchBoxDiv-sc-1nmahfx-0 jkqxtT"><form><svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="input__SearchIcon-sc-1nmahfx-1 gZvrwL"><path d="M7 13C10.3137 13 13 10.3137 13 7C13 3.68629 10.3137 1 7 1C3.68629 1 1 3.68629 1 7C1 10.3137 3.68629 13 7 13Z" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 15L12 12" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><input type="text" placeholder="Search Documentation..." aria-label="Search Documentation..." value=""/></form></div></div><div class="layout__Wrapper-sc-bupt9j-0 jwGPFR"><div class="layout__Container-sc-bupt9j-4 exaTrK"><div class="layout__CustomSticky-sc-bupt9j-8 jKxlUY"><div class="layout__SearchComponentDesktop-sc-bupt9j-7 bhoAMO"><div class="minimalInput__SearchBoxDiv-sc-15ifbjd-0 cEYuIU"><form><svg width="16" height="16" viewbox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="minimalInput__SearchIcon-sc-15ifbjd-1 epYiQK"><path d="M7 13C10.3137 13 13 10.3137 13 7C13 3.68629 10.3137 1 7 1C3.68629 1 1 3.68629 1 7C1 10.3137 3.68629 13 7 13Z" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 15L12 12" stroke="#4A5568" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><input type="text" placeholder="Search Docs..." aria-label="Search Documentation..." value=""/><svg width="18" height="28" viewbox="0 0 18 28" fill="none" xmlns="http://www.w3.org/2000/svg" class="minimalInput__SearchSlashIcon-sc-15ifbjd-2 gmXMnO"><path d="M11.2734 8.57812L7.01562 20H5.71875L9.97656 8.57812H11.2734Z" fill="#CBD5E0"/><rect x="0.5" y="0.5" width="17" height="27" rx="3.5" stroke="#CBD5E0"/></svg></form></div></div><section id="sidebar-holder" class="layout__NotMobile-sc-bupt9j-3 fTKCHT"><aside class="sidebar__SidebarContainer-sc-u94sja-0 cyByzh"><div id="sidebar-container" class="sidebar__Sidebar-sc-u94sja-1 bMsMoj"><ul class="sidebar__List-sc-u94sja-2 fzetWo"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq "><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq top-level "><a class="active-item" id="/docs/orm"><span class="">ORM</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/overview"><span class="">Overview</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/overview/introduction" href="/docs/orm/overview/introduction"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Introduction</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/overview/prisma-in-your-stack" href="/docs/orm/overview/prisma-in-your-stack"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Prisma ORM in your stack</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/overview/databases" href="/docs/orm/overview/databases"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Databases</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/prisma-schema"><span class="">Prisma schema</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-schema/overview" href="/docs/orm/prisma-schema/overview"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Overview</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-schema/data-model" href="/docs/orm/prisma-schema/data-model"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Data model</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-schema/introspection" href="/docs/orm/prisma-schema/introspection"><span class="">Introspection</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-schema/postgresql-extensions" href="/docs/orm/prisma-schema/postgresql-extensions"><span class="">PostgreSQL extensions</span><span class="tag small">Preview</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/prisma-client"><span class="">Prisma Client</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/setup-and-configuration" href="/docs/orm/prisma-client/setup-and-configuration"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Setup & configuration</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/queries" href="/docs/orm/prisma-client/queries"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Queries</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/special-fields-and-types" href="/docs/orm/prisma-client/special-fields-and-types"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Fields & types</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/client-extensions" href="/docs/orm/prisma-client/client-extensions"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Extensions</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/type-safety" href="/docs/orm/prisma-client/type-safety"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Type safety</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/testing" href="/docs/orm/prisma-client/testing"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Testing</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/deployment" href="/docs/orm/prisma-client/deployment"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Deployment</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/observability-and-logging" href="/docs/orm/prisma-client/observability-and-logging"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Observability & logging</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-client/debugging-and-troubleshooting" href="/docs/orm/prisma-client/debugging-and-troubleshooting"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Debugging & troubleshooting</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/prisma-migrate"><span class="">Prisma Migrate</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-migrate/getting-started" href="/docs/orm/prisma-migrate/getting-started"><span class="">Getting started</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-migrate/understanding-prisma-migrate" href="/docs/orm/prisma-migrate/understanding-prisma-migrate"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Understanding Prisma Migrate</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/prisma-migrate/workflows" href="/docs/orm/prisma-migrate/workflows"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Workflows</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/tools"><span class="">Tools</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/tools/prisma-cli" href="/docs/orm/tools/prisma-cli"><span class="">Prisma CLI</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/tools/prisma-studio" href="/docs/orm/tools/prisma-studio"><span class="">Prisma Studio</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="active-item" id="/docs/orm/reference"><span class="">Reference</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a aria-current="page" class="active-item active-item" id="/docs/orm/reference/prisma-client-reference" href="/docs/orm/reference/prisma-client-reference"><span class="">Prisma Client API</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/prisma-schema-reference" href="/docs/orm/reference/prisma-schema-reference"><span class="">Prisma Schema</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/prisma-cli-reference" href="/docs/orm/reference/prisma-cli-reference"><span class="">Prisma CLI</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/error-reference" href="/docs/orm/reference/error-reference"><span class="">Errors</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/environment-variables-reference" href="/docs/orm/reference/environment-variables-reference"><span class="">Environment variables</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/database-features" href="/docs/orm/reference/database-features"><span class="">Database features matrix</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/supported-databases" href="/docs/orm/reference/supported-databases"><span class="">Supported databases</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/connection-urls" href="/docs/orm/reference/connection-urls"><span class="">Connection URLs</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/system-requirements" href="/docs/orm/reference/system-requirements"><span class="">System requirements</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/reference/preview-features" href="/docs/orm/reference/preview-features"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Preview features</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link "><a class="non-active" id="/docs/orm/more"><span class="">More</span></a><ul class="treeNode__List-sc-a5dz51-0 iVglbw"><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/under-the-hood" href="/docs/orm/more/under-the-hood"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Under the hood</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/upgrade-guides" href="/docs/orm/more/upgrade-guides"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Upgrade guides</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/comparisons" href="/docs/orm/more/comparisons"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Comparing Prisma ORM</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/migrating-to-prisma" href="/docs/orm/more/migrating-to-prisma"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Migrate to Prisma ORM</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/development-environment" href="/docs/orm/more/development-environment"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Development environment</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/help-and-troubleshooting" href="/docs/orm/more/help-and-troubleshooting"><span class="collapse-title"><button aria-label="collapse" class="item-collapser"><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="right close"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><svg width="8" height="6" viewbox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg" class="down close"><path d="M7.27575 0.5C7.88863 0.5 8.22342 1.18191 7.83107 1.63107L4.74043 5.16916C4.3551 5.61028 3.6449 5.61028 3.25957 5.16916L0.168926 1.63107C-0.223425 1.18191 0.111375 0.5 0.724247 0.5L7.27575 0.5Z" fill="#A0AEC0"/></svg></button><span class="">Help & troubleshooting</span></span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq more-padding"><a class="non-active" id="/docs/orm/more/releases" href="/docs/orm/more/releases"><span class="">ORM releases and maturity levels</span></a></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq static-link more-padding"/></ul></li><li class="treeNode__ListItem-sc-a5dz51-1 iPyMQq top-level "/></ul></li></ul></li></ul></div></aside></section></div><article class="layout__Content-sc-bupt9j-1 gmqsGj"><div class="layout__MaxWidth-sc-bupt9j-2 hdrMcE"><section class="top-section"><div class="topSection__TopSectionWrapper-sc-d3j04s-0 kIQBBY"><div class="parentTitleComp__BreadcrumbTitle-sc-f3mbxz-0 jOgsrP"><button class="customLink__CustomButton-sc-1xpvtl4-0 hyHLmQ"><i class="fa-solid fa-house undefined" style="text-align:center;font-size:16px;color:currentcolor;margin:"/></button><span> <!-- -->/<!-- --> </span><span><a href="/docs/orm"><span class="">ORM</span></a> / </span><span><a href="/docs/orm/reference"><span class="">Reference</span></a></span></div><div class="topSection__Header-sc-d3j04s-1 jIzYNj"><div class="title"><h1 class="topSection__MainTitle-sc-d3j04s-2 egpkGJ">Prisma Client API reference</h1></div><div class="tech-switch-block"/></div></div></section><section><p class="paragraph">The Prisma Client API reference documentation is based on the following schema:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token type-class-name"> String</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token type-class-name"> String</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@unique</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">0</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token type-class-name"> Role</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">USER</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> coinflips</span><span class="token type-class-name"> Boolean</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token type-class-name"> Post</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profile</span><span class="token type-class-name"> ExtendedProfile</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token type-class-name"> Json</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> ExtendedProfile</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userId</span><span class="token type-class-name"> Int</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@unique</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> bio</span><span class="token type-class-name"> String</span><span class="token operator" style="color:#393A34">?</span><span class="token not-class"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token not-class"> User</span><span class="token type-class-name"> User</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">userId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> Post</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token type-class-name"> Boolean</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> author</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@relation</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">authorId</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token type-args">references:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> authorId</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> comments</span><span class="token type-class-name"> Json</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> views</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">0</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> likes</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">0</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">enum</span><span class="token type-class-name"> Role</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token not-class"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token not-class"> USER</span><span class="token not-class"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token not-class"> ADMIN</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">All example generated types (such as <code class="inline-code">UserSelect</code> and <code class="inline-code">UserWhereUniqueInput</code>) are based on the <code class="inline-code">User</code> model.</p></section><section><h2 id="prismaclient" style="position:relative"><a href="#prismaclient" aria-label="inlinecodeprismaclientinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>datasources</inlinecode></h3><p class="paragraph">Programmatically overrides properties of the <code class="inline-code">datasource</code> block in the <code class="inline-code">schema.prisma</code> file - for example, as part of an integration test. See also: <a href="/docs/orm/prisma-schema/overview/data-sources">Data sources</a></p><p class="paragraph">From version 5.2.0 and upwards, you can also use the <a href="#datasourceurl"><code class="inline-code">datasourceUrl</code></a> property to programmatically override the database connection string.</p><section><h4 id="properties" style="position:relative"><a href="#properties" aria-label="properties permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Programmatically override a datasource <code class="inline-code">url</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> datasources</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> db</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> url</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'file:./dev_qa.db'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">Based on the following <code class="inline-code">datasource</code> block:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">datasource</span><span class="token plain"> db </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> provider </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"sqlite"</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> url </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">env</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"DATABASE_URL"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="datasourceurl" style="position:relative"><a href="#datasourceurl" aria-label="inlinecodedatasourceurlinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Log levels</h5><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Example</th></tr></thead><tbody><tr><td><code class="inline-code">query</code></td><td>Logs all queries run by Prisma. <br/><br/> For relational databases this logs all SQL queries. Example: <br/><code class="inline-code">prisma:query SELECT "public"."User"."id", "public"."User"."email" FROM "public"."User" WHERE ("public"."User"."id") IN (SELECT "t0"."id" FROM "public"."User" AS "t0" INNER JOIN "public"."Post" AS "j0" ON ("j0"."authorId") = ("t0"."id") WHERE ("j0"."views" > $1 AND "t0"."id" IS NOT NULL)) OFFSET $2</code> <br/> For MongoDB this logs queries using the <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl"><code class="inline-code">mongosh</code> shell<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button> format. Example: <br/> <code class="inline-code">prisma:query db.User.deleteMany({ _id: ( $in: [ “6221ce49f756b0721fc00542”, ], }, })</code></td></tr><tr><td><code class="inline-code">info</code></td><td>Example: <br/><code class="inline-code">prisma:info Started http server on http://127.0.0.1:58471</code></td></tr><tr><td><code class="inline-code">warn</code></td><td>Warnings.</td></tr><tr><td><code class="inline-code">error</code></td><td>Errors.</td></tr></tbody></table></div></section><section><h5 id="emit-formats" style="position:relative"><a href="#emit-formats" aria-label="emit formats permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Event types</h5><p class="paragraph">The <code class="inline-code">query</code> event type:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>index.d.ts</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">1</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">export</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">type</span><span class="token plain"> </span><span class="token class-name maybe-class-name">QueryEvent</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">2</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> timestamp</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token known-class-name class-name">Date</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">3</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> query</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">string</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Query sent to the database</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">4</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> params</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">string</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Query parameters</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">5</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> duration</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">number</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Time elapsed (in milliseconds) between client issuing query and database responding - not only time taken to run query</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">6</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> target</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">string</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">7</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">Note that for MongoDB, the <code class="inline-code">params</code> and <code class="inline-code">duration</code> fields will be undefined.</p><p class="paragraph">All other log level event types:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="file"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.625 1.99609H2.25C1.91848 1.99609 1.60054 2.12252 1.36612 2.34757C1.1317 2.57261 1 2.87783 1 3.19609V12.7961C1 13.1144 1.1317 13.4196 1.36612 13.6446C1.60054 13.8697 1.91848 13.9961 2.25 13.9961H9.75C10.0815 13.9961 10.3995 13.8697 10.6339 13.6446C10.8683 13.4196 11 13.1144 11 12.7961V6.19609L6.625 1.99609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 1.99609V7.99609H11" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>index.d.ts</span></div><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">1</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">export</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">type</span><span class="token plain"> </span><span class="token class-name maybe-class-name">LogEvent</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">2</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> timestamp</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token known-class-name class-name">Date</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">3</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> message</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">string</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">4</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> target</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token builtin">string</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineNo-sc-8eixcc-4 hEdunH line-no">5</span><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h4 id="examples-2" style="position:relative"><a href="#examples-2" aria-label="examples 2 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Log <code class="inline-code">query</code> and <code class="inline-code">info</code> to <code class="inline-code">stdout</code></h5><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> log</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'query'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'info'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> countUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">count</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">then</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> process</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">exit</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section><section><h5 id="log-a-query-event-to-console" style="position:relative"><a href="#log-a-query-event-to-console" aria-label="log a query event to console permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Log a <code class="inline-code">query</code> event to console</h5><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> log</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> level</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'query'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> emit</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'event'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$on</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'query'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> countUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">count</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">then</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> process</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">exit</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section><section><h5 id="log-info-warn-and-error-events-to-console" style="position:relative"><a href="#log-info-warn-and-error-events-to-console" aria-label="log info warn and error events to console permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Log <code class="inline-code">info</code>, <code class="inline-code">warn</code>, and <code class="inline-code">error</code> events to console</h5><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> log</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> level</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'warn'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> emit</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'event'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> level</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'info'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> emit</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'event'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> level</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'error'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> emit</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'event'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$on</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'warn'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$on</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'info'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$on</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'error'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> countUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">count</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">then</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> process</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">exit</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section></section></section><section><h3 id="errorformat" style="position:relative"><a href="#errorformat" aria-label="inlinecodeerrorformatinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Example</h4><p class="paragraph">The example below uses the <a href="/docs/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm-preview">Neon driver adapter</a></p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">Pool</span><span class="token imports punctuation" style="color:#393A34">,</span><span class="token imports"> neonConfig </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@neondatabase/serverless'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaNeon</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/adapter-neon'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports">dotenv</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'dotenv'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports">ws</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ws'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">dotenv</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">config</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">neonConfig</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">webSocketConstructor</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> ws</span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> connectionString </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token template-string template-punctuation string" style="color:#e3116c">`</span><span class="token template-string interpolation interpolation-punctuation punctuation" style="color:#393A34">${</span><span class="token template-string interpolation">process</span><span class="token template-string interpolation punctuation" style="color:#393A34">.</span><span class="token template-string interpolation">env</span><span class="token template-string interpolation punctuation" style="color:#393A34">.</span><span class="token template-string interpolation constant" style="color:#36acaa">DATABASE_URL</span><span class="token template-string interpolation interpolation-punctuation punctuation" style="color:#393A34">}</span><span class="token template-string template-punctuation string" style="color:#e3116c">`</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> pool </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">Pool</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> connectionString </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> adapter </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaNeon</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">pool</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> adapter </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h3 id="rejectonnotfound" style="position:relative"><a href="#rejectonnotfound" aria-label="inlinecoderejectonnotfoundinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>rejectOnNotFound</inlinecode></h3><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><div class="admonition__FlexContainer-sc-htoeam-0 lfvhpa"><div class="admonition__ChildDiv-sc-htoeam-1 dDjWVR"><strong>Note</strong>: <code class="inline-code">rejectOnNotFound</code> was removed in v5.0.0.</div><div class="admonition__ChildDiv-sc-htoeam-1 dDjWVR"><strong>Deprecated:</strong> <code class="inline-code">rejectOnNotFound</code> is deprecated in v4.0.0. From v4.0.0, use the queries <a href="#finduniqueorthrow"><code class="inline-code">findUniqueOrThrow</code></a> or <a href="#findfirstorthrow"><code class="inline-code">findFirstOrThrow</code></a>.</div></div></span><p class="paragraph">Use the <code class="inline-code">rejectOnNotFound</code> parameter to configure <code class="inline-code">findUnique</code> and/or <code class="inline-code">findFirst</code> to throw an error if the record was not found. By default, both operations return <code class="inline-code">null</code> if the record is not found.</p><section><h4 id="remarks-2" style="position:relative"><a href="#remarks-2" aria-label="remarks 2 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Throw a custom error per model and operation if record is not found</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> rejectOnNotFound</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> findFirst</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token function-variable function maybe-class-name" style="color:#d73a49">User</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">err</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name known-class-name class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'User error'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token function-variable function maybe-class-name" style="color:#d73a49">Post</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">err</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name known-class-name class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'Post error!'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> findUnique</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token function-variable function maybe-class-name" style="color:#d73a49">User</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">err</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name known-class-name class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'User error'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token function-variable function maybe-class-name" style="color:#d73a49">Post</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">err</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name known-class-name class-name">Error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'Post error!'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="transactionoptions" style="position:relative"><a href="#transactionoptions" aria-label="inlinecodetransactionoptionsinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">maxWait</code></td><td>The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds.</td></tr><tr><td><code class="inline-code">timeout</code></td><td>The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds.</td></tr><tr><td><code class="inline-code">isolationLevel</code></td><td>Sets the <a href="/docs/orm/prisma-client/queries/transactions#transaction-isolation-level">transaction isolation level</a>. By default this is set to the value currently configured in your database. The available can vary depending on the database you use.</td></tr></tbody></table></div></section><section><h4 id="example-1" style="position:relative"><a href="#example-1" aria-label="example 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li>Prisma Client's dataloader <a href="/docs/orm/prisma-client/queries/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prisma-clients-dataloader">automatically batches <code class="inline-code">findUnique</code> queries</a> with the same <code class="inline-code">select</code> and <code class="inline-code">where</code> parameters.</li><li>If you want the query to throw an error if the record is not found, then consider using <a href="#finduniqueorthrow"><code class="inline-code">findUniqueOrThrow</code></a> instead.</li><li>You cannot use <a href="#filter-conditions-and-operators">filter conditions</a> (e.g. <code class="inline-code">equals</code>, <code class="inline-code">contains</code>, <code class="inline-code">not</code>) to filter fields of the <a href="/docs/orm/reference/prisma-schema-reference#json">JSON</a> data type. Using filter conditions will likely result in a <code class="inline-code">null</code> response for that field.</li></ul></section><section><h4 id="options-3" style="position:relative"><a href="#options-3" aria-label="options 3 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Example type (<code class="inline-code">User</code>)</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td><strong>Yes</strong></td><td>Wraps all <em>unique</em> fields of a model so that individual records can be selected. <br/>From version 4.5.0, this type wraps all fields of a model. <a href="#filter-on-non-unique-fields-with-userwhereuniqueinput">Learn more</a></td></tr><tr><td><code class="inline-code">select</code></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><code class="inline-code">include</code></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr><tr><td><code class="inline-code">rejectOnNotFound</code> (deprecated)</td><td><code class="inline-code">RejectOnNotFound</code></td><td>No</td><td>If true, throw a <code class="inline-code">NotFoundError: No User found error</code>. You can also <a href="#rejectonnotfound">configure <code class="inline-code">rejectOnNotFound</code> globally</a>. <br/><strong>Note:</strong> <code class="inline-code">rejectOnNotFound</code>is deprecated in v4.0.0. From v4.0.0, use <a href="#finduniqueorthrow"><code class="inline-code">findUniqueOrThrow</code></a> instead.</td></tr></tbody></table></div></section><section><h4 id="return-type" style="position:relative"><a href="#return-type" aria-label="return type permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Return type</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Return type</th><th>Example</th><th>Description</th></tr></thead><tbody><tr><td>JavaScript object (typed)</td><td><code class="inline-code">User</code></td><td/></tr><tr><td>JavaScript object (plain)</td><td><code class="inline-code">{ title: "Hello world" }</code></td><td>Use <code class="inline-code">select</code> and <code class="inline-code">include</code> to determine which fields to return.</td></tr><tr><td><code class="inline-code">null</code></td><td><code class="inline-code">null</code></td><td>Record not found</td></tr><tr><td>Error</td><td/><td>If <code class="inline-code">rejectOnNotFound</code> is true, <code class="inline-code">findUnique</code> throws an error (<code class="inline-code">NotFoundError</code> by default, <a href="#rejectonnotfound">customizable globally</a>) instead of returning <code class="inline-code">null</code>.</td></tr></tbody></table></div></section><section><h4 id="examples-5" style="position:relative"><a href="#examples-5" aria-label="examples 5 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get the <code class="inline-code">User</code> record with <code class="inline-code">firstName</code> of <code class="inline-code">Alice</code> and <code class="inline-code">lastName</code> of <code class="inline-code">Smith</code> (<code class="inline-code">@@unique</code>)</h5><div class="collapsible__Wrapper-sc-atw4gb-0 jOWteu"><div class="collapsible__Tab-sc-atw4gb-1 kOYPPx"><input type="checkbox" id="tab-160" name="tab" class="collapsible__Input-sc-atw4gb-4 jvueWa"/><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="collapsible__StyledArrow-sc-atw4gb-5 XNUMj"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><label for="tab-160" class="collapsible__Label-sc-atw4gb-2 kVOMbE">Expand for example User model with a @@unique block</label><div class="collapsible__TabContent-sc-atw4gb-3 hdGwPH tab-content"><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> firstName</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> lastName</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@@unique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token type-args">fields:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">firstName</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> lastName</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> name</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"fullname"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></div></div></div><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> fullname</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// name property of @@unique attribute - default is firstname_lastname</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> firstName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> lastName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Smith'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="get-the-user-record-with-firstname-of-alice-and-lastname-of-smith-id" style="position:relative"><a href="#get-the-user-record-with-firstname-of-alice-and-lastname-of-smith-id" aria-label="get the user record with firstname of alice and lastname of smith id permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get the <code class="inline-code">User</code> record with <code class="inline-code">firstName</code> of <code class="inline-code">Alice</code> and <code class="inline-code">lastName</code> of <code class="inline-code">Smith</code> (<code class="inline-code">@@id</code>)</h5><div class="collapsible__Wrapper-sc-atw4gb-0 jOWteu"><div class="collapsible__Tab-sc-atw4gb-1 kOYPPx"><input type="checkbox" id="tab-161" name="tab" class="collapsible__Input-sc-atw4gb-4 jvueWa"/><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="collapsible__StyledArrow-sc-atw4gb-5 XNUMj"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><label for="tab-161" class="collapsible__Label-sc-atw4gb-2 kVOMbE">Expand for example User model with an @@id block</label><div class="collapsible__TabContent-sc-atw4gb-3 hdGwPH tab-content"><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> firstName</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> lastName</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@@id</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">firstName</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> lastName</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></div></div></div><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> firstName_lastName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> firstName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> lastName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Smith'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="finduniqueorthrow" style="position:relative"><a href="#finduniqueorthrow" aria-label="inlinecodefinduniqueorthrowinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>findUniqueOrThrow()</inlinecode></h3><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><p class="paragraph">We introduced <code class="inline-code">findUniqueOrThrow</code> in v4.0.0. It replaces the <a href="#rejectonnotfound"><code class="inline-code">rejectOnNotFound</code></a> option. <code class="inline-code">rejectOnNotFound</code> is deprecated in v4.0.0.</p></span><p class="paragraph"><code class="inline-code">findUniqueOrThrow</code> retrieves a single data record in the same way as <a href="#findunique"><code class="inline-code">findUnique</code></a>. However, if the query does not find a record, it returns <code class="inline-code">NotFoundError: No User found error</code>.</p><p class="paragraph"><code class="inline-code">findUniqueOrThrow</code> differs from <code class="inline-code">findUnique</code> as follows:</p><ul class="list"><li><p class="paragraph">Its return type is non-nullable. For example, <code class="inline-code">post.findUnique()</code> can return <code class="inline-code">post</code> or <code class="inline-code">null</code>, but <code class="inline-code">post.findUniqueOrThrow()</code> always returns <code class="inline-code">post</code>.</p></li><li><p class="paragraph">It is not compatible with sequential operations in the <a href="/docs/orm/prisma-client/queries/transactions#the-transaction-api"><code class="inline-code">$transaction</code> API</a>. If the query returns <code class="inline-code">NotFoundError</code>, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the <code class="inline-code">$transaction</code> API, as follows:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token function" style="color:#d73a49">$transaction</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">model</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">model</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUniqueOrThrow</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li></ul></section><section><h3 id="findfirst" style="position:relative"><a href="#findfirst" aria-label="inlinecodefindfirstinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Example type (<code class="inline-code">User</code>)</th><th>Required</th><th>Description</th><th/></tr></thead><tbody><tr><td><code class="inline-code">select</code></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td><td/></tr><tr><td><code class="inline-code">include</code></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td><td/></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td><td/></tr><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> model fields in a type so that the list can be filtered by any property.</td><td/></tr><tr><td><code class="inline-code">orderBy</code></td><td><code class="inline-code">XOR<Enumerable<User</code><br/><code class="inline-code">OrderByInput>,UserOrderByInput></code></td><td>No</td><td>Lets you order the returned list by any property.</td><td/></tr><tr><td><code class="inline-code">cursor</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td>No</td><td>Specifies the position for the list (the value typically specifies an <code class="inline-code">id</code> or another unique value).</td><td/></tr><tr><td><code class="inline-code">take</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many objects should be returned in the list. When used with <code class="inline-code">findFirst</code>, <code class="inline-code">take</code> is implicitly <code class="inline-code">1</code> or <code class="inline-code">-1</code>. <code class="inline-code">findFirst</code> is only affected by whether the value is positive or negative - any negative value reverses the list.</td><td/></tr><tr><td><code class="inline-code">skip</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many of the returned objects in the list should be skipped.</td><td/></tr><tr><td><code class="inline-code">distinct</code></td><td><code class="inline-code">Enumerable<UserDistinct</code><br/><code class="inline-code">FieldEnum></code></td><td>No</td><td>Lets you filter out duplicate rows by a specific field - for example, return only distinct <code class="inline-code">Post</code> titles.</td><td/></tr><tr><td><code class="inline-code">rejectOnNotFound</code> (deprecated)</td><td><code class="inline-code">RejectOnNotFound</code></td><td>No</td><td>If true, throw a <code class="inline-code">NotFoundError: No User found error</code>. You can also <a href="#rejectonnotfound">configure <code class="inline-code">rejectOnNotFound</code> globally</a>. <br/><strong>Note:</strong> <code class="inline-code">rejectOnNotFound</code>is deprecated in v4.0.0. From v4.0.0, use <a href="#findfirstorthrow"><code class="inline-code">findFirstOrThrow</code></a> instead.</td><td/></tr></tbody></table></div></section><section><h4 id="return-type-1" style="position:relative"><a href="#return-type-1" aria-label="return type 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Return type</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Return type</th><th>Example</th><th>Description</th></tr></thead><tbody><tr><td>JavaScript object (typed)</td><td><code class="inline-code">User</code></td><td>Specifies which properties to include on the returned object.</td></tr><tr><td>JavaScript object (plain)</td><td><code class="inline-code">{ title: "Hello world" }</code></td><td>Use <code class="inline-code">select</code> and <code class="inline-code">include</code> to determine which fields to return.</td></tr><tr><td><code class="inline-code">null</code></td><td><code class="inline-code">null</code></td><td>Record not found</td></tr><tr><td>Error</td><td/><td>If <code class="inline-code">rejectOnNotFound</code> is true, <code class="inline-code">findUnique</code> throws an error (<code class="inline-code">NotFoundError</code> by default, <a href="#rejectonnotfound">customizable globally</a>) instead of returning <code class="inline-code">null</code>.</td></tr></tbody></table></div></section><section><h4 id="remarks-6" style="position:relative"><a href="#remarks-6" aria-label="remarks 6 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get the first <code class="inline-code">Post</code> record where the <code class="inline-code">title</code> starts with <code class="inline-code">A test</code>, reverse the list with <code class="inline-code">take</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> a </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'A test 1'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> b </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'A test 2'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> c </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findFirst</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> startsWith</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'A test'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'asc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> take</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">-</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Reverse the list</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="findfirstorthrow" style="position:relative"><a href="#findfirstorthrow" aria-label="inlinecodefindfirstorthrowinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>findFirstOrThrow()</inlinecode></h3><span style=""/><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><p class="paragraph">We introduced <code class="inline-code">findFirstOrThrow</code> in v4.0.0. It replaces the <a href="#rejectonnotfound"><code class="inline-code">rejectOnNotFound</code></a> option. <code class="inline-code">rejectOnNotFound</code> is deprecated in v4.0.0.</p></span><p class="paragraph"><code class="inline-code">findFirstOrThrow</code> retrieves the first record in a list in the same way as <a href="#findfirst"><code class="inline-code">findFirst</code></a>. However, if the query does not find a record, it returns <code class="inline-code">NotFoundError: No User found error</code>.</p><p class="paragraph"><code class="inline-code">findFirstOrThrow</code> differs from <code class="inline-code">findFirst</code> as follows:</p><ul class="list"><li><p class="paragraph">Its return type is non-nullable. For example, <code class="inline-code">post.findFirst()</code> can return <code class="inline-code">post</code> or <code class="inline-code">null</code>, but <code class="inline-code">post.findFirstOrThrow</code> always returns <code class="inline-code">post</code>.</p></li><li><p class="paragraph">It is not compatible with sequential operations in the <a href="/docs/orm/prisma-client/queries/transactions#the-transaction-api"><code class="inline-code">$transaction</code> API</a>. If the query returns <code class="inline-code">NotFoundError</code>, then the API will not roll back any operations in the array of calls. As a workaround, you can use interactive transactions with the <code class="inline-code">$transaction</code> API, as follows:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$transaction</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">tx</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> tx</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">model</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> tx</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">model</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findFirstOrThrow</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li></ul></section><section><h3 id="findmany" style="position:relative"><a href="#findmany" aria-label="inlinecodefindmanyinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">select</code></td><td><code class="inline-code">XOR<PostSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><code class="inline-code">include</code></td><td><code class="inline-code">XOR<PostInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> model fields in a type so that the list can be filtered by any property.</td></tr><tr><td><code class="inline-code">orderBy</code></td><td><code class="inline-code">XOR<Enumerable<PostOrder</code><br/><code class="inline-code">ByInput>, PostOrderByInput></code></td><td>No</td><td>Lets you order the returned list by any property.</td></tr><tr><td><code class="inline-code">cursor</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td>No</td><td>Specifies the position for the list (the value typically specifies an <code class="inline-code">id</code> or another unique value).</td></tr><tr><td><code class="inline-code">take</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many objects should be returned in the list (as seen from the <em>beginning</em> (positive value) or <em>end</em> (negative value) <strong>either</strong> of the list <strong>or</strong> from the <code class="inline-code">cursor</code> position if mentioned)</td></tr><tr><td><code class="inline-code">skip</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many of the returned objects in the list should be skipped.</td></tr><tr><td><code class="inline-code">distinct</code></td><td><code class="inline-code">Enumerable<UserDistinctFieldEnum></code></td><td>No</td><td>Lets you filter out duplicate rows by a specific field - for example, return only distinct <code class="inline-code">Post</code> titles.</td></tr></tbody></table></div></section><section><h4 id="return-type-2" style="position:relative"><a href="#return-type-2" aria-label="return type 2 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">data</code></td><td><code class="inline-code">XOR<UserCreateInput,</code> <br/><code class="inline-code">UserUncheckedCreateInput></code></td><td><strong>Yes</strong></td><td>Wraps all the model fields in a type so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional.</td></tr><tr><td><a href="#select"><code class="inline-code">select</code></a></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><a href="#include"><code class="inline-code">include</code></a></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr><tr><td/><td/><td/><td/></tr></tbody></table></div></section><section><h4 id="return-type-3" style="position:relative"><a href="#return-type-3" aria-label="return type 3 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create multiple new records</h5><p class="paragraph">In most cases, you can carry out batch inserts with the <a href="#createmany"><code class="inline-code">createMany</code></a> query. However, <a href="#remarks-10">there are scenarios where <code class="inline-code">create</code> is the best option to insert multiple records</a>.</p><p class="paragraph">The following example results in <strong>two</strong> <code class="inline-code">INSERT</code> statements:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">Prisma</span><span class="token imports punctuation" style="color:#393A34">,</span><span class="token imports"> </span><span class="token imports maybe-class-name">PrismaClient</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> prisma </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">new</span><span class="token plain"> </span><span class="token class-name maybe-class-name">PrismaClient</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> log</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'query'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">let</span><span class="token plain"> users</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access maybe-class-name">UserCreateInput</span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ariana@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Ari'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">20</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> coinflips</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ADMIN'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'elsa@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Elsa'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">20</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> coinflips</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ADMIN'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> </span><span class="token known-class-name class-name">Promise</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">all</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> users</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">map</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">user</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> user</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">then</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">catch</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">error</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">e</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$disconnect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> process</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">exit</span><span class="token punctuation" style="color:#393A34">(</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Hide CLI results</div><div class="result-code"><cmdresult><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-sql " style="color:#393A34;background-color:#f6f8fa"><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">BEGIN</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">INTO</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"name"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"email"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"role"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"coinflips"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">2</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">4</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">5</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">RETURNING</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"name"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"email"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"role"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"coinflips"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">FROM</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">WHERE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">LIMIT</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">2</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">OFFSET</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">3</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">INTO</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"name"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"email"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"role"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"coinflips"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">2</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">4</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">5</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">RETURNING</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">COMMIT</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">SELECT</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"name"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"email"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"role"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"coinflips"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">FROM</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">WHERE</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">LIMIT</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">2</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">OFFSET</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">3</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma:query </span><span class="token keyword" style="color:#00009f">COMMIT</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmdresult></div></div></div></section></section></section><section><h3 id="update" style="position:relative"><a href="#update" aria-label="inlinecodeupdateinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">data</code></td><td><code class="inline-code">XOR<UserUpdateInput</code><br/><code class="inline-code">UserUncheckedUpdateInput></code></td><td><strong>Yes</strong></td><td>Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional.</td></tr><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td><strong>Yes</strong></td><td>Wraps all <em>unique</em> fields of a model so that individual records can be selected. <br/>From version 4.5.0, this type wraps all fields of a model. <a href="#filter-on-non-unique-fields-with-userwhereuniqueinput">Learn more</a></td></tr><tr><td><a href="#select"><code class="inline-code">select</code></a></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><a href="#include"><code class="inline-code">include</code></a></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr></tbody></table></div></section><section><h4 id="return-type-4" style="position:relative"><a href="#return-type-4" aria-label="return type 4 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>upsert()</inlinecode></h3><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><p class="paragraph">This section covers the usage of the <code class="inline-code">upsert()</code> operation. To learn about using <a href="#upsert-1">nested upsert queries</a> within <code class="inline-code">update()</code>, reference the linked documentation.</p></span><p class="paragraph"><code class="inline-code">upsert</code> does the following:</p><ul class="list"><li>If an existing database record satisfies the <code class="inline-code">where</code> condition, it updates that record</li><li>If no database record satisfies the <code class="inline-code">where</code> condition, it creates a new database record</li></ul><section><h4 id="options-8" style="position:relative"><a href="#options-8" aria-label="options 8 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">create</code></td><td><code class="inline-code">XOR<UserCreateInput,</code><br/><code class="inline-code">UserUncheckedCreateInput></code></td><td><strong>Yes</strong></td><td>Wraps all the fields of the model so that they can be provided when creating new records. It also includes relation fields which lets you perform (transactional) nested inserts. Fields that are marked as optional or have default values in the datamodel are optional.</td></tr><tr><td><code class="inline-code">update</code></td><td><code class="inline-code">XOR<UserUpdateInput,</code><br/><code class="inline-code">UserUncheckedUpdateInput></code></td><td><strong>Yes</strong></td><td>Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional.</td></tr><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td><strong>Yes</strong></td><td>Wraps all <em>unique</em> fields of a model so that individual records can be selected. <br/>From version 4.5.0, this type wraps all fields of a model. <a href="#filter-on-non-unique-fields-with-userwhereuniqueinput">Learn more</a></td></tr><tr><td><a href="#select"><code class="inline-code">select</code></a></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><a href="#include"><code class="inline-code">include</code></a></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr></tbody></table></div></section><section><h4 id="return-type-5" style="position:relative"><a href="#return-type-5" aria-label="return type 5 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li>To perform arithmetic operations on update (add, subtract, multiply, divide), use <a href="#atomic-number-operations">atomic updates</a> to prevent race conditions.</li><li>If two or more upsert operations happen at the same time and the record doesn't already exist, then a race condition might happen. As a result, one or more of the upsert operations might throw a unique key constraint error. Your application code can catch this error and retry the operation. <a href="#unique-key-constraint-errors-on-upserts">Learn more</a>.</li><li>From version 4.6.0, Prisma ORM hands over upsert queries to the database where possible. <a href="#database-upserts">Learn more</a>.</li></ul></section><section><h4 id="examples-10" style="position:relative"><a href="#examples-10" aria-label="examples 10 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Cause</h5><p class="paragraph">When Prisma Client does an upsert, it first checks whether that record already exists in the database. To make this check, Prisma Client performs a read operation with the <code class="inline-code">where</code> clause from the upsert operation. This has two possible outcomes, as follows:</p><ul class="list"><li>If the record does not exist, then Prisma Client creates that record.</li><li>If the record exists, then Prisma Client updates it.</li></ul><p class="paragraph">When your application tries to perform two or more concurrent upsert operations, then a race condition might happen where two or more operations do not find the record and therefore try to create that record. In this situation, one of the operations successfully creates the new record but the other operations fail and return a unique key constraint error.</p></section><section><h5 id="solution" style="position:relative"><a href="#solution" aria-label="solution permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Database upserts</h4><p class="paragraph">Where possible, Prisma Client hands over an <code class="inline-code">upsert</code> query to the database. This is called a <em>database upsert</em>.</p><p class="paragraph">Database upserts have the following advantages:</p><ul class="list"><li>They are faster than upserts handled by Prisma Client</li><li><a href="#unique-key-constraint-errors-on-upserts">Unique key constraint errors</a> cannot happen</li></ul><p class="paragraph">Prisma Client uses a database upsert automatically when <a href="#database-upsert-query-criteria">specific criteria</a> are met. When these criteria are not met, Prisma Client handles the <code class="inline-code">upsert</code>.</p><p class="paragraph">To use a database upsert, Prisma Client sends the SQL construction <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl"><code class="inline-code">INSERT ... ON CONFLICT SET .. WHERE</code></button> to the database.</p><section><h5 id="database-upsert-prerequisites" style="position:relative"><a href="#database-upsert-prerequisites" aria-label="database upsert prerequisites permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Database upsert query criteria</h5><p class="paragraph">Prisma Client uses a database upsert for an <code class="inline-code">upsert</code> query when the query meets the following criteria:</p><ul class="list"><li>There are no nested queries in the <code class="inline-code">upsert</code>'s <code class="inline-code">create</code> and <code class="inline-code">update</code> <a href="#options-7">options</a></li><li>The query does <em>not</em> include a selection that uses a <a href="/docs/orm/prisma-client/queries/relation-queries#nested-reads">nested read</a></li><li>The query modifies only one model</li><li>There is only one unique field in the <code class="inline-code">upsert</code>'s <code class="inline-code">where</code> option</li><li>The unique field in the <code class="inline-code">where</code> option and the unique field in the <code class="inline-code">create</code> option have the same value</li></ul><p class="paragraph">If your query does not meet these criteria, then Prisma Client handles the upsert itself.</p></section><section><h5 id="database-upsert-examples" style="position:relative"><a href="#database-upsert-examples" aria-label="database upsert examples permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Database upsert examples</h5><p class="paragraph">The following examples use this schema:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token type-class-name"> String</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@unique</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@@unique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain">id</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> profileViews</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following <code class="inline-code">upsert</code> query meets all of the criteria, so Prisma Client uses a database upsert.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">upsert</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'updated@example.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">In this situation, Prisma uses the following SQL query:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-sql " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">INTO</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"id"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"userName"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token string" style="color:#e3116c">"email"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">2</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain">$</span><span class="token number" style="color:#36acaa">4</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">ON</span><span class="token plain"> CONFLICT </span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"userName"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">DO</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">UPDATE</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">SET</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"email"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">5</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">WHERE</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"userName"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> $</span><span class="token number" style="color:#36acaa">6</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">AND</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token operator" style="color:#393A34">=</span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">RETURNING</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"id"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"profileViews"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"userName"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"public"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"User"</span><span class="token punctuation" style="color:#393A34">.</span><span class="token string" style="color:#e3116c">"email"</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following query has multiple unique values in the <code class="inline-code">where</code> clause, so Prisma Client does <em>not</em> use a database upsert:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access maybe-class-name">User</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">upsert</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'updated@example.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">In the following query, the values for <code class="inline-code">userName</code> in the <code class="inline-code">where</code> and <code class="inline-code">create</code> options are different, so Prisma Client does <em>not</em> use a database upsert.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access maybe-class-name">User</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">upsert</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'AliceS'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'updated@example.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">In the following query, the selection on the <code class="inline-code">title</code> field in <code class="inline-code">posts</code> is a nested read, so Prisma Client does <em>not</em> use a database upsert.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">upsert</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userName</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alice'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'updated@example.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="delete" style="position:relative"><a href="#delete" aria-label="inlinecodedeleteinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td><strong>Yes</strong></td><td>Wraps all <em>unique</em> fields of a model so that individual records can be selected. <br/>From version 4.5.0, this type wraps all fields of a model. <a href="#filter-on-non-unique-fields-with-userwhereuniqueinput">Learn more</a></td></tr><tr><td><a href="#select"><code class="inline-code">select</code></a></td><td><code class="inline-code">XOR<UserSelect, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/select-fields">Specifies which properties to include</a> on the returned object.</td></tr><tr><td><a href="#include"><code class="inline-code">include</code></a></td><td><code class="inline-code">XOR<UserInclude, null></code></td><td>No</td><td><a href="/docs/orm/prisma-client/queries/relation-queries">Specifies which relations should be eagerly loaded</a> on the returned object.</td></tr><tr><td><code class="inline-code">relationLoadStrategy</code></td><td><code class="inline-code">'join'</code> or <code class="inline-code">'query'</code></td><td>No</td><td><strong>Default: <code class="inline-code">join</code></strong>. Specifies the <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">load strategy</a> for a relation query. Only available in combination with <code class="inline-code">include</code> (or <code class="inline-code">select</code> on a relation field). In <a href="/docs/orm/more/releases#preview">Preview</a> since 5.9.0.</td></tr></tbody></table></div></section><section><h4 id="return-type-6" style="position:relative"><a href="#return-type-6" aria-label="return type 6 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Return type</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Return type</th><th>Example</th><th>Description</th></tr></thead><tbody><tr><td>JavaScript object (typed)</td><td><code class="inline-code">User</code></td><td>The <code class="inline-code">User</code> record that was deleted.</td></tr><tr><td>JavaScript object (plain)</td><td><code class="inline-code">{ name: "Alice Wonderland" }</code></td><td>Data from the <code class="inline-code">User</code> record that was deleted. Use <code class="inline-code">select</code> and <code class="inline-code">include</code> to determine which fields to return.</td></tr><tr><td><code class="inline-code">RecordNotFound</code> exception</td><td/><td>Throws an exception if record does not exist.</td></tr></tbody></table></div></section><section><h4 id="remarks-10" style="position:relative"><a href="#remarks-10" aria-label="remarks 10 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Delete the <code class="inline-code">User</code> record where <code class="inline-code">email</code> equals <code class="inline-code">else@prisma.io</code></h5><p class="paragraph">The following query deletes a specific user record and uses <code class="inline-code">select</code> to return the <code class="inline-code">name</code> and <code class="inline-code">email</code> of the deleted user:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> deleteUser </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token keyword" style="color:#00009f">delete</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'elsa@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Hide CLI results</div><div class="result-code"><cmdresult><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-json " style="color:#393A34;background-color:#f6f8fa"><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"email"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"elsa@prisma.io"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Elsa"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmdresult></div></div></div></section></section></section><section><h3 id="createmany" style="position:relative"><a href="#createmany" aria-label="inlinecodecreatemanyinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">data</code></td><td><code class="inline-code">Enumerable<UserCreateManyInput></code></td><td><strong>Yes</strong></td><td>Wraps all the model fields in a type so that they can be provided when creating new records. Fields that are marked as optional or have default values in the datamodel are optional.</td></tr><tr><td><code class="inline-code">skipDuplicates?</code></td><td><code class="inline-code">boolean</code></td><td>No</td><td>Do not insert records with unique fields or ID fields that already exist. Only supported by databases that support <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl"><code class="inline-code">ON CONFLICT DO NOTHING</code><svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button>. This excludes MongoDB and SQLServer</td></tr></tbody></table></div></section><section><h4 id="return-type-7" style="position:relative"><a href="#return-type-7" aria-label="return type 7 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><code class="inline-code">createMany</code> is not supported by SQLite.</li><li>The <code class="inline-code">skipDuplicates</code> option is not supported by MongoDB and SQLServer.</li><li>You <strong>cannot</strong> create or connect relations - you cannot nest <code class="inline-code">create</code>, <code class="inline-code">createMany</code>, <code class="inline-code">connect</code>, <code class="inline-code">connectOrCreate</code> inside a top-level <code class="inline-code">createMany</code></li><li>You can nest a <a href="#createmany-1"><code class="inline-code">createMany</code></a> inside an <code class="inline-code">update</code> or <code class="inline-code">create</code> query - for example, add a <code class="inline-code">User</code> and two <code class="inline-code">Post</code> records at the same time.</li></ul></section><section><h4 id="examples-12" style="position:relative"><a href="#examples-12" aria-label="examples 12 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">data</code></td><td><code class="inline-code">XOR<UserUpdateManyMutationInput,</code><br/><code class="inline-code">UserUncheckedUpdateManyInput></code></td><td><strong>Yes</strong></td><td>Wraps all the fields of the model so that they can be provided when updating an existing record. Fields that are marked as optional or have default values in the datamodel are optional on <code class="inline-code">data</code>.</td></tr><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> fields of a model so that the list can be filtered by any property. If you do not filter the list, all records will be updated.</td></tr></tbody></table></div></section><section><h4 id="return-type-8" style="position:relative"><a href="#return-type-8" aria-label="return type 8 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update all <code class="inline-code">User</code> records where the <code class="inline-code">email</code> contains <code class="inline-code">prisma.io</code> and at least one related <code class="inline-code">Post</code> has more than 10 likes</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> deleteUser </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">updateMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> some</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> likes</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> gt</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">10</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'USER'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="deletemany" style="position:relative"><a href="#deletemany" aria-label="inlinecodedeletemanyinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> model fields in a type so that the list can be filtered by any property.</td></tr><tr><td><code class="inline-code">orderBy</code></td><td><code class="inline-code">XOR<Enumerable<PostOrder</code><br/><code class="inline-code">ByInput>, PostOrderByInput></code></td><td>No</td><td>Lets you order the returned list by any property.</td></tr><tr><td><code class="inline-code">cursor</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td>No</td><td>Specifies the position for the list (the value typically specifies an <code class="inline-code">id</code> or another unique value).</td></tr><tr><td><code class="inline-code">take</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many objects should be returned in the list (as seen from the <em>beginning</em> (positive value) or <em>end</em> (negative value) <strong>either</strong> of the list <strong>or</strong> from the <code class="inline-code">cursor</code> position if mentioned)</td></tr><tr><td><code class="inline-code">skip</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many of the returned objects in the list should be skipped.</td></tr></tbody></table></div></section><section><h4 id="return-type-10" style="position:relative"><a href="#return-type-10" aria-label="return type 10 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Use <code class="inline-code">select</code> to perform three separate counts</h5><p class="paragraph">The following query returns:</p><ul class="list"><li>A count of all records (<code class="inline-code">_all</code>)</li><li>A count of all records with non-<code class="inline-code">null</code> <code class="inline-code">name</code> fields</li><li>A count of all records with non-<code class="inline-code">null</code> <code class="inline-code">city</code> fields</li></ul><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> c </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">count</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _all</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="aggregate" style="position:relative"><a href="#aggregate" aria-label="inlinecodeaggregateinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> model fields in a type so that the list can be filtered by any property.</td></tr><tr><td><code class="inline-code">orderBy</code></td><td><code class="inline-code">XOR<Enumerable<UserOrderByInput>,</code><br/><code class="inline-code">UserOrderByInput></code></td><td>No</td><td>Lets you order the returned list by any property.</td></tr><tr><td><code class="inline-code">cursor</code></td><td><code class="inline-code">UserWhereUniqueInput</code></td><td>No</td><td>Specifies the position for the list (the value typically specifies an <code class="inline-code">id</code> or another unique value).</td></tr><tr><td><code class="inline-code">take</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many objects should be returned in the list (as seen from the <em>beginning</em> (positive value) or <em>end</em> (negative value) <strong>either</strong> of the list <strong>or</strong> from the <code class="inline-code">cursor</code> position if mentioned)</td></tr><tr><td><code class="inline-code">skip</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many of the returned objects in the list should be skipped.</td></tr><tr><td><code class="inline-code">_count</code></td><td><code class="inline-code">true</code></td><td>No</td><td>Returns a count of matching records or non-<code class="inline-code">null</code> fields.</td></tr><tr><td><code class="inline-code">_avg</code></td><td><code class="inline-code">UserAvgAggregateInputType</code></td><td>No</td><td>Returns an average of all values of the specified field.</td></tr><tr><td><code class="inline-code">_sum</code></td><td><code class="inline-code">UserSumAggregateInputType</code></td><td>No</td><td>Returns the sum of all values of the specified field.</td></tr><tr><td><code class="inline-code">_min</code></td><td><code class="inline-code">UserMinAggregateInputType</code></td><td>No</td><td>Returns the smallest available value of the specified field.</td></tr><tr><td><code class="inline-code">_max</code></td><td><code class="inline-code">UserMaxAggregateInputType</code></td><td>No</td><td>Returns the largest available value of the specified field.</td></tr></tbody></table></div></section><section><h4 id="examples-16" style="position:relative"><a href="#examples-16" aria-label="examples 16 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Options</h4><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">where</code></td><td><code class="inline-code">UserWhereInput</code></td><td>No</td><td>Wraps <em>all</em> model fields in a type so that the list can be filtered by any property.</td></tr><tr><td><code class="inline-code">orderBy</code></td><td><code class="inline-code">XOR<Enumerable<UserOrderByInput>,</code><br/><code class="inline-code">UserOrderByInput></code></td><td>No</td><td>Lets you order the returned list by any property that is also present in <code class="inline-code">by</code>.</td></tr><tr><td><code class="inline-code">by</code></td><td><code class="inline-code">Array<UserScalarFieldEnum></code> <!-- -->|<!-- --> <code class="inline-code">string</code></td><td>No</td><td>Specifies the field or combination of fields to group records by.</td></tr><tr><td><code class="inline-code">having</code></td><td><code class="inline-code">UserScalarWhereWithAggregatesInput</code></td><td>No</td><td>Allows you to filter groups by an aggregate value - for example, only return groups <em>having</em> an average age less than 50.</td></tr><tr><td><code class="inline-code">take</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many objects should be returned in the list (as seen from the <em>beginning</em> (positive value) or <em>end</em> (negative value) <strong>either</strong> of the list <strong>or</strong> from the <code class="inline-code">cursor</code> position if mentioned)</td></tr><tr><td><code class="inline-code">skip</code></td><td><code class="inline-code">number</code></td><td>No</td><td>Specifies how many of the returned objects in the list should be skipped.</td></tr><tr><td><code class="inline-code">_count</code></td><td><code class="inline-code">true</code> <!-- -->|<!-- --> <code class="inline-code">UserCountAggregateInputType</code></td><td>No</td><td>Returns a count of matching records or non-<code class="inline-code">null</code> fields.</td></tr><tr><td><code class="inline-code">_avg</code></td><td><code class="inline-code">UserAvgAggregateInputType</code></td><td>No</td><td>Returns an average of all values of the specified field.</td></tr><tr><td><code class="inline-code">_sum</code></td><td><code class="inline-code">UserSumAggregateInputType</code></td><td>No</td><td>Returns the sum of all values of the specified field.</td></tr><tr><td><code class="inline-code">_min</code></td><td><code class="inline-code">UserMinAggregateInputType</code></td><td>No</td><td>Returns the smallest available value of the specified field.</td></tr><tr><td><code class="inline-code">_max</code></td><td><code class="inline-code">UserMaxAggregateInputType</code></td><td>No</td><td>Returns the largest available value of the specified field.</td></tr></tbody></table></div></section><section><h4 id="examples-17" style="position:relative"><a href="#examples-17" aria-label="examples 17 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Group by <code class="inline-code">country</code>/<code class="inline-code">city</code> where the average <code class="inline-code">profileViews</code> is greater than <code class="inline-code">200</code>, and return the <code class="inline-code">_sum</code> of <code class="inline-code">profileViews</code> for each group</h5><p class="paragraph">The query also returns a count of <code class="inline-code">_all</code> records in each group, and all records with non-<code class="inline-code">null</code> <code class="inline-code">city</code> field values in each group.</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> groupUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">groupBy</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> by</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'country'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'city'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _count</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _all</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _sum</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> having</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _avg</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> gt</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">200</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Hide CLI results</div><div class="result-code"><cmdresult><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">;</span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Denmark'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Copenhagen'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _sum</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">490</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _count</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _all</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">70</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">8</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Sweden'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Stockholm'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _sum</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> profileViews</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">500</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _count</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _all</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">50</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">3</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmdresult></div></div></div></section></section></section></section><section><h2 id="model-query-options" style="position:relative"><a href="#model-query-options" aria-label="model query options permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Generated types for <code class="inline-code">select</code></h4><p class="paragraph">The following examples demonstrate how to use the <a href="/docs/orm/prisma-client/type-safety/prisma-validator"><code class="inline-code">validator</code></a> with <code class="inline-code">select</code>:</p><ul class="list"><li><code class="inline-code">SelectAndInclude</code></li><li><code class="inline-code">UserSelect</code></li></ul><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token comment" style="color:#999988;font-style:italic">// SelectAndInclude</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> selectNameIncludeEmail </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">SelectAndInclude</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token comment" style="color:#999988;font-style:italic">// UserSelect</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> selectNameEmailNotPosts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserSelect</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h3 id="include" style="position:relative"><a href="#include" aria-label="inlinecodeincludeinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Include the <code class="inline-code">posts</code> relation on the returned objects when creating a new <code class="inline-code">User</code> record with two <code class="inline-code">Post</code> records</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my first post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Here comes a second post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Returns all fields for all posts</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h4 id="generated-types-for-include" style="position:relative"><a href="#generated-types-for-include" aria-label="generated types for include permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Generated types for <code class="inline-code">include</code></h4><p class="paragraph">The following examples demonstrate how to use the <a href="/docs/orm/prisma-client/type-safety/prisma-validator"><code class="inline-code">validator</code></a> with <code class="inline-code">include</code>:</p><ul class="list"><li><code class="inline-code">SelectAndInclude</code></li><li><code class="inline-code">UserInclude</code></li></ul><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token comment" style="color:#999988;font-style:italic">// SelectAndInclude</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> selectNameIncludeEmail </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">SelectAndInclude</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token comment" style="color:#999988;font-style:italic">// UserInclude</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> includePosts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserInclude</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h5 id="include-a-_count-of-relations" style="position:relative"><a href="#include-a-_count-of-relations" aria-label="include a _count of relations permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>relationLoadStrategy</inlinecode> (Preview)</h3><p class="paragraph"><code class="inline-code">relationLoadStrategy</code> specifies how a relation should be loaded from the database. It has two possible values:</p><ul class="list"><li><code class="inline-code">join</code> (default): Uses a database-level <code class="inline-code">LATERAL JOIN</code> and fetches all data with a single query to the database.</li><li><code class="inline-code">query</code>: Sends multiple queries to the database (one per table) and joins them on the application level.</li></ul><blockquote><p class="paragraph"><strong>Note</strong>: Once <code class="inline-code">relationLoadStrategy</code> moves from <a href="/docs/orm/more/releases#preview">Preview</a> into <a href="/docs/orm/more/releases/#generally-available-ga">General Availability</a>, <code class="inline-code">join</code> will universally become the default for all relation queries.</p></blockquote><p class="paragraph">You can learn more about join strategies <a href="/docs/orm/prisma-client/queries/relation-queries#relation-load-strategies-preview">here</a>.</p><p class="paragraph">Because the <code class="inline-code">relationLoadStrategy</code> option is currently in Preview, you need to enable it via the <code class="inline-code">relationJoins</code> preview feature flag in your Prisma schema file:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">generator</span><span class="token plain"> client </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> provider </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"prisma-client-js"</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> previewFeatures </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"relationJoins"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">After adding this flag, you need to run <code class="inline-code">prisma generate</code> again to re-generate Prisma Client. Also note that this feature is currently only available on PostgreSQL and CockroachDB, support for other DBs is coming soon.</p><section><h4 id="remarks-14" style="position:relative"><a href="#remarks-14" aria-label="remarks 14 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li>In most situations, the default <code class="inline-code">join</code> strategy will be more effective. Use <code class="inline-code">query</code> if you want to save resources on your database server or if you profiling shows that the application-level join is more performant.</li><li>You can only specify the <code class="inline-code">relationLoadStrategy</code> on the top-level in your query. The top-level choice will affect all nested sub-queries.</li></ul></section><section><h4 id="examples-20" style="position:relative"><a href="#examples-20" aria-label="examples 20 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Generated types for <code class="inline-code">where</code></h4><p class="paragraph">The following examples demonstrate how to use the <a href="/docs/orm/prisma-client/type-safety/prisma-validator"><code class="inline-code">validator</code></a> with <code class="inline-code">where</code>:</p><ul class="list"><li><p class="paragraph"><code class="inline-code">UserWhereInput</code></p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token comment" style="color:#999988;font-style:italic">// UserWhereInput</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> whereNameIs </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserWhereInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Rich'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token comment" style="color:#999988;font-style:italic">// It can be combined with conditional operators too</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> whereNameIs </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserWhereInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Rich'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">AND</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'rich@boop.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li><li><p class="paragraph"><code class="inline-code">UserWhereUniqueInput</code> This type works by exposing any unique fields on the model. A field assigned <code class="inline-code">@id</code> is considered unique, as is one assigned <code class="inline-code">@unique</code>.</p><p class="paragraph">From version 4.5.0, this type exposes all fields on the model. This means that when you filter for a single record based on a unique field, you can check additional non-unique and unique fields at the same time. <a href="#filter-on-non-unique-fields-with-userwhereuniqueinput">Learn more</a>.</p></li></ul><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token comment" style="color:#999988;font-style:italic">// UserWhereUniqueInput</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> whereEmailIsUnique </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserWhereUniqueInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'rich@boop.com'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><ul class="list"><li><p class="paragraph"><code class="inline-code">PostScalarWhereInput</code></p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> whereScalarTitleIs </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">PostScalarWhereInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'boop'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li><li><p class="paragraph"><code class="inline-code">PostUpdateWithWhereUniqueWithoutAuthorInput</code> - This type accepts a unique <code class="inline-code">where</code> field (an <code class="inline-code">@id</code> or another assigned <code class="inline-code">@unique</code>) and updates any field on the <code class="inline-code">Post</code> model except the <code class="inline-code">Author</code>. The <code class="inline-code">Author</code> is the scalar field on the <code class="inline-code">Post</code> model.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> updatePostByIdWithoutAuthor </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">PostUpdateWithWhereUniqueWithoutAuthorInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> content</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is some updated content'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is a new title'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li><li><p class="paragraph"><code class="inline-code">PostUpsertWithWhereUniqueWithoutAuthorInput</code> - This type will update the <code class="inline-code">Post</code> records title field where the id matches, if it doesn't exist it will create it instead.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> updatePostTitleOrCreateIfNotExist </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">PostUpsertWithWhereUniqueWithoutAuthorInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is a new title'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'If the title doesnt exist, then create one with this text'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li><li><p class="paragraph"><code class="inline-code">PostUpdateManyWithWhereWithoutAuthorInput</code> - This type will update all <code class="inline-code">Post</code> records where published is set to false.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> publishAllPosts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">PostUpdateManyWithWhereWithoutAuthorInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></li></ul></section></section><section><h3 id="orderby" style="position:relative"><a href="#orderby" aria-label="inlinecodeorderbyinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><p class="paragraph">In <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">2.16.0<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button> and later, you can <a href="#sort-post-by-the-related-user-records-name">order by relation fields</a> - for example, order posts by the author's name.</p></li><li><p class="paragraph">In <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">3.5.0<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button> and later, in PostgreSQL you can <a href="#sort-post-by-relevance-of-the-title">order by relevance</a>. For details, see <a href="/docs/orm/prisma-client/queries/filtering-and-sorting#sort-by-relevance-postgresql">Sort by relevance</a>.</p></li><li><p class="paragraph">In <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">4.1.0<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button> and later, you can <a href="#sort-post-by-the-related-user-records-name-with-null-records-first">sort <code class="inline-code">null</code> records first or last</a>. For details, see <a href="/docs/orm/prisma-client/queries/filtering-and-sorting#sort-with-null-records-first-or-last">Sort with nulls first or last</a>.</p></li></ul></section><section><h4 id="inputs-for-sort-argument" style="position:relative"><a href="#inputs-for-sort-argument" aria-label="inputs for inlinecodesortinlinecode argument permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Inputs for <inlinecode>nulls</inlinecode> argument</h4><p class="paragraph">Note:</p><ul class="list"><li>This argument is optional.</li><li>It is for use on optional <a href="/docs/orm/prisma-schema/data-model/models#scalar-fields">scalar</a> fields only. If you try to sort by nulls on a required or <a href="/docs/orm/prisma-schema/data-model/models#relation-fields">relation</a> field, Prisma Client throws a <a href="/docs/orm/reference/error-reference#p2009">P2009 error</a>.</li><li>It is available in version 4.1.0 and later, as a preview feature. See <a href="/docs/orm/prisma-client/queries/filtering-and-sorting#sort-with-null-records-first-or-last">sort with nulls first or last</a> for details of how to enable the feature.</li></ul><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-code">first</code></td><td>Sort with <code class="inline-code">null</code> values first.</td></tr><tr><td><code class="inline-code">last</code></td><td>Sort with <code class="inline-code">null</code> values last.</td></tr></tbody></table></div></section><section><h4 id="examples-22" style="position:relative"><a href="#examples-22" aria-label="examples 22 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Sort <code class="inline-code">User</code> by <code class="inline-code">email</code> field</h5><p class="paragraph">The following example returns all <code class="inline-code">User</code> records sorted by <code class="inline-code">email</code> ascending:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> users </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'asc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following example returns all <code class="inline-code">User</code> records sorted by <code class="inline-code">email</code> descending:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> users </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h4 id="sort-post-by-the-related-user-records-name" style="position:relative"><a href="#sort-post-by-the-related-user-records-name" aria-label="sort post by the related user records name permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Sort <code class="inline-code">Post</code> by relevance of the title</h4><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-3 kzCMZj"><p class="paragraph">This feature is available from version 3.5.0 onwards in PostgreSQL and MySQL only. You'll need to use the <code class="inline-code">fullTextSearch</code> preview flag to enable this feature.</p></span><p class="paragraph">The following query orders posts by relevance of the search term <code class="inline-code">'database'</code> to the title:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> posts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> _relevance</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> fields</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'title'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> search</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'database'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> sort</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'asc'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="sort-user-by-the-posts-count" style="position:relative"><a href="#sort-user-by-the-posts-count" aria-label="sort user by the posts count permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Sort <code class="inline-code">User</code> by multiple fields - <code class="inline-code">email</code> <em>and</em> <code class="inline-code">role</code></h5><p class="paragraph">The following example sorts users by two fields - first <code class="inline-code">email</code>, then <code class="inline-code">role</code>:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> users </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div><p class="paragraph">The order of sorting parameters matters - the following query sorts by <code class="inline-code">role</code>, then <code class="inline-code">email</code>. Not the difference in the results:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> users </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> role</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section><section><h5 id="sort-user-by-email-select-name-and-email" style="position:relative"><a href="#sort-user-by-email-select-name-and-email" aria-label="sort user by email select name and email permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Sort <code class="inline-code">User</code> records by <code class="inline-code">email</code> and sort nested <code class="inline-code">Post</code> records by <code class="inline-code">title</code></h5><p class="paragraph">The following example:</p><ul class="list"><li>Returns all <code class="inline-code">User</code> records sorted by <code class="inline-code">email</code></li><li>For each <code class="inline-code">User</code> record, returns the <code class="inline-code">title</code> field of all nested <code class="inline-code">Post</code> records sorted by <code class="inline-code">title</code></li></ul><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> usersWithPosts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'asc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'asc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section><section><h5 id="sort-one-users-nested-list-of-post-records" style="position:relative"><a href="#sort-one-users-nested-list-of-post-records" aria-label="sort one users nested list of post records permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Sort one user's nested list of <code class="inline-code">Post</code> records</h5><p class="paragraph">The following example retrieves a single <code class="inline-code">User</code> record by ID, as well as a list of nested <code class="inline-code">Post</code> records sorted by <code class="inline-code">title</code>:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> userWithPosts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> orderBy</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'desc'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section><section><h5 id="sort-by-enum" style="position:relative"><a href="#sort-by-enum" aria-label="sort by enum permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Select distinct on a single field</h5><p class="paragraph">The following example returns all distinct <code class="inline-code">city</code> fields, and selects only the <code class="inline-code">city</code> and <code class="inline-code">country</code> fields:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> distinctCities </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> distinct</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'city'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Hide CLI results</div><div class="result-code"><cmdresult><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">;</span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Paris'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'France'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Lyon'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'France'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmdresult></div></div></div></section><section><h5 id="select-distinct-on-multiple-fields" style="position:relative"><a href="#select-distinct-on-multiple-fields" aria-label="select distinct on multiple fields permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Select distinct on multiple fields</h5><p class="paragraph">The following example returns all distinct <code class="inline-code">city</code> <em>and</em> <code class="inline-code">country</code> field combinations, and selects only the <code class="inline-code">city</code> and <code class="inline-code">country</code> fields:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> distinctCitiesAndCountries </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> distinct</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'city'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'country'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Hide CLI results</div><div class="result-code"><cmdresult><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">;</span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Paris'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'France'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Paris'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Denmark'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Lyon'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'France'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmdresult></div></div></div><p class="paragraph">Note that there is now a "Paris, Denmark" in addition to "Paris, France":</p></section><section><h5 id="select-distinct-in-combination-with-a-filter" style="position:relative"><a href="#select-distinct-in-combination-with-a-filter" aria-label="select distinct in combination with a filter permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Select distinct in combination with a filter</h5><p class="paragraph">The following example returns all distinct <code class="inline-code">city</code> <em>and</em> <code class="inline-code">country</code> field combinations where the user's email contains <code class="inline-code">"prisma.io"</code>, and selects only the <code class="inline-code">city</code> and <code class="inline-code">country</code> fields:</p><div class="codeWithResult__Wrapper-sc-1hf1bfh-0 lhhNb"><div class="cmd"><cmd><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> distinctCitiesAndCountries </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> select</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> country</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> distinct</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'city'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'country'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></cmd></div><div class="result"><div class="show-btn">Show CLI results</div></div></div></section></section></section></section><section><h2 id="nested-queries" style="position:relative"><a href="#nested-queries" aria-label="nested queries permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create a new <code class="inline-code">User</code> record with two new <code class="inline-code">Post</code> records</h5><p class="paragraph">Because it's a one-to-many relation, you can also create several <code class="inline-code">Post</code> records at once by passing an array to <code class="inline-code">create</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my first post'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Here comes a second post'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line highlighted-line" style="background-color:var(--code-highlight-bg-color);symb-color:var(--code-highlight-color);class-name:highlighted-line"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">You can also use a nested <a href="#createmany-1"><code class="inline-code">createMany</code></a> to achieve the same result.</p></section><section><h5 id="update-an-existing-user-record-by-creating-a-new-profile-record" style="position:relative"><a href="#update-an-existing-user-record-by-creating-a-new-profile-record" aria-label="update an existing user record by creating a new profile record permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><code class="inline-code">createMany</code> is available as a nested query when you <code class="inline-code">create</code> (<code class="inline-code">prisma.user.create(...)</code>) a new parent record or <code class="inline-code">update</code> (<code class="inline-code">prisma.user.update(...)</code>) an existing parent record.</li><li>Available in the context of a has-many relation - for example, you can <code class="inline-code">prisma.user.create(...)</code> a user and use a nested <code class="inline-code">createMany</code> to create multiple posts (posts have one user).</li><li><strong>Not</strong> available in the context of a many-to-many relation - for example, you <strong>cannot</strong> <code class="inline-code">prisma.post.create(...)</code> a post and use a nested <code class="inline-code">createMany</code> to create categories (many posts have many categories).</li><li>Does not support nesting additional relations - you cannot nest an additional <code class="inline-code">create</code> or <code class="inline-code">createMany</code>.</li><li>Allows setting foreign keys directly - for example, setting the <code class="inline-code">categoryId</code> on a post.</li></ul><blockquote><p class="paragraph">You can use a nested <code class="inline-code">create</code> <em>or</em> a nested <code class="inline-code">createMany</code> to create multiple related records - <a href="/docs/orm/prisma-client/queries/relation-queries#create-a-single-record-and-multiple-related-records">each technique pros and cons</a> .</p></blockquote></section><section><h4 id="examples-25" style="position:relative"><a href="#examples-25" aria-label="examples 25 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create a new <code class="inline-code">Profile</code> record and connect it to an existing <code class="inline-code">User</code> record via an ID field</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">profile</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hello World'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> user</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connect</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">42</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// sets userId of Profile record</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">In <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">2.11.0<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button> and later, you can set the foreign key directly:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">profile</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hello World'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> userId</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">42</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="create-a-new-post-record-and-connect-it-to-an-existing-user-record" style="position:relative"><a href="#create-a-new-post-record-and-connect-it-to-an-existing-user-record" aria-label="create a new post record and connect it to an existing user record permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><p class="paragraph">Multiple <code class="inline-code">connectOrCreate</code> queries that run <em>as concurrent transactions</em> can result in a <strong>race condition</strong>. Consider the following example, where two queries attempt to <code class="inline-code">connectOrCreate</code> a blog post tag named <code class="inline-code">computing</code> at the same time (tag names must be unique):</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="14" height="14" viewbox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.8 1H2.2C1.53726 1 1 1.76751 1 2.71429V11.2857C1 12.2325 1.53726 13 2.2 13H11.8C12.4627 13 13 12.2325 13 11.2857V2.71429C13 1.76751 12.4627 1 11.8 1Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.6958 3.9668L6.21143 6.48242L3.6958 8.99805M6.47078 9.73637H10.4836" stroke="#A0AEC0" stroke-width="2" stroke-linejoin="round"/><path d="M3.57129 13H10.4284" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>Query A</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="14" height="14" viewbox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.8 1H2.2C1.53726 1 1 1.76751 1 2.71429V11.2857C1 12.2325 1.53726 13 2.2 13H11.8C12.4627 13 13 12.2325 13 11.2857V2.71429C13 1.76751 12.4627 1 11.8 1Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M3.6958 3.9668L6.21143 6.48242L3.6958 8.99805M6.47078 9.73637H10.4836" stroke="#A0AEC0" stroke-width="2" stroke-linejoin="round"/><path d="M3.57129 13H10.4284" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>Query B</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> createPost </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'How to create a compiler'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> content</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'...'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> author</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connect</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">9</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> tags</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connectOrCreate</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'computing'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'computing'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div><p class="paragraph">If query A and query B overlap in the following way, query A results in an exception:</p><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th align="left">Query A (Fail ❌)</th><th align="left">Query B (Success ✅)</th></tr></thead><tbody><tr><td align="left">Query hits server, starts transaction A</td><td align="left">Query hits server, starts transaction B</td></tr><tr><td align="left"/><td align="left">Find record where <code class="inline-code">tagName</code> equals <code class="inline-code">computing</code>, record not found</td></tr><tr><td align="left">Find record where <code class="inline-code">tagName</code> equals <code class="inline-code">computing</code>, record not found</td><td align="left"/></tr><tr><td align="left"/><td align="left">Create record where <code class="inline-code">tagName</code> equals <code class="inline-code">computing</code> and connect</td></tr><tr><td align="left">Create record where <code class="inline-code">tagName</code> equals <code class="inline-code">computing</code></td><td align="left"/></tr><tr><td align="left">Unique violation, record already created by transaction B</td><td align="left"/></tr></tbody></table></div><p class="paragraph">To work around this scenario, we recommend catching the unique violation exception (<code class="inline-code">PrismaClientKnownRequestError</code>, error <code class="inline-code">P2002</code>) and retrying failed queries.</p></li></ul></section><section><h4 id="examples-28" style="position:relative"><a href="#examples-28" aria-label="examples 28 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create a new <code class="inline-code">Profile</code> record, then connect it to an existing <code class="inline-code">User</code> record <em>or</em> create a new <code class="inline-code">User</code></h5><p class="paragraph">The following example:</p><ol class="o-list"><li>Creates a <code class="inline-code">Profile</code></li><li>Attempts to connect the profile to a <code class="inline-code">User</code> where the email address is <code class="inline-code">alice@prisma.io</code></li><li>Creates a new user if a matching user does not exist</li></ol><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">profile</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'The coolest Alice on the planet'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> user</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connectOrCreate</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="create-a-new-post-record-and-connect-it-to-an-existing-user-record-or-create-a-new-user" style="position:relative"><a href="#create-a-new-post-record-and-connect-it-to-an-existing-user-record-or-create-a-new-user" aria-label="create a new post record and connect it to an existing user record or create a new user permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create a new <code class="inline-code">Post</code> record and connect it to an existing <code class="inline-code">User</code> record, <em>or</em> create a new <code class="inline-code">User</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hello World'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> author</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connectOrCreate</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="update-an-existing-user-record-by-connecting-it-to-an-existing-profile-record-or-creating-a-new-profile-record" style="position:relative"><a href="#update-an-existing-user-record-by-connecting-it-to-an-existing-profile-record-or-creating-a-new-profile-record" aria-label="update an existing user record by connecting it to an existing profile record or creating a new profile record permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update an existing <code class="inline-code">User</code> record by connecting it to an existing <code class="inline-code">Profile</code> record, <em>or</em> creating a new <code class="inline-code">Profile</code> record</h5><p class="paragraph">The following example:</p><ol class="o-list"><li>Attempts to connect the user to a <code class="inline-code">Profile</code> with an <code class="inline-code">id</code> of <code class="inline-code">20</code></li><li>Creates a new profile if a matching profile does not exist</li></ol><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> updateUser </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profile</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connectOrCreate</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">20</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'The coolest Alice in town'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="update-an-existing-user-record-by-connect-it-to-two-existing-post-records-or-creating-two-new-post-records" style="position:relative"><a href="#update-an-existing-user-record-by-connect-it-to-two-existing-post-records-or-creating-two-new-post-records" aria-label="update an existing user record by connect it to two existing post records or creating two new post records permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update an existing <code class="inline-code">User</code> record by connect it to two existing <code class="inline-code">Post</code> records, or creating two new <code class="inline-code">Post</code> records</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> connectOrCreate</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">32</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my first post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">19</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my second post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="disconnect" style="position:relative"><a href="#disconnect" aria-label="inlinecodedisconnectinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><p class="paragraph"><code class="inline-code">disconnect</code> is only available if the relation is optional.</p></li><li><p class="paragraph">If the relationship you are attempting to disconnect does not exist:</p><ul class="list"><li><p class="paragraph">(<button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">In 2.21.0 and later<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button>), the operation does nothing</p></li><li><p class="paragraph">(Before <button style="display:inline-block" class="customLink__CustomButton-sc-1xpvtl4-0 geWZl">2.21.0<svg xmlns="http://www.w3.org/2000/svg" width="12" style="margin-left:4px" height="12" viewbox="0 0 12 12" fill="currentColor" color="inherit"><path fill="inherit" d="M6 1h5v5L8.86 3.85 4.7 8 4 7.3l4.15-4.16L6 1Z M2 3h2v1H2v6h6V8h1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/></svg></button>) Prisma Client throws an exception if the provided ID or unique identifier is not connected:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-undefined " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">The records for relation `PostToUser` between the `User` and `Post` models are not connected.</span></span></div></code></pre></div></div></pre></li></ul></li></ul></section><section><h4 id="examples-29" style="position:relative"><a href="#examples-29" aria-label="examples 29 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><ul class="list"><li><p class="paragraph">Nested <code class="inline-code">update</code> queries are only available in the context of a top-level <code class="inline-code">update</code> query (for example, <code class="inline-code">prisma.user.update(...)</code>).</p></li><li><p class="paragraph">If the parent record does not exist, Prisma Client throws an exception:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-undefined " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">AssertionError("Expected a valid parent ID to be present for nested update to-one case.")</span></span></div></code></pre></div></div></pre></li><li><p class="paragraph">If the related record that you want to update does not exist, Prisma Client throws an exception:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-undefined " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">AssertionError("Expected a valid parent ID to be present for nested update to-one case.")</span></span></div></code></pre></div></div></pre></li></ul></section><section><h4 id="examples-30" style="position:relative"><a href="#examples-30" aria-label="examples 30 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update an existing <code class="inline-code">User</code> record by updating two <code class="inline-code">Post</code> records it's connected to</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">32</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">23</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="upsert-1" style="position:relative"><a href="#upsert-1" aria-label="inlinecodeupsertinlinecode 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update an existing <code class="inline-code">User</code> record by updating the <code class="inline-code">Profile</code> record it's connected to or creating a new one (<em>upsert</em>)</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> profile</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> upsert</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hello World'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> bio</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Hello World'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="update-an-existing-user-record-by-updating-two-post-record-its-connected-to-or-creating-new-ones-upsert" style="position:relative"><a href="#update-an-existing-user-record-by-updating-two-post-record-its-connected-to-or-creating-new-ones-upsert" aria-label="update an existing user record by updating two post record its connected to or creating new ones upsert permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Update an existing <code class="inline-code">User</code> record by updating two <code class="inline-code">Post</code> record it's connected to or creating new ones (<em>upsert</em>)</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'alice@prisma.io'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> upsert</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my first post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my first post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">32</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my second post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'This is my second post'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">23</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="delete-1" style="position:relative"><a href="#delete-1" aria-label="inlinecodedeleteinlinecode 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get a <code class="inline-code">User</code> record where at least one <code class="inline-code">Post</code> has at least one specified <code class="inline-code">Category</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUser </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Find users where..</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> some</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ..at least one (some) posts..</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> categories</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> some</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// .. have at least one category ..</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'Food'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Introductions'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// .. with a name that matches one of the following.</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="notin" style="position:relative"><a href="#notin" aria-label="inlinecodenotininlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>search</inlinecode></h3><p class="paragraph">Use <a href="/docs/orm/prisma-client/queries/full-text-search">Full-Text Search</a> to search within a <code class="inline-code">String</code> field.</p><p class="paragraph">Full-Text Search is currently in <strong>Preview</strong> and only available for <strong>PostgreSQL</strong> and <strong>MySQL</strong>. To use <code class="inline-code">search</code>, you'll need to enable the <code class="inline-code">fullTextSearch</code> preview feature.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">generator</span><span class="token plain"> client </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> provider </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"prisma-client-js"</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> previewFeatures </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"fullTextSearch"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h4 id="examples-45" style="position:relative"><a href="#examples-45" aria-label="examples 45 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">content</code> field contains <code class="inline-code">Prisma</code> and <code class="inline-code">published</code> is <code class="inline-code">false</code> (no <code class="inline-code">AND</code>)</h5><p class="paragraph">The following format returns the same results as the previous example <strong>without</strong> the <code class="inline-code">AND</code> operator:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> content</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="get-all-post-records-where-the-title-field-contains-prisma-or-databases-and-published-is-false" style="position:relative"><a href="#get-all-post-records-where-the-title-field-contains-prisma-or-databases-and-published-is-false" aria-label="get all post records where the title field contains prisma or databases and published is false permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">title</code> field contains <code class="inline-code">Prisma</code> or <code class="inline-code">databases</code>, and <code class="inline-code">published</code> is <code class="inline-code">false</code></h5><p class="paragraph">The following example combines <code class="inline-code">OR</code> and <code class="inline-code">AND</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">AND</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="or" style="position:relative"><a href="#or" aria-label="inlinecodeorinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">title</code> filed contains <code class="inline-code">Prisma</code> or <code class="inline-code">databases</code>, but not <code class="inline-code">SQL</code></h5><p class="paragraph">The following example combines <code class="inline-code">OR</code> and <code class="inline-code">NOT</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">NOT</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'SQL'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="get-all-post-records-where-the-title-field-contains-prisma-or-databases-and-published-is-false-1" style="position:relative"><a href="#get-all-post-records-where-the-title-field-contains-prisma-or-databases-and-published-is-false-1" aria-label="get all post records where the title field contains prisma or databases and published is false 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">title</code> field contains <code class="inline-code">Prisma</code> or <code class="inline-code">databases</code>, and <code class="inline-code">published</code> is <code class="inline-code">false</code></h5><p class="paragraph">The following example combines <code class="inline-code">OR</code> and <code class="inline-code">AND</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">AND</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> published</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="not-1" style="position:relative"><a href="#not-1" aria-label="inlinecodenotinlinecode 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">title</code> filed contains <code class="inline-code">Prisma</code> or <code class="inline-code">databases</code>, but not <code class="inline-code">SQL</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">NOT</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'SQL'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="get-all-post-records-where-the-title-field-contains-prisma-or-databases-but-not-sql-and-the-related-user-record-email-address-does-not-contain-sarah" style="position:relative"><a href="#get-all-post-records-where-the-title-field-contains-prisma-or-databases-but-not-sql-and-the-related-user-record-email-address-does-not-contain-sarah" aria-label="get all post records where the title field contains prisma or databases but not sql and the related user record email address does not contain sarah permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Get all <code class="inline-code">Post</code> records where the <code class="inline-code">title</code> field contains <code class="inline-code">Prisma</code> or <code class="inline-code">databases</code>, but not <code class="inline-code">SQL</code>, and the related <code class="inline-code">User</code> record' email address does not contain <code class="inline-code">sarah</code></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> result </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Prisma'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">NOT</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'SQL'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> user</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">NOT</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'sarah'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> include</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> user</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section></section><section><h2 id="relation-filters" style="position:relative"><a href="#relation-filters" aria-label="relation filters permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Add a <code class="inline-code">computing</code> item to the <code class="inline-code">tags</code> list</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> addTag </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">9</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> tags</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> push</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'computing'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> addTag </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">9</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> tags</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> push</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'computing'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'genetics'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="unset" style="position:relative"><a href="#unset" aria-label="inlinecodeunsetinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Examples</h4><p class="paragraph">The following query returns all <code class="inline-code">Post</code> records where the <code class="inline-code">tags</code> list includes <code class="inline-code">"databases"</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> posts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> client</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> tags</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> has</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following query returns all <code class="inline-code">Post</code> records where the <code class="inline-code">tags</code> list <strong>does not</strong> include <code class="inline-code">"databases"</code>:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> posts </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> client</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token constant" style="color:#36acaa">NOT</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> tags</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> has</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'databases'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section><section><h3 id="hasevery" style="position:relative"><a href="#hasevery" aria-label="inlinecodehaseveryinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Set the <inlinecode>shippingAddress</inlinecode> composite type within a new <inlinecode>order</inlinecode></h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> order </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">order</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">create</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Normal relation</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> product</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> connect</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'some-object-id'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> color</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Red'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> size</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Large'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Composite type</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token class-name">shippingAddress</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">set</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> street</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'1084 Candycane Lane'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Silverlake'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> zip</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'84323'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="set-an-optional-composite-type-to-inlinecodenullinlinecode" style="position:relative"><a href="#set-an-optional-composite-type-to-null" aria-label="set an optional composite type to inlinecodenullinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Create a new <inlinecode>billingAddress</inlinecode> if it doesn't exist, and otherwise update it</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> order </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">order</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'some-object-id'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> billingAddress</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Create the address if it doesn't exist,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// otherwise update it</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> upsert</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">set</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> street</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'1084 Candycane Lane'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Silverlake'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> zip</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'84323'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> zip</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'84323'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h3 id="push-1" style="position:relative"><a href="#push-1" aria-label="inlinecodepushinlinecode 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h4><p class="paragraph">When matching optional fields, you need to distinguish between undefined (missing) fields of the document, and fields that have been explicitly set to <code class="inline-code">null</code>:</p><ul class="list"><li>If you omit an optional field, it will match undefined fields, but not fields that have been set to <code class="inline-code">null</code></li><li>If you filter for <code class="inline-code">null</code> values of an optional field with <code class="inline-code">equals: { ... exampleField: null ... }</code>, then it will match only documents where the field has been set to <code class="inline-code">null</code>, and not undefined fields</li></ul><p class="paragraph">The ordering of fields and lists matters when using <code class="inline-code">equals</code>:</p><ul class="list"><li>For fields, <code class="inline-code">{ "a": "1", "b": "2" }</code> and <code class="inline-code">{ "b": "2", "a": "1" }</code> are not considered equal</li><li>For lists, <code class="inline-code">[ { "a": 1 }, { "a": 2 } ]</code> and <code class="inline-code">[ { "a": 2 }, { "a": 1 } ]</code> are not considered equal</li></ul></section><section><h4 id="examples-70" style="position:relative"><a href="#examples-70" aria-label="examples 70 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Atomic number operations</h2><p class="paragraph">Atomic operations on update is available for number field types (<code class="inline-code">Float</code> and <code class="inline-code">Int</code>). This feature allows you to update a field based on its <strong>current</strong> value (such as <em>subtracting</em> or <em>dividing</em>) without risking a race condition.</p><div class="collapsible__Wrapper-sc-atw4gb-0 jOWteu"><div class="collapsible__Tab-sc-atw4gb-1 kOYPPx"><input type="checkbox" id="tab-162" name="tab" class="collapsible__Input-sc-atw4gb-4 jvueWa"/><svg width="5" height="8" viewbox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg" class="collapsible__StyledArrow-sc-atw4gb-5 XNUMj"><path d="M0 0.724246C0 0.111374 0.681914 -0.223425 1.13107 0.168926L4.66916 3.25957C5.11028 3.6449 5.11028 4.3551 4.66916 4.74043L1.13107 7.83107C0.681913 8.22342 0 7.88863 0 7.27575V0.724246Z" fill="#A0AEC0"/></svg><label for="tab-162" class="collapsible__Label-sc-atw4gb-2 kVOMbE">Overview: Race conditions</label><div class="collapsible__TabContent-sc-atw4gb-3 hdGwPH tab-content"><p class="paragraph">A race conditions occurs when two or more operations must be done in sequence in order to complete a task. In the following example, two clients try to increase the same field (<code class="inline-code">postCount</code>) by one:</p><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th align="left">Client</th><th align="left">Operation</th><th align="left">Value</th></tr></thead><tbody><tr><td align="left">Client 1</td><td align="left"><strong>Get</strong> field value</td><td align="left"><code class="inline-code">21</code></td></tr><tr><td align="left">Client 2</td><td align="left"><strong>Get</strong> field value</td><td align="left"><code class="inline-code">21</code></td></tr><tr><td align="left">Client 2</td><td align="left"><strong>Set</strong> field value</td><td align="left"><code class="inline-code">22</code></td></tr><tr><td align="left">Client 1</td><td align="left"><strong>Set</strong> field value</td><td align="left"><code class="inline-code">22</code> ✘</td></tr></tbody></table></div><p class="paragraph">The value <em>should</em> be <code class="inline-code">23</code>, but the two clients did not read and write to the <code class="inline-code">postCount</code> field in sequence. Atomic operations on update combine read and write into a single operation, which prevents a race condition:</p><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th align="left">Client</th><th align="left">Operation</th><th align="left">Value</th></tr></thead><tbody><tr><td align="left">Client 1</td><td align="left"><strong>Get and set</strong> field value</td><td align="left"><code class="inline-code">21</code> <!-- -->→<!-- --> <code class="inline-code">22</code></td></tr><tr><td align="left">Client 2</td><td align="left"><strong>Get and set</strong> field value</td><td align="left"><code class="inline-code">22</code> <!-- -->→<!-- --> <code class="inline-code">23</code> ✔</td></tr></tbody></table></div></div></div></div><section><h3 id="operators" style="position:relative"><a href="#operators" aria-label="operators permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>Json</inlinecode> filters</h2><p class="paragraph">For use cases and advanced examples, see: <a href="/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields">Working with <code class="inline-code">Json</code> fields</a>.</p><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-3 kzCMZj"><p class="paragraph">Supported by <a href="/docs/orm/overview/databases/postgresql">PostgreSQL</a> and <a href="/docs/orm/overview/databases/mysql">MySQL</a> with different syntaxes for the <code class="inline-code">path</code> option. PostgreSQL does not support filtering on object key values in arrays.</p></span><p class="paragraph">The examples in this section assumes that the value of the <code class="inline-code">pet</code> field is:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-json " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"favorites"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"catBreed"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Turkish van"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"dogBreed"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Rottweiler"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"sanctuaries"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"RSPCA"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Alley Cat Allies"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"treats"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Dreamies"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"manufacturer"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Mars Inc"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"name"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Treatos"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token property" style="color:#36acaa">"manufacturer"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"The Dog People"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"fostered"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"cats"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"Bob"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Alice"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Svetlana the Magnificent"</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"Queenie"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"owned"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token property" style="color:#36acaa">"cats"</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">"Elliott"</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h3 id="remarks-36" style="position:relative"><a href="#remarks-36" aria-label="remarks 36 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>path</inlinecode></h3><p class="paragraph"><code class="inline-code">path</code> represents the location of a specific key. The following query returns all users where the nested <code class="inline-code">favourites</code> > <code class="inline-code">dogBreed</code> key equals <code class="inline-code">"Rottweiler"</code>.</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>PostgreSQL</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'favorites'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'dogBreed'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Rottweiler'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div><p class="paragraph">The following query returns all users where the nested <code class="inline-code">owned</code> > <code class="inline-code">cats</code> array contains <code class="inline-code">"Elliott"</code>.</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>PostgreSQL</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'owned'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'cats'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> array_contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'Elliott'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-3 kzCMZj"><p class="paragraph">Filtering by the key values of objects inside an array (below) is only supported by the MySQL connector.</p></span><p class="paragraph">The following query returns all users where the nested <code class="inline-code">favorites</code> > <code class="inline-code">treats</code> array contains an object where the <code class="inline-code">name</code> value is <code class="inline-code">"Dreamies"</code>:</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'$.favorites.treats[*].name'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> array_contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Dreamies'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div></section><section><h3 id="string_contains" style="position:relative"><a href="#string_contains" aria-label="inlinecodestring_containsinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>string_starts_with</inlinecode></h3><p class="paragraph">The following query returns all users where the nested <code class="inline-code">favorites</code> > <code class="inline-code">catBreed</code> key value starts with <code class="inline-code">"Turkish"</code>:</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>PostgreSQL</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'favorites'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'catBreed'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> string_starts_with</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Turkish'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div></section><section><h3 id="string_ends_with" style="position:relative"><a href="#string_ends_with" aria-label="inlinecodestring_ends_withinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>array_contains</inlinecode></h3><p class="paragraph">The following query returns all users where the <code class="inline-code">sanctuaries</code> array contains the value <code class="inline-code">"RSPCA"</code>:</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>PostgreSQL</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'sanctuaries'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> array_contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'RSPCA'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><p class="paragraph"><strong>Note</strong>: In PostgreSQL, the value of <code class="inline-code">array_contains</code> must be an array and not a string, even if the array only contains a single value.</p></span></tab></div><p class="paragraph">The following query returns all users where the <code class="inline-code">sanctuaries</code> array contains <em>all</em> the values in the given array:</p><div class="tabbedContent__Wrapper-sc-19zdpko-1 cqEcvg"><div class="tabbedContent__Tabs-sc-19zdpko-0 bXKDlh"><div class="tabHeading active " data-index="0"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>PostgreSQL</span></div><div class="tabHeading " data-index="1"><span class="fileWithIcon__FileNameWrapper-sc-13l4knb-0 dhygHl"><svg width="12" height="15" viewbox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 5.59609C8.76142 5.59609 11 4.79021 11 3.79609C11 2.80198 8.76142 1.99609 6 1.99609C3.23858 1.99609 1 2.80198 1 3.79609C1 4.79021 3.23858 5.59609 6 5.59609Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M11 7.99609C11 8.99209 8.77778 9.79609 6 9.79609C3.22222 9.79609 1 8.99209 1 7.99609" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M1 3.79614V12.1961C1 13.1921 3.22222 13.9961 6 13.9961C8.77778 13.9961 11 13.1921 11 12.1961V3.79614" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>MySQL</span></div></div><tab><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> getUsers </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> pets</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> path</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'sanctuaries'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> array_contains</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'RSPCA'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Alley Cat Allies'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></tab></div></section><section><h3 id="array_starts_with" style="position:relative"><a href="#array_starts_with" aria-label="inlinecodearray_starts_withinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Remarks</h3><ul class="list"><li><code class="inline-code">$on</code> and <code class="inline-code">$use</code> client methods do not exist on extended client instances which are extended using <a href="#extends"><code class="inline-code">$extends</code></a></li></ul><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-3 kzCMZj"><div class="admonition__FlexContainer-sc-htoeam-0 lfvhpa"><div class="admonition__ChildDiv-sc-htoeam-1 dDjWVR">In <a href="/docs/orm/prisma-client/client-extensions">extended clients</a>, Client methods do not necessarily exist. If you are extending your client, make sure to check for existence before using Client methods like <code class="inline-code">$transaction</code> or <code class="inline-code">$connect</code>.</div><div class="admonition__ChildDiv-sc-htoeam-1 dDjWVR">In addition, if you are using <code class="inline-code">$on</code> or <code class="inline-code">$use</code>, you will need to use these client methods before extending your client as these methods do not exist on extended clients. For <code class="inline-code">$use</code> specifically we recommend transitioning <a href="/docs/orm/prisma-client/client-extensions/query">to use query extensions</a>.</div></div></span></section><section><h3 id="disconnect-1" style="position:relative"><a href="#disconnect-1" aria-label="inlinecodedisconnectinlinecode 1 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>$use()</inlinecode></h3><span type="warning" class="admonition__AdmonitionWrapper-sc-htoeam-3 kzCMZj"><p class="paragraph"><code class="inline-code">$use</code> is not available in <a href="/docs/orm/prisma-client/client-extensions">extended clients</a>. Please <a href="/docs/orm/prisma-client/client-extensions/query">either migrate to query extensions</a> or use the <code class="inline-code">$use</code> method prior to extending your client.</p></span><p class="paragraph">The <code class="inline-code">$use()</code> method adds <a href="/docs/orm/prisma-client/client-extensions/middleware">middleware</a> :</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">$use</span><span class="token punctuation" style="color:#393A34">(</span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">params</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> next</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token console class-name">console</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">log</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">'This is middleware!'</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Modify or interrogate params here</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">return</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">next</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">params</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><section><h4 id="next" style="position:relative"><a href="#next" aria-label="inlinecodenextinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>params</inlinecode></h4><p class="paragraph"><code class="inline-code">params</code> is an object with information to use in your middleware.</p><div class="table__TableWrapper-sc-18kfzv9-0 jewaNT"><table><thead><tr><th align="left">Parameter</th><th align="left">Description</th></tr></thead><tbody><tr><td align="left"><code class="inline-code">action</code></td><td align="left">The query type - for example, <code class="inline-code">create</code> or <code class="inline-code">findMany</code>.</td></tr><tr><td align="left"><code class="inline-code">args</code></td><td align="left">Arguments that were passed into the query - for example, <code class="inline-code">where</code>, <code class="inline-code">data</code>, or <code class="inline-code">orderBy</code></td></tr><tr><td align="left"><code class="inline-code">dataPath</code></td><td align="left">Populated if you use the <a href="/docs/orm/prisma-client/queries/relation-queries#fluent-api">fluent API</a>.</td></tr><tr><td align="left"><code class="inline-code">model</code></td><td align="left">The model type - for example, <code class="inline-code">Post</code> or <code class="inline-code">User</code>.</td></tr><tr><td align="left"><code class="inline-code">runInTransaction</code></td><td align="left">Returns <code class="inline-code">true</code> if the query ran in the context of a <a href="#transaction">transaction</a>.</td></tr></tbody></table></div><section class="tip__Wrapper-sc-1dwv1cj-0 gTwDYR"><div><p class="paragraph">If you need the <code class="inline-code">model</code> property as a string, use: <code class="inline-code">String(params.model)</code></p></div></section><p class="paragraph">Example parameter values:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-js " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> args</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">15</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> dataPath</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'select'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'author'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'select'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'posts'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> runInTransaction</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> action</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'findMany'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> model</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Post'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="examples-78" style="position:relative"><a href="#examples-78" aria-label="examples 78 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>$metrics</inlinecode></h3><p class="paragraph">Prisma Client metrics give you a detailed insight into how Prisma Client interacts with your database. You can use this insight to help diagnose performance issues with your application. Learn more: <a href="/docs/orm/prisma-client/observability-and-logging/metrics">Metrics</a>.</p><p class="paragraph">Prisma Client metrics has the following methods:</p><ul class="list"><li><code class="inline-code">$metrics.json()</code>: <a href="/docs/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-json-format">Retrieves Prisma Client metrics in JSON format</a>.</li><li><code class="inline-code">$metrics.prometheus()</code>: <a href="/docs/orm/prisma-client/observability-and-logging/metrics#retrieve-metrics-in-prometheus-format">Retrieves Prisma Client metrics in Prometheus format</a>.</li></ul></section><section><h3 id="extends" style="position:relative"><a href="#extends" aria-label="inlinecodeextendsinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a><inlinecode>$extends</inlinecode></h3><p class="paragraph">With <code class="inline-code">$extends</code>, you can create and use Prisma Client extensions to add functionality to Prisma Client in the following ways:</p><ul class="list"><li><code class="inline-code">model</code>: add custom methods to your models</li><li><code class="inline-code">client</code>: add custom methods to your client</li><li><code class="inline-code">query</code>: create custom Prisma Client queries</li><li><code class="inline-code">result</code>: add custom fields to your query results</li></ul><p class="paragraph">Learn more: <a href="/docs/orm/prisma-client/client-extensions">Prisma Client extensions</a>.</p></section></section><section><h2 id="utility-types" style="position:relative"><a href="#utility-types" aria-label="utility types permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Using a "selector"</h4><p class="paragraph">When using the selector pattern, you use an existing Prisma Client instance to create a validator. This pattern allows you to select the model, operation, and query option to validate against.</p><p class="paragraph">You can also use an instance of Prisma Client that has been extended using a <a href="/docs/orm/prisma-client/client-extensions">Prisma Client extension</a>.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">validator</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token maybe-class-name">PrismaClientInstance</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'<model>'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'<operation>'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'<query option>'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> args </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="examples-79" style="position:relative"><a href="#examples-79" aria-label="examples 79 permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Examples</h4><p class="paragraph">The following example shows how you can extract and validate the input for the <code class="inline-code">create</code> operation you can reuse within your app:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">Prisma</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> </span><span class="token function-variable function" style="color:#d73a49">validateUserAndPostInput</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> postTitle</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">return</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token generic-function function" style="color:#d73a49">validator</span><span class="token generic-function generic class-name operator" style="color:#393A34"><</span><span class="token generic-function generic class-name maybe-class-name">Prisma</span><span class="token generic-function generic class-name punctuation" style="color:#393A34">.</span><span class="token generic-function generic class-name property-access maybe-class-name">UserCreateInput</span><span class="token generic-function generic class-name operator" style="color:#393A34">></span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> postTitle</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">Here is an alternative syntax for the same operation:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports punctuation" style="color:#393A34">{</span><span class="token imports"> </span><span class="token imports maybe-class-name">Prisma</span><span class="token imports"> </span><span class="token imports punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'@prisma/client'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> </span><span class="token imports">prisma</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">from</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'./prisma'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> </span><span class="token function-variable function" style="color:#d73a49">validateUserAndPostInput</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> postTitle</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token arrow operator" style="color:#393A34">=></span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">return</span><span class="token plain"> </span><span class="token maybe-class-name">Prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">validator</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'user'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'create'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token string" style="color:#e3116c">'data'</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> posts</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> create</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> postTitle</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h2 id="compare-columns-in-the-same-table" style="position:relative"><a href="#compare-columns-in-the-same-table" aria-label="compare columns in the same table permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Compare columns in the same table</h2><p class="paragraph">You can compare columns in the same table directly, for non-unique filters.</p><p class="paragraph">This feature was moved to general availability in version 5.0.0 and was available via the <code class="inline-code">fieldReference</code> Preview feature from Prisma ORM versions 4.3.0 to 4.16.2.</p><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><div class="admonition__FlexContainer-sc-htoeam-0 lfvhpa"><div class="admonition__ChildDiv-sc-htoeam-1 dDjWVR">In the following situations, you must <a href="/docs/orm/more/help-and-troubleshooting/help-articles/comparing-columns-through-raw-queries">use raw queries to compare columns in the same table</a>:</div><ul class="admonition__ChildList-sc-htoeam-2 kUyJrN"><li>If you use a version earlier than 4.3.0</li><li>If you want to use a unique filter, such as <a href="#findunique"><code class="inline-code">findUnique</code></a> or <a href="#finduniqueorthrow"><code class="inline-code">findUniqueOrThrow</code></a></li><li>If you want to compare a field with a <a href="/docs/orm/prisma-schema/data-model/models#defining-a-unique-field">unique constraint</a></li><li>If you want to use one of the following operators to compare a <a href="/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields">JSON field</a> in MySQL or MariaDB with another field: <a href="#gt"><code class="inline-code">gt</code></a>, <a href="#gte"><code class="inline-code">gte</code></a>, <a href="#lt"><code class="inline-code">lt</code></a>, or <a href="#lte"><code class="inline-code">lte</code></a>. Note that you can use these operators to compare the JSON field with a scalar value. This limitation applies only if you try to compare a JSON field with another field.</li></ul></div></span><p class="paragraph">To compare columns in the same table, use the <code class="inline-code"><model>.fields</code> property. In the following example, the query returns all records where the value in the <code class="inline-code">prisma.product.quantity</code> field is less than or equal to the value in the <code class="inline-code">prisma.product.warnQuantity</code> field.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">product</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> quantity</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> lte</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">product</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">warnQuantity</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><span type="info" class="admonition__AdmonitionWrapper-sc-htoeam-3 kwPClj"><p class="paragraph"><code class="inline-code">fields</code> is a special property of every model. It contains the list of fields for that model.</p></span><section><h3 id="considerations" style="position:relative"><a href="#considerations" aria-label="considerations permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Fields must be of the same type</h4><p class="paragraph">You can only make comparisons on fields of the same type. For example, the following causes an error:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">order</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">order</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">due</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Type error: id is a string, while amountDue is an integer</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="fields-must-be-in-the-same-model" style="position:relative"><a href="#fields-must-be-in-the-same-model" aria-label="fields must be in the same model permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Fields must be in the same model</h4><p class="paragraph">You can only make comparisons with the <code class="inline-code">fields</code> property on fields in the same model. The following example does not work:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">order</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">name</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Type error: name is a field on the User model, not Order</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">However, you can compare fields in separate models with <a href="#model-queries">standard queries</a>.</p></section><section><h4 id="in-groupby-model-queries-put-your-referenced-fields-in-the-by-argument" style="position:relative"><a href="#in-groupby-model-queries-put-your-referenced-fields-in-the-by-argument" aria-label="in inlinecodegroupbyinlinecode model queries put your referenced fields in the inlinecodebyinlinecode argument permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>In <inlinecode>groupBy</inlinecode> model queries, put your referenced fields in the <inlinecode>by</inlinecode> argument</h4><p class="paragraph">If you use the <a href="#groupby">groupBy</a> model query with the <code class="inline-code">having</code> option, then you must put your referenced fields in the <code class="inline-code">by</code> argument.</p><p class="paragraph">The following example works:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">groupBy</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> by</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'id'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'name'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> having</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">name</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following example does not work, because <code class="inline-code">name</code> is not in the <code class="inline-code">by</code> argument:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">groupBy</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> by</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token string" style="color:#e3116c">'id'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> having</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> equals</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">name</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// name is not in the 'by' argument</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="search-for-fields-in-scalar-lists" style="position:relative"><a href="#search-for-fields-in-scalar-lists" aria-label="search for fields in scalar lists permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Search for fields in scalar lists</h4><p class="paragraph">If your data source supports scalar lists (for example in PostgreSQL), then you can search for all records where a specific field is in a list of fields. To do so, reference the scalar list with the <a href="#in"><code class="inline-code">in</code></a> and <a href="#notin"><code class="inline-code">notIn</code></a> filters. For example:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findMany</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// find all users where 'name' is in a list of tags</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> name</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">in</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">fields</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">tags</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section></section></section><section><h2 id="filter-on-non-unique-fields-with-userwhereuniqueinput" style="position:relative"><a href="#filter-on-non-unique-fields-with-userwhereuniqueinput" aria-label="filter on non unique fields with inlinecodeuserwhereuniqueinputinlinecode permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Filter on non-unique fields with <inlinecode>UserWhereUniqueInput</inlinecode></h2><p class="paragraph">From version 5.0.0, the generated type <code class="inline-code">UserWhereUniqueInput</code> on <a href="#where"><code class="inline-code">where</code></a> exposes all fields on the model, not just unique fields. This was available under the <a href="/docs/orm/reference/preview-features/client-preview-features#preview-features-promoted-to-general-availability"><code class="inline-code">extendedWhereUnique</code> Preview flag</a> between versions 4.5.0 to 4.16.2</p><p class="paragraph">You must specify at least one unique field in your <code class="inline-code">where</code> statement <a href="#boolean-operators-with-userwhereuniqueinput">outside of boolean operators</a>, and you can specify any number of additional unique and non-unique fields. You can use this to add filters to any operation that returns a single record. For example, you can use this feature for the following:</p><ul class="list"><li><a href="#optimistic-concurrency-control-on-updates">Optimistic concurrency control on updates</a></li><li><a href="#permission-checks">Permission checks</a></li><li><a href="#soft-deletes">Soft deletes</a></li></ul><p class="paragraph">From version 4.6.0, you can use this feature to filter on optional <a href="/docs/orm/prisma-client/queries/relation-queries#nested-reads">one-to-one nested reads</a>.</p><section><h3 id="optimistic-concurrency-control-on-updates" style="position:relative"><a href="#optimistic-concurrency-control-on-updates" aria-label="optimistic concurrency control on updates permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Optimistic concurrency control on updates</h3><p class="paragraph">You can filter on non-unique fields to perform <a href="/docs/orm/prisma-client/queries/transactions#optimistic-concurrency-control">optimistic concurrency control</a> on <code class="inline-code">update</code> operations.</p><p class="paragraph">To perform optimistic concurrency control, we recommend that you use a <code class="inline-code">version</code> field to check whether the data in a record or related record has changed while your code executes. Before version 4.5.0, you could not evaluate the <code class="inline-code">version</code> field in an <code class="inline-code">update</code> operation, because the field is non-unique. From version 4.5.0, you can evaluate the <code class="inline-code">version</code> field.</p><p class="paragraph">In the following example, <code class="inline-code">updateOne</code> and <code class="inline-code">updateTwo</code> first read the same record and then attempt to update it. The database only executes these updates if the value in <code class="inline-code">version</code> is the same as the value when it did the initial read. When the database executes the first of these updates (which might be <code class="inline-code">updateOne</code> or <code class="inline-code">updateTwo</code>, depending on timing), it increments the value in <code class="inline-code">version</code>. This means that the database does not execute the second update because the value in <code class="inline-code">version</code> has changed.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-prisma " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">model</span><span class="token type-class-name"> User</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> id</span><span class="token type-class-name"> Int</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@id</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@default</span><span class="token punctuation" style="color:#393A34">(</span><span class="token function" style="color:#d73a49">autoincrement</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> email</span><span class="token type-class-name"> String</span><span class="token plain"> </span><span class="token annotation punctuation" style="color:#393A34">@unique</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> city</span><span class="token type-class-name"> String</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> version</span><span class="token type-class-name"> Int</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">updateOne</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">id</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> version</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">version</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Berlin'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> version</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> increment</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">updateTwo</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> user </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">id</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> version</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">version</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> city</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'New York'</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> version</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> increment</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">main</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> </span><span class="token known-class-name class-name">Promise</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">allSettled</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token function" style="color:#d73a49">updateOne</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">updateTwo</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h3 id="permission-checks" style="position:relative"><a href="#permission-checks" aria-label="permission checks permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Permission checks</h3><p class="paragraph">You can filter on non-unique fields to check permissions during an update.</p><p class="paragraph">In the following example, a user wants to update a post title. The <code class="inline-code">where</code> statement checks the value in <code class="inline-code">authorId</code> to confirm that the user is the author of the post. The application only updates the post title if the user is the post author.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> authorId</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> title</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'Updated post title'</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h3 id="soft-deletes" style="position:relative"><a href="#soft-deletes" aria-label="soft deletes permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Soft deletes</h3><p class="paragraph">You can filter on non-unique fields to handle soft deletes.</p><p class="paragraph">In the following example, we do not want to return a post if it is soft-deleted. The operation only returns the post if the value in <code class="inline-code">isDeleted</code> is <code class="inline-code">false</code>.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain">prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access maybe-class-name">Post</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">findUnique</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> postId</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> isDeleted</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">false</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h3 id="userwhereuniqueinput-considerations" style="position:relative"><a href="#userwhereuniqueinput-considerations" aria-label="inlinecodeuserwhereuniqueinputinlinecode considerations permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Boolean operators with <inlinecode>UserWhereUniqueInput</inlinecode></h4><p class="paragraph">With <code class="inline-code">UserWhereUniqueInput</code>, you must specify at least one unique field outside of the boolean operators <code class="inline-code">AND</code>, <code class="inline-code">OR</code>, <code class="inline-code">NOT</code>. You can still use these boolean operators in conjunction with any other unique fields or non-unique fields in your filter.</p><p class="paragraph">In the following example, we test <code class="inline-code">id</code>, a unique field, in conjunction with <code class="inline-code">email</code>. This is valid.</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"bob@prisma.io"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"alice@prisma.io"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ^^^ Valid: the expression specifies a unique field (`id`) outside of any boolean operators</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain" style="display:inline-block"> </span></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token comment" style="color:#999988;font-style:italic">// SQL equivalent:</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token comment" style="color:#999988;font-style:italic">// WHERE id = 1 AND (email = "bob@prisma.io" OR email = "alice@prisma.io")</span><span class="token plain"/></span></div></code></pre></div></div></pre><p class="paragraph">The following example is not valid, because there is no unique field outside of any boolean operators:</p><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token constant" style="color:#36acaa">OR</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">[</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"bob@prisma.io"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> email</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"alice@prisma.io"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">]</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// ^^^ Invalid: the expressions does not contain a unique field outside of boolean operators</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h4 id="one-to-one-relations" style="position:relative"><a href="#one-to-one-relations" aria-label="one to one relations permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>One-to-one relations</h4><p class="paragraph">From version 4.5.0, you can filter on non-unique fields in the following operations on <a href="/docs/orm/prisma-schema/data-model/relations/one-to-one-relations">one-to-one relations</a>:</p><ul class="list"><li>Nested update</li><li>Nested upsert</li><li>Nested disconnect</li><li>Nested delete</li></ul><p class="paragraph">Prisma Client automatically uses a unique filter to select the appropriate related record. As a result, you do not need to specify a unique filter in your <code class="inline-code">where</code> statement with a <code class="inline-code">WhereUniqueInput</code> <a href="#generated-types-for-where">generated type</a>. Instead, the <code class="inline-code">where</code> statement has a <code class="inline-code">WhereInput</code> generated type. You can use this to filter without the restrictions of <code class="inline-code">WhereUniqueInput</code>.</p><section><h5 id="nested-update-example" style="position:relative"><a href="#nested-update-example" aria-label="nested update example permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg"> </svg></a>Nested update example</h5><pre><div class="code__CodeWrapper-sc-8eixcc-0 cbTKLY codeWrapperDiv"><div class="gatsby-highlight pre-highlight"><pre class="code__Pre-sc-8eixcc-2 glKhkr prism-code language-ts " style="color:#393A34;background-color:#f6f8fa"><div class="code__AbsoluteCopyButton-sc-8eixcc-1 fcPKpO copy-button"><div class="copy__CopyComponent-sc-eodafv-0 jdLDrK"><svg width="25" height="24" viewbox="0 0 25 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="light"><rect x="0.5" width="24" height="24" rx="4" fill="#EDF2F7"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg width="25" height="24" viewbox="0 0 25 24" fill="#1A202C" xmlns="http://www.w3.org/2000/svg" class="dark"><rect x="0.5" width="24" height="24" rx="4" fill="#1A202C"/><path d="M15.5001 6.40002H17.0002C17.398 6.40002 17.7795 6.54752 18.0608 6.81007C18.3422 7.07263 18.5002 7.42872 18.5002 7.80002V17.6C18.5002 17.9713 18.3422 18.3274 18.0608 18.59C17.7795 18.8525 17.398 19 17.0002 19H8.00002C7.60219 19 7.22066 18.8525 6.93935 18.59C6.65804 18.3274 6.5 17.9713 6.5 17.6V7.80002C6.5 7.42872 6.65804 7.07263 6.93935 6.81007C7.22066 6.54752 7.60219 6.40002 8.00002 6.40002H9.50005" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M14.75 5H10.25C9.83579 5 9.5 5.33579 9.5 5.75V7.25C9.5 7.66421 9.83579 8 10.25 8H14.75C15.1642 8 15.5 7.66421 15.5 7.25V5.75C15.5 5.33579 15.1642 5 14.75 5Z" stroke="#A0AEC0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div><code style="width:max-content;overflow:visible"><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token keyword" style="color:#00009f">await</span><span class="token plain"> prisma</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">user</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">update</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> id</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> to_one</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Before Prisma version 4.5.0</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> field</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"updated"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// From Prisma version 4.5.0, you can also do the following:</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> update</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> where</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">/*WhereInput*/</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> data</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> field</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"updated"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"/></span></div><div class="code__Line-sc-8eixcc-3 eskRzB token-line " style="background-color:;symb-color:;class-name:"><span class="code__LineContent-sc-8eixcc-5 fEIrRl "><span class="token plain"/><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"/></span></div></code></pre></div></div></pre></section><section><h5 id="nested-upsert-example" style="position:relative"><a href="#nested-upsert-example" aria-label="nested upsert example permalink" class="title-link before"><svg width="17" height="18" viewbox="0 0 17 18" fill="none" xmlns="http://www.w3.org/2000/svg">
推荐文章
爱吹牛的水煮肉
·
【麒麟990手机】报价_麒麟990手机大全_价格图片大全-天极产品库
5 月前
胡子拉碴的便当
·
这些新型骗术你一定要知道-信息与网络管理中心
1 年前
威武的煎饼
·
拖拉机自卸车工地干活图片-中国路面机械网
1 年前
豪情万千的单车
·
陶喆专辑封-抖音
1 年前
迷茫的手术刀
·
特朗普宣布参加2024年总统竞选:“美国现在回来了!”-中新网
1 年前