jsoneaday
jsoneaday
Explore posts from servers
PPrisma
Created by jsoneaday on 10/31/2024 in #help-and-questions
Why is omit not available for this query?
I am using prisma 5.21.1. If I try this call omit is not available why?
client.profile.findFirst({
omit: {
password: true,
},
where: {
id: profileId,
},
});
client.profile.findFirst({
omit: {
password: true,
},
where: {
id: profileId,
},
});
8 replies
PPrisma
Created by jsoneaday on 9/9/2024 in #help-and-questions
Cursor based paging issue for multilevel relationships
I have this query. As you can see my paging field's like cursors are inside the select: works section. Question completes in the next post.
const works = await this.#client.follow.findMany({
select: {
followed: {
select: {
works: {
take: pageSize,
skip: lastCursor ? 1 : 0,
cursor: lastCursor
? {
id: lastCursor,
}
: undefined,
orderBy: {
id: SortOrder.Desc,
},
select: {
id: true,
updatedAt: true,
title: true,
description: true,
content: true,
authorId: true,
author: {
select: {
userName: true,
fullName: true,
description: true,
},
},
workTopics: {
select: {
topic: {
select: {
id: true,
name: true,
},
},
},
},
workLikes: {
select: {
id: true,
},
},
},
},
},
},
},
where: {
followerId,
},
});
const works = await this.#client.follow.findMany({
select: {
followed: {
select: {
works: {
take: pageSize,
skip: lastCursor ? 1 : 0,
cursor: lastCursor
? {
id: lastCursor,
}
: undefined,
orderBy: {
id: SortOrder.Desc,
},
select: {
id: true,
updatedAt: true,
title: true,
description: true,
content: true,
authorId: true,
author: {
select: {
userName: true,
fullName: true,
description: true,
},
},
workTopics: {
select: {
topic: {
select: {
id: true,
name: true,
},
},
},
},
workLikes: {
select: {
id: true,
},
},
},
},
},
},
},
where: {
followerId,
},
});
2 replies
MModular
Created by jsoneaday on 8/31/2024 in #community-showcase
Created a job posting app for less popular languages like Mojo
App focuses on esoteric and less popular languages that still have fortune 1000 companies using them. https://syntaxmakers.com/
1 replies
PPrisma
Created by jsoneaday on 6/17/2024 in #help-and-questions
Docker error Can't reach database server at localhost:5432
I'm using docker compose and my server api depends on a postgres server in the same container. During the build I run
prisma migrate deploy
prisma migrate deploy
and get this error. I also tried replacing localhost with 0.0.0.0 and db (my database's docker service name) but it does not work. Strangely from my dev machine I'm able to run
prisma migrate dev --name init
prisma migrate dev --name init
without issue using this same DATABASE_URL variable.
DATABASE_URL="postgresql://freeauth:freeauth@localhost:5432/freeauth?schema=public"
DATABASE_URL="postgresql://freeauth:freeauth@localhost:5432/freeauth?schema=public"
5 replies
DDeno
Created by jsoneaday on 8/28/2023 in #help
fastwebsockets how to end client calls and avoid Error in websocket connection Unexpected EOF
What is the issue in this client code that causes the error?
pub async fn connect() -> Result<FragmentCollector<Upgraded>> {
let stream = TcpStream::connect("127.0.0.1:9001").await?;

let req = Request::builder()
.method("GET")
.uri("http://127.0.0.1:9001")
.header("Host", "localhost:9001")
.header(UPGRADE, "websocket")
.header(CONNECTION, "upgrade")
.header(
"Sec-Websocket-Key",
fastwebsockets::handshake::generate_key()
)
.header("Sec-Websocket-Version", "13")
.body(Body::empty())?;

let ws_result = handshake::client(&SpawnExecutor, req, stream).await;
match ws_result {
Ok((ws, _)) => {
Ok(FragmentCollector::new(ws))
},
Err(err) => {
Err(err.into())
}
}
}
async fn main() {
let mut ws = connect().await.unwrap();

let message = String::from("hello world");
let binding = message.clone();
let message = binding.as_bytes();

_ = ws.write_frame(Frame::text(Payload::from(message))).await;

_ = ws.write_frame(Frame::close(1000, &[]));
}
pub async fn connect() -> Result<FragmentCollector<Upgraded>> {
let stream = TcpStream::connect("127.0.0.1:9001").await?;

let req = Request::builder()
.method("GET")
.uri("http://127.0.0.1:9001")
.header("Host", "localhost:9001")
.header(UPGRADE, "websocket")
.header(CONNECTION, "upgrade")
.header(
"Sec-Websocket-Key",
fastwebsockets::handshake::generate_key()
)
.header("Sec-Websocket-Version", "13")
.body(Body::empty())?;

let ws_result = handshake::client(&SpawnExecutor, req, stream).await;
match ws_result {
Ok((ws, _)) => {
Ok(FragmentCollector::new(ws))
},
Err(err) => {
Err(err.into())
}
}
}
async fn main() {
let mut ws = connect().await.unwrap();

let message = String::from("hello world");
let binding = message.clone();
let message = binding.as_bytes();

_ = ws.write_frame(Frame::text(Payload::from(message))).await;

_ = ws.write_frame(Frame::close(1000, &[]));
}
1 replies