Hi everyone! I'm trying out prisma as we are looki...
# orm-help
s
Hi everyone! I'm trying out prisma as we are looking to migrate a current application to Next.js with TypeScript, and adding testing to really tighten up the stability of the app. I'm getting really close, but I'm having an issue with typescript throwing an error when trying to mock a
groupBy
call. Currently I have this:
Copy code
prismaMock.fitment.groupBy.mockResolvedValue([
	{ year: '2020', make: 'Ford', model: 'F-150', sub_model: null },
]);
👀 1
a
Hey @Sean Templeton 👋, Would you mind sharing the relevant parts of your schema? I’ll try to recreate this on my end.
s
Copy code
create table fitment
(
    id        serial primary key,
    created   timestamp default now() not null,
    modified  timestamp default now() not null,
    year      text                    not null,
    make      text                    not null,
    model     text                    not null,
    sub_model text                    not null,
);
a
Do you have the Prisma schema representation as well?
s
I do not. It was an existing database. I did the
generate
command or something like that to get a client, but I don't have any prisma file in my repo as far as I can see.
a
You should have a
schema.prisma
file in your project somewhere, I think. Are you using Prisma successfully in your actual application code?
v
👋 Hi @Sean Templeton I wanted to check if you were able to fully address all your questions or if there's still anything we can do to help?
s
Sorry, been busy with our projects, i keep forgetting to check here. I don't see a
schema.prisma
file, and yes, i have it working successfully in code (and in test). It just shows a typescript error for the test
a
Are you consuming Prisma through a 3rd-party module or directly? Every Prisma project needs a
schema.prisma
file somewhere 🤔.
s
@Austin Sorry I didn't reply, not sure why I wasn't seeing notifications. I'm consuming it directly. I don't use prisma migrations, if that makes any difference
n
Can you invoke
npx prisma db pull
command in your project? this should introspect your database and create a
schema.prisma
file for you.
s
@Austin wow, i'm sorry this is so delayed. I'm leaving the company so I'm not actively working on this anymore. I did, however, find there was indeed a primsa schema, i was just blink. Here's the fitment model:
Copy code
model fitment {
  id                 Int               @id @default(autoincrement())
  created            DateTime          @default(now()) @db.Timestamp(6)
  modified           DateTime          @default(now()) @db.Timestamp(6)
  available          Boolean
  sku                String
  vendor             String
  comment            String
  year               String
  make               String
  model              String
  sub_model          String
  part_number        String
  row                String
  seat_description   String
  amazon_description String
  diagram            String
  tip_1_title        String            @default("")
  tip_1_description  String            @default("")
  tip_1_image        String            @default("")
  tip_2_title        String            @default("")
  tip_2_description  String            @default("")
  tip_2_image        String            @default("")
  evox_vif           String            @default("")
  sort_by            Int               @default(0)
  legacy_id          Int?
  questions          Json              @default("[]") @db.Json
  addons             String[]          @default([])
  analytics_count    analytics_count[]
}