xoldyckk
xoldyckk
Explore posts from servers
TTCTheo's Typesafe Cult
Created by xoldyckk on 9/12/2023 in #questions
How to validate the media url returned from clients when using uploadthing?
Client uploads file(s), receives media url(s), sends them to the server , server stores them in database. But what if client submits invalid url(s) that don't correspond to the media files that were uploaded on the client? If the client hijacks the form submission process and provides a custom media url, how do we prevent that?
2 replies
SSolidJS
Created by xoldyckk on 8/15/2023 in #support
Help me build a custom link component which adheres to solid's principles
import { ParentComponent } from "solid-js";
import { A } from "solid-start";
import { type AnchorProps } from "@solidjs/router";

export const CustomLink: ParentComponent<
{
class: string | undefined;
href: string;
sameSite: boolean;
} & AnchorProps
> = (props) => {
return (
<A
class={props.class}
href={props.href}
target={props.sameSite ? "_self" : "_blank"}
>
{props.children}
</A>
);
};
import { ParentComponent } from "solid-js";
import { A } from "solid-start";
import { type AnchorProps } from "@solidjs/router";

export const CustomLink: ParentComponent<
{
class: string | undefined;
href: string;
sameSite: boolean;
} & AnchorProps
> = (props) => {
return (
<A
class={props.class}
href={props.href}
target={props.sameSite ? "_self" : "_blank"}
>
{props.children}
</A>
);
};
I wanted to ask how do I apply the rest of properties present on the props object on <A> tag? Since in solid destructuring would make the signals not work later on down the line, if I were to pass them in through props. I was thinking of doing this but this seems error prone. Basically I wanted to know of a clean way to achieve a similar thing without breaking solid's reactivity.
import { ParentComponent } from "solid-js";
import { A } from "solid-start";
import { type AnchorProps } from "@solidjs/router";

export const CustomLink: ParentComponent<
{
class: string | undefined;
href: string;
sameSite: boolean;
} & AnchorProps
> = ({children, class, href, sameSite, ...props}) => {
return (
<A
class={class}
href={href}
target={sameSite ? "_self" : "_blank"}
...props
>
{children}
</A>
);
};
import { ParentComponent } from "solid-js";
import { A } from "solid-start";
import { type AnchorProps } from "@solidjs/router";

export const CustomLink: ParentComponent<
{
class: string | undefined;
href: string;
sameSite: boolean;
} & AnchorProps
> = ({children, class, href, sameSite, ...props}) => {
return (
<A
class={class}
href={href}
target={sameSite ? "_self" : "_blank"}
...props
>
{children}
</A>
);
};
3 replies
DTDrizzle Team
Created by xoldyckk on 8/14/2023 in #help
Need help implementing one to many relations for a table on itself
const comments = pgTable("comments", {
id: text("id").notNull().primaryKey(),

parentCommentId: text("parent_comment_id").references(
(): AnyPgColumn => comments.id
),
});

const commentsRelations = relations(comments, ({ many, one }) => ({
childComments: many(comments, {
relationName: "child_comments_from_parent_comment",
}),

parentComment: one(comments, {
fields: [comments.parentCommentId],
references: [comments.id],
relationName: "parent_comment_from_child_comment",
}),
}));
const comments = pgTable("comments", {
id: text("id").notNull().primaryKey(),

parentCommentId: text("parent_comment_id").references(
(): AnyPgColumn => comments.id
),
});

const commentsRelations = relations(comments, ({ many, one }) => ({
childComments: many(comments, {
relationName: "child_comments_from_parent_comment",
}),

parentComment: one(comments, {
fields: [comments.parentCommentId],
references: [comments.id],
relationName: "parent_comment_from_child_comment",
}),
}));
I want to implement a one to many self relation on the comments table, where a comment can have child comments recursively. The comment where parentCommentId is null would be the root comment that has no parent comment. Somehow this doesn't work. What's the problem in this schema? Here's the error:-
There is not enough information to infer relation "comments.childComments"
There is not enough information to infer relation "comments.childComments"
13 replies
TTCTheo's Typesafe Cult
Created by xoldyckk on 1/6/2023 in #questions
What are different approaches to persisting the state of a page(dynamic pages included)?
On social media sites like instagram, let's say we scroll down a big list of comments and open the profile page for one of the commentors. Now if we navigate back to the comments page again(using back button presumably) the whole page's state is reset, the comments are loaded again(maybe cached), the position on the page we scrolled to(the comment whose commentor's profile we opened) is lost. It would be a hassle to scroll back to that comment again. So, how do apps mitigate this behaviour? I'd like hear about solutions to this which works on dynamic pages as well(like /user/1 and /user/2 both pages have their individual states persisted).
2 replies
TTCTheo's Typesafe Cult
Created by xoldyckk on 1/3/2023 in #questions
How to refetch(refresh) next-auth session manually on the client side?
Let's say the app has two unique models user and profile, both are in a one to one relation. User object will have a field named profileId which can be a string or null depending on whether the user object has a profile linked to it. After a successful sign in we get the user session object back which has profileId === null. Then we force the user to create a profile if they want to make use of all functionalities of the app. So, the user creates a profile which gets linked to their user object in the database. Now session.user.profileId === "somethingId". How do I refresh the session to update this change on client side without any page reloads and stuff? Like doing it the react way, refetch the sesion, set the session state to the refetched value.
7 replies
SSolidJS
Created by xoldyckk on 12/11/2022 in #support
Can we use solid's For and Index component for data that isn't stored as a signal?
Let's say we're using something like react-query or urql to fetch some data from the server and render it. We're not making a raw fetch request and storing the results in solid's signals. Instead the results are controlled by an external library. Would we get the benefits of solid's For and Index components with this approach?
4 replies