{"id":5637,"date":"2024-10-20T16:31:18","date_gmt":"2024-10-20T07:31:18","guid":{"rendered":"https:\/\/akamist.com\/blog\/?p=5637"},"modified":"2024-10-20T16:32:04","modified_gmt":"2024-10-20T07:32:04","slug":"ts-prisma%e3%81%aefindunique%e3%81%a8findfirst%e3%81%ae%e9%81%95%e3%81%84%e3%81%af%ef%bc%9f%e4%bd%bf%e3%81%84%e5%88%86%e3%81%91%e6%96%b9%e3%81%af","status":"publish","type":"post","link":"https:\/\/akamist.com\/blog\/archives\/5637","title":{"rendered":"[TS] prisma\u306efindUnique()\u3068findFirst()\u306e\u9055\u3044\u306f\uff1f\u4f7f\u3044\u5206\u3051\u65b9\u306f?"},"content":{"rendered":"<p>findUnique\u3068findFirst\u306f\u3001Prisma ORM\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u304c\u3001\u305d\u308c\u305e\u308c\u7570\u306a\u308b\u7528\u9014\u3068\u52d5\u4f5c\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>findUnique<\/h3>\n<ul>\n<li><strong>\u7528\u9014<\/strong>: \u4e00\u610f\u306e\u8b58\u5225\u5b50\uff08\u4e3b\u30ad\u30fc\u3084\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\uff09\u3092\u4f7f\u7528\u3057\u3066\u3001\u7279\u5b9a\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u52d5\u4f5c<\/strong>: \u6307\u5b9a\u3055\u308c\u305f\u4e00\u610f\u306e\u8b58\u5225\u5b50\u306b\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u305d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u8fd4\u3057\u307e\u3059\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f<code>null<\/code>\u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u4f7f\u3044\u65b9<\/strong>: \u4e3b\u30ad\u30fc\u3084\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<h4>\u4f8b<\/h4>\n<pre><code class=\"language-typescript\">const task = await this.prisma.task.findUnique({\n  where: {\n    id: taskId, \/\/ \u4e3b\u30ad\u30fc\u3084\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u3092\u6307\u5b9a\n  },\n});\n<\/code><\/pre>\n<h3>findFirst<\/h3>\n<ul>\n<li><strong>\u7528\u9014<\/strong>: \u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u6700\u521d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u52d5\u4f5c<\/strong>: \u6307\u5b9a\u3055\u308c\u305f\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u305d\u306e\u6700\u521d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u8fd4\u3057\u307e\u3059\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f<code>null<\/code>\u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u4f7f\u3044\u65b9<\/strong>: \u4e00\u610f\u306e\u8b58\u5225\u5b50\u3067\u306f\u306a\u304f\u3001\u8907\u6570\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u6761\u4ef6\u3067\u6700\u521d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<h4>\u4f8b<\/h4>\n<pre><code class=\"language-typescript\">const task = await this.prisma.task.findFirst({\n  where: {\n    userId: userId, \/\/ \u6761\u4ef6\u3092\u6307\u5b9a\n    status: 'OPEN',\n  },\n});\n<\/code><\/pre>\n<h3>\u4f7f\u3044\u5206\u3051\u65b9<\/h3>\n<ul>\n<li><strong>findUnique<\/strong>: \u4e3b\u30ad\u30fc\u3084\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u4e00\u610f\u306b\u8b58\u5225\u3067\u304d\u308b\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n<li><strong>findFirst<\/strong>: \u4e00\u610f\u306e\u8b58\u5225\u5b50\u3067\u306f\u306a\u304f\u3001\u8907\u6570\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u5b58\u5728\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u6761\u4ef6\u3067\u6700\u521d\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>findUnique\u3068findFirst\u306f\u3001Prisma ORM\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u304c\u3001\u305d\u308c\u305e\u308c\u7570\u306a\u308b\u7528\u9014\u3068\u52d5\u4f5c\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002 findUnique \u7528\u9014: \u4e00\u610f\u306e\u8b58\u5225\u5b50\uff08\u4e3b\u30ad\u30fc\u3084\u30e6\u30cb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":4640,"url":"https:\/\/akamist.com\/blog\/archives\/4640","url_meta":{"origin":5637,"position":0},"title":"O'Reilly\u306e\u300c\u306f\u3058\u3081\u3066\u306eSQL\u300d\u3092\u8aad\u3093\u3067\u3001MySQL8.0\u306eSQL\u3092\u5b66\u3073\u306a\u304a\u3057\u305f","date":"2021\u5e749\u670825\u65e5","format":false,"excerpt":"\u5fd8\u308c\u3066\u3044\u305f\u3053\u3068\u3001\u77e5\u3089\u306a\u304b\u3063\u305f\u3053\u3068\u3092\u81ea\u5206\u306e\u5fd8\u5099\u9332\u3068\u3057\u3066\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002 ## \uff12\u7ae0: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u2026","rel":"","context":"MySQL","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3575,"url":"https:\/\/akamist.com\/blog\/archives\/3575","url_meta":{"origin":5637,"position":1},"title":"\u304a\u540d\u524d.com\u3067\u30c9\u30e1\u30a4\u30f3\u3092\u767b\u9332\u3057\u305f\u6642\u306bdig\u30b3\u30de\u30f3\u30c9\u3067\u540d\u524d\u89e3\u6c7a\u3092\u78ba\u8a8d\u3059\u308b \u65b9\u6cd5","date":"2019\u5e743\u670816\u65e5","format":false,"excerpt":"\u304a\u540d\u524d.com\u3067\u3001DNS\u306eA\u30ec\u30b3\u30fc\u30c9\u306b\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u306a\u3069\u3092\u767b\u9332\u3057\u305f\u6642\u306b\u3001\u767b\u9332\u304c\u6210\u529f\u3057\u3066\u3044\u308b\u304b\u3092dig\u30b3\u2026","rel":"","context":"\u672a\u5206\u985e","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":991,"url":"https:\/\/akamist.com\/blog\/archives\/991","url_meta":{"origin":5637,"position":2},"title":"[PHP]Eloquent\u3067\u65e5\u4ed8\u306b\u95a2\u3059\u308b\u5217\u5b9a\u7fa9\u306e\u547d\u540d\u898f\u5247","date":"2017\u5e7411\u670813\u65e5","format":false,"excerpt":"PHP\u306eOR\u30de\u30c3\u30d1\u30fc\u3067\u3042\u308bEloquent\u3067\u306f\u3001\u30c7\u30fc\u30bf\u306e\u767b\u9332\u6642\u523b\u30fb\u66f4\u65b0\u6642\u523b\u3068\u3001\u30c7\u30fc\u30bf\u306e\u8ad6\u7406\u524a\u9664(So\u2026","rel":"","context":"PHP","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/10\/icon_php.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":923,"url":"https:\/\/akamist.com\/blog\/archives\/923","url_meta":{"origin":5637,"position":3},"title":"[WordPress]\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u304c\u672a\u6307\u5b9a\u306e\u6295\u7a3f\u3092SQL\u3067\u62bd\u51fa\u3059\u308b","date":"2017\u5e7411\u670811\u65e5","format":false,"excerpt":"WordPress\u3067\u306f\u5404\u6295\u7a3f\u306b\u5bfe\u3057\u3066\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u3092\u6307\u5b9a\u2026","rel":"","context":"\u672a\u5206\u985e","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/11\/icon_wordpress.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4661,"url":"https:\/\/akamist.com\/blog\/archives\/4661","url_meta":{"origin":5637,"position":4},"title":"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u8a66\u9a13 \u5408\u683c\u3078\u306e\u9053","date":"2021\u5e749\u670830\u65e5","format":false,"excerpt":"## \u52c9\u5f37\u306b\u4f7f\u7528\u3057\u305f\u30c6\u30ad\u30b9\u30c8 \u4e0b\u8a18\u306e\u66f8\u7c4d\u4e00\u518a\u3060\u3051\u3067OK\u3067\u3059\u3002\u3053\u306e\u66f8\u7c4d\u306f\u6bce\u5e74\u6539\u5b9a\u3055\u308c\u3066\u304a\u308a\u3001\u66f8\u7c4d\u3092\u8cfc\u5165\u2026","rel":"","context":"\u672a\u5206\u985e","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3284,"url":"https:\/\/akamist.com\/blog\/archives\/3284","url_meta":{"origin":5637,"position":5},"title":"ssh\u30b3\u30de\u30f3\u30c9\u3067\u30ed\u30b0\u30a4\u30f3\u6642\u3001'-i'\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u306e\u30ad\u30fc\u30d5\u30a1\u30a4\u30eb\u6307\u5b9a\u3092\u7701\u7565\u3059\u308b(ssh_config)","date":"2018\u5e7411\u67084\u65e5","format":false,"excerpt":"ssh\u30b3\u30de\u30f3\u30c9\u3067\u306f\u3001\u30ad\u30fc\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306f`~\/.ssh\/id_rsa`\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u2026","rel":"","context":"\u30af\u30e9\u30a6\u30c9","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/09\/icon_ssh.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/5637"}],"collection":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/comments?post=5637"}],"version-history":[{"count":3,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/5637\/revisions"}],"predecessor-version":[{"id":5640,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/5637\/revisions\/5640"}],"wp:attachment":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/media?parent=5637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/categories?post=5637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/tags?post=5637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}