Yilmaz Ugurlu
10/26/2021, 2:51 PMQuery createOneActivity is required to return data, but found no record(s).
I just created a model and trying to create a record and receiving this error..
This is my model
model Activity {
createdAt DateTime @default(now()) @map(name: "created_at") @db.Timestamptz(0)
actionUserId String @map(name: "action_user_id") @db.Uuid
affectedUserId String @map(name: "affected_user_id") @db.Uuid
event String @db.VarChar(64)
entity Json
@@id([createdAt, actionUserId, affectedUserId, event])
@@index(fields: [affectedUserId, createdAt], name: "actvt_fltr_idx")
@@index(fields: [affectedUserId, createdAt, event], name: "actvt_fltr_evt_idx")
@@map(name: "activity")
}
and this is the code that Iām using
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
const handler = async () => {
const data = await prisma.activity.create({
data: {
event: 'test',
actionUserId: '85a42af9-bb28-47b3-9ef2-699858c8bbea',
affectedUserId: '85a42af9-bb28-47b3-9ef2-699858c8bbea',
entity: { key: 'value' },
},
});
console.log(data);
};
handler();
Yilmaz Ugurlu
10/26/2021, 2:52 PMYilmaz Ugurlu
10/26/2021, 2:52 PMprisma:tryLoadEnv Environment variables loaded from /app/project/.env +0ms
prisma:tryLoadEnv Environment variables loaded from /app/project/.env +4ms
[dotenv][DEBUG] "DATABASE_URL" is already defined in `process.env` and will not be overwritten
[dotenv][DEBUG] "DATABASE_USER" is already defined in `process.env` and will not be overwritten
[dotenv][DEBUG] "DATABASE_NAME" is already defined in `process.env` and will not be overwritten
[dotenv][DEBUG] "DATABASE_PORT" is already defined in `process.env` and will not be overwritten
[dotenv][DEBUG] "DATABASE_PASSWORD" is already defined in `process.env` and will not be overwritten
prisma:client clientVersion: 3.2.1 +0ms
prisma:client:libraryEngine internalSetup +0ms
prisma:client Prisma Client call: +61ms
prisma:client prisma.activity.create({
prisma:client data: {
prisma:client event: 'test',
prisma:client actionUserId: '85a42af9-bb28-47b3-9ef2-699858c8bbea',
prisma:client affectedUserId: '85a42af9-bb28-47b3-9ef2-699858c8bbea',
prisma:client entity: {
prisma:client key: 'value'
prisma:client }
prisma:client }
prisma:client }) +1ms
prisma:client Generated request: +0ms
prisma:client mutation {
prisma:client createOneActivity(data: {
prisma:client event: "test"
prisma:client actionUserId: "85a42af9-bb28-47b3-9ef2-699858c8bbea"
prisma:client affectedUserId: "85a42af9-bb28-47b3-9ef2-699858c8bbea"
prisma:client entity: "{\"key\":\"value\"}"
prisma:client }) {
prisma:client createdAt
prisma:client actionUserId
prisma:client affectedUserId
prisma:client event
prisma:client entity
prisma:client }
prisma:client }
prisma:client +0ms
prisma:client:libraryEngine sending request, this.libraryStarted: false +62ms
prisma:client:libraryEngine Search for Query Engine Library in /app/project/node_modules/.prisma/client +1ms
prisma:client:libraryEngine loadEngine using /app/project/node_modules/.prisma/client/libquery_engine-darwin.dylib.node +0ms
prisma:client:libraryEngine library starting +43ms
prisma:client:libraryEngine library started +63ms
prisma:client:libraryEngine graphQLToJSError +25ms
prisma:client:fetcher Error: Query createOneActivity is required to return data, but found no record(s).
prisma:client:fetcher at LibraryEngine.prismaGraphQLToJSError (/app/project/node_modules/@prisma/client/runtime/index.js:26923:14)
prisma:client:fetcher at LibraryEngine.request (/app/project/node_modules/@prisma/client/runtime/index.js:26938:24)
prisma:client:fetcher at cb (/app/project/node_modules/@prisma/client/runtime/index.js:38705:26)
prisma:client:fetcher at handler (/app/project/seed-data/seed_test.ts:9:16) +0ms
/app/project/node_modules/@prisma/client/runtime/index.js:38739
throw new import_engine_core3.PrismaClientUnknownRequestError(message, this.prisma._clientVersion);
^
Error:
Invalid `prisma.activity.create()` invocation in
/app/project/seed-data/seed_test.ts:9:38
6 const prisma = new PrismaClient();
7
8 const handler = async () => {
ā 9 const data = await prisma.activity.create(
Query createOneActivity is required to return data, but found no record(s).
at cb (/app/project/node_modules/@prisma/client/runtime/index.js:38739:17)
at handler (/app/project/seed-data/seed_test.ts:9:16)
prisma:client:libraryEngine hookProcess received: exit +7ms
prisma:client:libraryEngine runBeforeExit +1ms
Ryan
10/27/2021, 12:04 PMYilmaz Ugurlu
10/27/2021, 12:46 PMYilmaz Ugurlu
10/27/2021, 12:46 PMRyan
10/27/2021, 1:02 PMYilmaz Ugurlu
10/27/2021, 4:02 PMYilmaz Ugurlu
10/27/2021, 4:03 PMdatasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["filterJson", "fullTextSearch"]
binaryTargets = ["native", "linux-arm64-openssl-1.0.x", "linux-musl"]
}
model Activity {
createdAt DateTime @default(now()) @map(name: "created_at") @db.Timestamptz(0)
actionUserId String @map(name: "action_user_id") @db.Uuid
affectedUserId String @map(name: "affected_user_id") @db.Uuid
event String @db.VarChar(64)
entity Json
@@id([createdAt, actionUserId, affectedUserId, event])
@@index(fields: [affectedUserId, createdAt], name: "actvt_fltr_idx")
@@index(fields: [affectedUserId, createdAt, event], name: "actvt_fltr_evt_idx")
@@map(name: "activity")
}
Here is my whole schema and the testing code is already above.Yilmaz Ugurlu
10/27/2021, 4:04 PMmigrate && generate
Yilmaz Ugurlu
10/27/2021, 4:04 PMnode test.js