ossicor-san
ossicor-san
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
thanks a lot
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
I fixed
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
nvm I'm dumb
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
export const getChatroom = query({
args: { chatroomId: v.string() },
handler: async (ctx, args) => {
const chatroom = await ctx.db
.query("chatrooms")
.filter((q) => q.eq(q.field("_id"), args.chatroomId))
.unique();

if (!chatroom) {
throw new Error("Chatroom not found");
}

const creator = await ctx.db.get(chatroom.creatorId);
console.log(chatroom);

return {
creator: creator!.name,
chatroomId: chatroom._id,
name: chatroom.name,
};
},
});
export const getChatroom = query({
args: { chatroomId: v.string() },
handler: async (ctx, args) => {
const chatroom = await ctx.db
.query("chatrooms")
.filter((q) => q.eq(q.field("_id"), args.chatroomId))
.unique();

if (!chatroom) {
throw new Error("Chatroom not found");
}

const creator = await ctx.db.get(chatroom.creatorId);
console.log(chatroom);

return {
creator: creator!.name,
chatroomId: chatroom._id,
name: chatroom.name,
};
},
});
is there something wrong with this and/or
export default function App() {
return (
<Router>
<ChatroomSelect />
<Routes>
<Route path="/chatrooms/:chatroomId" element={<LoadingChatroom />}>
</Route>
</Routes>
</Router>
);
}
export default function App() {
return (
<Router>
<ChatroomSelect />
<Routes>
<Route path="/chatrooms/:chatroomId" element={<LoadingChatroom />}>
</Route>
</Routes>
</Router>
);
}
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
but for some reason it just cannot find the chatroom
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
import { useParams } from "react-router-dom";
import { api } from "../../convex/_generated/api";
import { useQuery } from "convex/react";
import ChatroomPage from "./ChatroomPage";

export default function LoadingChatroom() {
type ChatroomParams = {
chatroomId: string;
};

const { chatroomId } = useParams<ChatroomParams>();

if (!chatroomId) {
throw new Error("No chatroom ID provided");
}

const chatroom = useQuery(api.chatrooms.getChatroom, {
chatroomId: chatroomId,
});

if (!chatroom) {
return <div>Loading...</div>;
}

return (
<ChatroomPage
chatroomId={chatroom.chatroomId}
creator={chatroom.creator}
name={chatroom.name}
/>
);
}
import { useParams } from "react-router-dom";
import { api } from "../../convex/_generated/api";
import { useQuery } from "convex/react";
import ChatroomPage from "./ChatroomPage";

export default function LoadingChatroom() {
type ChatroomParams = {
chatroomId: string;
};

const { chatroomId } = useParams<ChatroomParams>();

if (!chatroomId) {
throw new Error("No chatroom ID provided");
}

const chatroom = useQuery(api.chatrooms.getChatroom, {
chatroomId: chatroomId,
});

if (!chatroom) {
return <div>Loading...</div>;
}

return (
<ChatroomPage
chatroomId={chatroom.chatroomId}
creator={chatroom.creator}
name={chatroom.name}
/>
);
}
I tried doing this as the docs suggested
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
@ian actually didnt resolve
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
export default async function ChatroomPage() {
type ChatroomParams = {
chatroomId: string;
};

const { chatroomId } = useParams<ChatroomParams>();

if (!chatroomId) {
throw new Error("No chatroom ID provided");
}

const chatroom = await useQuery(api.chatrooms.getChatroom, {
chatroomId: chatroomId,
});

if (!chatroom) {
throw new Error("Chatroom not found");
}

const messages =
(await useQuery(api.messages.list, { chatroomId: chatroom.chatroomId })) ||
[];
export default async function ChatroomPage() {
type ChatroomParams = {
chatroomId: string;
};

const { chatroomId } = useParams<ChatroomParams>();

if (!chatroomId) {
throw new Error("No chatroom ID provided");
}

const chatroom = await useQuery(api.chatrooms.getChatroom, {
chatroomId: chatroomId,
});

if (!chatroom) {
throw new Error("Chatroom not found");
}

const messages =
(await useQuery(api.messages.list, { chatroomId: chatroom.chatroomId })) ||
[];
I did this
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
showing this error now
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
No description
15 replies
CCConvex Community
Created by ossicor-san on 9/11/2023 in #support-community
Using Filter does not work with ids as string?
oh, I should await it?
15 replies