doddy nicolas
09/27/2022, 2:54 PMAlix A
09/27/2022, 3:01 PMversion: '3.8'
services:
postgres:
container_name: test-postgres
image: kartoza/postgis:14-3.3--v2022.08.30
ports:
- 15432:5432
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=test-db
volumes:
- postgis-data:/var/lib/postgresql
volumes:
postgis-data:
DATABASE_URL="<postgresql://admin:secret@localhost:15432/test-db?schema=public>"
doddy nicolas
09/27/2022, 3:40 PMguilherme
09/27/2022, 4:07 PMconst user = await this.prismaService.user.findUnique({
where: {
id: userId,
},
select: {
managing: {
select: {
user: {
select: {
person: true,
},
include: {
notifications: {
where: {
dismissAt: null,
},
},
},
},
},
},
},
});
Irakli Safareli
09/27/2022, 7:52 PMCollin
09/27/2022, 8:01 PMAustin
09/27/2022, 10:02 PMMichael
09/27/2022, 11:25 PMOR
actually functional? there's no OR present in the generated SQL and instead it seems to be generating the same SQL as when the OR is an AND:await prismaClient.objective.findMany({
where: {
patientId: id,
OR: { // replace with AND makes no difference
branchingOptionId: { not: null },
conversationItemId: { not: null },
},
},
});
// generates: SELECT Objectives.id, ... WHERE (Objectives.patientId = 1 AND Objectives.branchingOptionId IS NOT NULL AND Objectives.conversationItemId IS NOT NULL)
Amgelo563
09/28/2022, 12:40 AMTS2531: Object is possibly 'null'.
TS2345: Argument of type 'JsonValue' is not assignable to parameter of type 'string'. Type 'null' is not assignable to type 'string'.
What confuses me is that
• Wasn't JsonValue made to always support JSON.parse()?
• Why would JsonValue be null if my schema says it's required?
I tried to use
JSON.parse(fetchedValue ?? '{}');
but I get
TS2345: Argument of type 'string | number | boolean | JsonObject | JsonArray' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'.
which is related to the first mentioned point. Could someone explain to me what is going on? I probably missed something on the wiki or I did something wrongLucas Pelegrino
09/28/2022, 12:48 AMthis.$on('query', (event) => {
this.logger.debug(`Query: ${event.query}`, PrismaService.name);
}
It duplicates the logs, one time with my custom logger and one time (logged first) with prisma’s default one.Nurul
09/28/2022, 6:41 AMHenrik Spolander
09/28/2022, 8:24 AMDateTime
's are returned to me as strings. I understand this is how it works when writing in TypeScript but does it mean I have to define the types on the client differently than the models I defined for Prisma?
Is there a best practice for solving this?
Model:
model Review {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
comment String
score Int
wine Wine @relation(fields: [wineId], references: [id], onDelete: Cascade)
wineId String
reviewer WineUser @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
}
Query:
let db: PrismaClient;
//Prismaclient is imported from elsewhere
...
const reviews = await db.review.findMany({
take: 1,
});
console.log({reviews})
Log:
reviews: [
{
id: '00715d17-19ea-429d-8d04-cc0afe4f0b53',
createdAt: '2022-09-27T18:46:08.953Z',
updatedAt: '2022-09-27T18:46:08.953Z',
comment: 'Mycket prisvärt. Viss fatkaraktär. Körsbärstoner. Inte så kraftigt.\n' +
'Alk.: 13.50%',
score: 7,
wineId: '5b4fd795-4c82-4b78-b568-eb72754f6ab2',
userId: '8a65f07b-6357-45b4-9fb7-c13ca989053a'
}
]
Kashyup
09/28/2022, 10:00 AMKashyup
09/28/2022, 10:01 AMYudhvir Raj
09/28/2022, 10:58 AMmodel User {
@ComputedProperty(firstName, lastName)
fullName string
}
Does Prisma support such functionality or does it intend too in the future?Omri Goldberger
09/28/2022, 11:39 AMNurul
09/28/2022, 12:31 PMprisma generate
command included in your build step?
For example, here’s the package.json file in a sample repository which demonstrates deploying a next.js app with Prisma to vercel.Matheus Assis
09/28/2022, 3:01 PMDale Shanefelt
09/28/2022, 7:25 PMPaulo Castellano
09/28/2022, 9:22 PMconst website = await prisma.website.create({
data: {
name: name,
domain: domain,
users: {
connect: {
userId: userId,
role: 'owner'
}
},
},
})
Rob
09/29/2022, 4:47 AMNo cast exists, the column would be dropped and recreated, which cannot be done since the column is required and there is data in the table.
Is there no way I can just get it to add the column, but fill out a default value to fulfill the requirements?Amit Kumar
09/29/2022, 7:20 AMuser_id
in the table user_posts
is a reference to the table users
.
So when I introspect the database, schema like the following is generated, where it doesn't implicitly knows the relations
model users {
id BigInt @id @default(autoincrement())
user_name String? @db.VarChar
tenant_id Int?
}
model user_posts {
id BigInt @id @default(autoincrement())
post_id Int?
user_id Int?
tenant_id Int?
}
Any solution for this other than declaring each supposed foreign key in the main database?Theo Letouze
09/29/2022, 10:48 AMJarupong
09/29/2022, 11:56 AMven v
09/29/2022, 6:12 PMcreate table todos (
id bigint generated by default as identity primary key,
user_id uuid references auth.users not null,
task text check (char_length(task) > 3),
is_complete boolean default false,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
);
alter table todos enable row level security;
create policy "Individuals can create todos." on todos for
insert with check (auth.uid() = user_id);
create policy "Individuals can view their own todos. " on todos for
select using (auth.uid() = user_id);
create policy "Individuals can update their own todos." on todos for
update using (auth.uid() = user_id);
create policy "Individuals can delete their own todos." on todos for
delete using (auth.uid() = user_id);
something like this, how to do in prisma?Chris Graves
09/29/2022, 7:01 PMFergal Moran
09/29/2022, 7:02 PMconst items = await prisma.items.findMany({
take: 12, orderBy: { title: 'asc' },
include: {
_count: {
select: {
votes: { where: { isUp: true } },
votes: { where: { isUp: false } }, // ???
}
}
}
});
like, I would like the two votes fields to be "upVotes" and "downVotes"?
Thanks for any help!Guids
09/29/2022, 8:13 PMCollin
09/29/2022, 8:38 PMRob
09/30/2022, 5:34 AM