Charles Gaudreau Jackson
11/26/2021, 8:34 PMRenato Carneiro
11/26/2021, 9:21 PMItalo Gama
11/27/2021, 1:45 AMItalo Gama
11/27/2021, 1:46 AMWingy
11/27/2021, 3:33 AMTaylor Cantwell
11/27/2021, 6:48 AMuser
11/27/2021, 1:22 PMBrook MG
11/27/2021, 3:52 PMCarlos
11/27/2021, 4:26 PMJinho Chung
11/27/2021, 11:38 PMprisma db pull
should be evoked followed by prisma generate
. Is this a common pattern? Does this suggest that if prisma is being added to an existing database, that migrations should not be used?Vinicius Marchesin
11/27/2021, 11:55 PMmodel Community {
id String @id @unique @default(uuid()) @db.Uuid
regions Region[]
...more stuff here
members UsersOnCommunities[]
}
enum Region {
NA
EU
LATAM
}
model User {
id String @id @unique @default(uuid()) @db.Uuid
...more stuff here
communities UsersOnCommunities[]
}
model UsersOnCommunities {
id String @unique @default(uuid())
userId String @db.Uuid
communityId String @db.Uuid
...more stuff here
community Community @relation(fields: [communityId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, communityId])
}
I want to find find many communities where region: ['NA']
and the count of members is greater than n
. I am using
const data = await prisma.community.findMany({
...my pagination here,
where: {
regions: {
hasSome: regions,
},
},
include: {
_count: {
select: {
members: true,
},
},
},
});
With this I am able to get the count of members, but I can't filter by that. From the docs it looks like I need to use groupBy
and filter using having
, but how can I get all fields back from the group by that way? Not sure what's the best way to do this besides a raw query.Kunal Shah
11/28/2021, 3:36 AMupdate
call
const data = await prisma.document.update({
where: { id },
data: {
...params,
// updated_at: new Date(), // when this is uncommented, type-checking fails
},
});
it correctly highlights that params
is not the right type to update the document. However when I uncomment the updated_at
line, the errors go away and it fails to typecheck at all. Any idea what I am doing wrong here? thanks in advance!Robert Fish
11/28/2021, 2:06 PMBenny
11/28/2021, 2:46 PMprepare
script of one of our libs we want to run prisma migrate dev
.
We are getting
Error: Prisma Migrate has detected that the environment is non-interactive, which is not supported
Is there a way to automatically accept the migrations? What is the best practice here?Benny
11/28/2021, 2:51 PMprisma db push --accept-data-loss
is the way to go?Benny
11/28/2021, 3:05 PMBenny
11/28/2021, 3:14 PMprisma db push --accept-data-loss
in npm prepare
script that will apply the changes that were pulled (because when pulling we are running pnpm i
that will eventually trigger prepare
.)
2. When changing the schema locally, before pushing, we have to run prisma migrate dev
to generate migration files.
Is this the correct flow?joao.santos
11/28/2021, 4:05 PMglenn
11/28/2021, 6:38 PMawait prisma.$queryRaw`SELECT * from job_search_db.jobs_function(
${distanceInt},
${dateRangeStr},
${remoteBoolArr},
${citiesArr},
${termsArr},
${excludeTermsArr},
${excludeCompaniesArr},
${jobBoardsArr},
${orderBy},
${limitInt},
${offsetInt}
)`
when I format it like this I get: db error: ERROR: number of array dimensions (1634890337) exceeds the maximum allowed (6)
However, when I just log the query that I placed in a variable then paste the query in hardcoded it works and returns the expected results
const result = await prisma.$queryRaw`SELECT * from job_search_db.jobs_function(
50000,
'2021-09-29T17:24:58.142Z',
array[true, false],
array[4560349,5128581,5205659],
array['%javascript%','%react.js%'],
array['%junior%','%jr%','%manager%','%analyst%','%recruiter%','%accounting%','%network%','%associate%'],
array['cybercoders'],
null,
'desc',
26,
0
)`
I don't really understand whyJulien Demarque
11/29/2021, 11:55 AMuser
11/29/2021, 12:18 PMItalo Gama
11/29/2021, 3:31 PMJames Homer
11/29/2021, 3:39 PMJames Homer
11/29/2021, 3:42 PMChris Bitoy
11/29/2021, 4:12 PMBenny
11/29/2021, 4:41 PMItalo Carrasco
11/29/2021, 6:49 PMmodel Notaria {
idNotaria Int @id @default(autoincrement())
idEstado Int
razonSocial String @db.VarChar(255)
codigo String @db.VarChar(255)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
estado Estado @relation(fields: [idEstado], references: [idEstado])
}
model Estado {
idEstado Int @id @default(autoincrement())
nombre String @db.VarChar(255)
Notaria Notaria[]
}
i am trying to use create like this but it throws an error related to data saying: type number is not assignable to undefined
crearNotaria: (_parent: any, args: CreateNotariaInput) => {
return prisma.notaria.create({
data: {
...args,
estado: { connect: { idEstado: args.idEstado } },
},
});
}
if i change the code to this, the error goes away. i dont understand why the first method doesnt work or what am i doing wrong.
crearNotaria: (_parent: any, args: CreateNotariaInput) => {
return prisma.notaria.create({
data: {
...args,
idEstado: args.idEstado,
},
});
}
Marcus Y.
11/29/2021, 7:19 PMmodel Newsletter {
email String @unique
}
model User {
id Int @id @unique @default(autoincrement())
config Configuration @relation(fields: [configurationId], references: [id])
records Record[]
information Information @relation(fields: [informationId], references: [dbid])
informationId String
affirmations String?
configurationId String
recaps Recap[]
lastIndex Int?
}
I create a new Newsletter record by running:
return await server.db.newsletter.create({
data: {
email: args.email,
},
});
It returns:
PrismaClientKnownRequestError:
`Invalid prisma.newsletter.findFirst()
invocation:`
`Failed to validate the query: Field does not exist on enclosing type.
at `Query.findFirstNewsletter``
at cb (/Users/*/*/*/*/node_modules/@prisma/client/runtime/index.js:38675:17)
at Object.addEmailToNewsletter (/Users/*/*/*/*/src/resolvers/addEmailtoNewsletter.ts:7:16) {
code: 'P2009',
clientVersion: '3.5.0',
meta: {
query_validation_error: 'Field does not exist on enclosing type.',
query_position: 'Query.findFirstNewsletter'
}
}
Any idea how to resolve this?Zak
11/29/2021, 9:24 PMMichael Aubry
11/29/2021, 9:44 PMid String @id @default(cuid())
Then the column is forced to 25 chars, but the docs say it can be up to 30, and I am running into a column too large issue. What is the best way to update the column char count to 30? Why did it generate at 25?
id character(25) PRIMARY KEY,
-- DDL generated by Postico 1.5.19
-- Not all database features are supported. Do not use for backup.
-- Table Definition ----------------------------------------------
CREATE TABLE graphcool."Media" (
id character(25) PRIMARY KEY,
createdat timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedat timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
date timestamp with time zone,
duration double precision,
loading boolean NOT NULL,
mediaurl text,
name text,
thumbnails text,
trimmed boolean,
type text,
uid text,
"thumbnailSprites" text,
metadata text
);
-- Indices -------------------------------------------------------
CREATE UNIQUE INDEX idx_17956_primary ON graphcool."Media"(id bpchar_ops);
CREATE UNIQUE INDEX idx_17956_id_unique ON graphcool."Media"(id bpchar_ops);