Hello <@UESADRKMY> I created model called `List` a...
# orm-help
j
Hello @Ryan I created model called
List
and
Activity
Copy code
model List {
 id   Int             @id @default(autoincrement())
 Activity             Activity[]
 @@map("list")
}

model Activity {
 id             Int          @id @default(autoincrement())
 status         String
 list_id        Int
 List           List        @relation(fields: [list_id], references: [ID])
 @@map("activity")
}
Now I need to new column called listDoneActivity so created extend type like below
Copy code
export const ListDoneActivity = extendType({
    type: 'List',
    definition(t) {
      t.field('listDoneActivity', {
        type: nonNull('Int'),
        args: {
            filter: intArg(),
          },
        async resolve(parent: any, args, ctx: Context) {
            console.log('parent', parent)
            console.log('args', args)
        return parent.Activity.filter(
              (item) => item?.status                === 'Done')?.length
        },
      })
    },
  })
Now I need to apply filtering on the List that I need only those records which has
listDoneActivity
> 2
So how can I achieve this @Ryan?
@Ahmed
a
@Jemin Kothari if you using the prisma select plugin please take a look to this example in paljs docs https://paljs.com/plugins/select#filter
you can add a new extends type and use the default fields but you need to add the original file
Activity
to default fields because maybe frontend asking for the other one extends on this one put not this one this mean will get an error
j
Yes, but now I need to filter on this new extended type
Now I need to apply filtering on the List that I need only those records which has 
listDoneActivity
 > 2
a
ok now you have your filter here
args.filter
and you can use easily here
Copy code
parent.Activity.filter(
              (item) => item?.status                === 'Done')?.length
j
Copy code
let doneCount = parent.Activity.filter(
              (item) => item?.status                === 'Done')?.length
return doneCount  > args.filter ? doneCount : null