Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

prisma Return a relations count with include

const usersWithCount = await prisma.user.findMany({
  include: {
    _count: {
      select: { posts: true },
    },
  },
})

/*
{ id: 1, _count: { posts: 3 } },
{ id: 2, _count: { posts: 2 } },
{ id: 3, _count: { posts: 2 } },
{ id: 4, _count: { posts: 0 } },
{ id: 5, _count: { posts: 0 } }
*/
Comment

prisma Return a relations count with include

const usersWithCount = await prisma.user.findMany({
  include: {
    _count: {
      select: { posts: true },
    },
  },
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: react-native navigation homeStack 
Javascript :: add array and sort 
Javascript :: Getting The Search Params With A For Of Loop 
Javascript :: Inside Fetch Is A Request 
Javascript :: JavaScript get div height dynamically without jQuery 
Javascript :: Moving Zeros To The End 
Javascript :: trigger oninput of input js 
Javascript :: function titleCase 2 
Javascript :: prisma get single data query 
Javascript :: useState intro 
Javascript :: camelcase to css variable javascript 
Javascript :: Backbone View El 
Javascript :: react creating function to call API in app: calling APIs after render w error message 
Javascript :: using nodeenv 
Javascript :: How do I target and change the style of a different element when I click a button in react 
Javascript :: close popup after 5 seconds in jquery 
Javascript :: react get variable from child component 
Javascript :: data.json 
Javascript :: js function to print word starts with vowels of given string 
Javascript :: var vs let javascript 
Javascript :: find an element 
Javascript :: js array map concat 
Javascript :: javascript json to excel 
Javascript :: color switcher 
Javascript :: how to save data in javascript 
Javascript :: javascript Non-numeric String Results to NaN 
Javascript :: Export Multiple Objects 
Javascript :: javascript Assigning to a getter-only property is not allowed 
Javascript :: alphanumeric without space regex 
Javascript :: at runtime.exports.handler aws lambda 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =