Hārūn | هارون
Hārūn | هارون
Explore posts from servers
VVALORANT
Created by Hārūn | هارون on 6/29/2024 in #community-help
Resolution changing when starting Val
Even when I use nvidia control panel it defaults back to 1024x768
3 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
So now, if I wanted to get all posts by x tag name e.g. /tag/typescript , then I'd need a one to many , correct ?
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
export const getTagsForPost = query({
args: { postId: v.id("posts") },
handler: async (ctx, args) => {

const tags = await getManyVia(
ctx.db,
"postTags",
"tagId",
"postId_tags",
args.postId,
"postId"
);

return tags.map((tag) => tag?.name);
},
});
export const getTagsForPost = query({
args: { postId: v.id("posts") },
handler: async (ctx, args) => {

const tags = await getManyVia(
ctx.db,
"postTags",
"tagId",
"postId_tags",
args.postId,
"postId"
);

return tags.map((tag) => tag?.name);
},
});
This is what I was able to make , and it is functional from what I've noticed
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
I don't know what I changed but I can confirm that it works, I think it was this that caused the difference and it works! Just wanted to ask how I would filter now through these as the filter I've written doesn't work 😅 and was wondering if it's possible or just a syntax error:
export const getTagsForPost = query({
args: { postId: v.id("posts") },
handler: async (ctx, args) => {
const postTags = await ctx.db
.query("postTags")
.withIndex("postId_tags" ,(q) => q.eq("postId", args.postId))
.collect();

const tagIds = postTags.map((postTag) => postTag.tagId);
const tags = await ctx.db
.query("tags")
.take(5)
// .filter((q) => q.eq(q.field("_id"), tagIds))

return tags.map((tag) => tag.name);
},
});
export const getTagsForPost = query({
args: { postId: v.id("posts") },
handler: async (ctx, args) => {
const postTags = await ctx.db
.query("postTags")
.withIndex("postId_tags" ,(q) => q.eq("postId", args.postId))
.collect();

const tagIds = postTags.map((postTag) => postTag.tagId);
const tags = await ctx.db
.query("tags")
.take(5)
// .filter((q) => q.eq(q.field("_id"), tagIds))

return tags.map((tag) => tag.name);
},
});
using .take(5) at the moment until the filter works.
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
@ian If you could look into this it'd be super helpful as I cannot figure out what's wrong
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags,
}
);

return postId;
},
});
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags,
}
);

return postId;
},
});
And this is my createPostAction
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
No description
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string())
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags
}
);

return postId;
},
});
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string())
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags
}
);

return postId;
},
});
My post action as well
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
posts: defineTable({
title: v.string(),
userId: v.string(),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
author: v.optional(v.string()),
likes: v.number(),
likeIds: v.optional(v.array(v.string())),
}),
tags: defineTable({
tagId: v.string(),
name: v.string(),
}),
postTags: defineTable({
postId: v.id("posts"),
tagId: v.id("tags"),
}).index("postId_tags", ["postId", "tagId"]),
posts: defineTable({
title: v.string(),
userId: v.string(),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
author: v.optional(v.string()),
likes: v.number(),
likeIds: v.optional(v.array(v.string())),
}),
tags: defineTable({
tagId: v.string(),
name: v.string(),
}),
postTags: defineTable({
postId: v.id("posts"),
tagId: v.id("tags"),
}).index("postId_tags", ["postId", "tagId"]),
Something like this? And what would I need to change here? I'm assuming a forloop and I've tried but no success so far:
export const createPost = internalMutation({
args: {
title: v.string(),
userId: v.id("users"),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
likes: v.number(),
likeIds: v.array(v.string()),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const user = await ctx.db.get(args.userId);

if (!user) {
throw new ConvexError("User not found.");
}

const id = await ctx.db.insert("posts", {
title: args.title,
userId: user._id,
image: args.image,
profileImage: user.profileImage,
description: args.description,
author: user.name,
likes: 0,
likeIds: [],
});

return id;
},
});
export const createPost = internalMutation({
args: {
title: v.string(),
userId: v.id("users"),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
likes: v.number(),
likeIds: v.array(v.string()),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const user = await ctx.db.get(args.userId);

if (!user) {
throw new ConvexError("User not found.");
}

const id = await ctx.db.insert("posts", {
title: args.title,
userId: user._id,
image: args.image,
profileImage: user.profileImage,
description: args.description,
author: user.name,
likes: 0,
likeIds: [],
});

return id;
},
});
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
First time doing something like this so, sorry if it's obvious to make
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
@ian Or would this still be incorrect if you know
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string())
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags
}
);

return postId;
},
});
export const createPostAction = authAction({
args: {
title: v.string(),
image: v.string(),
description: v.string(),
tags: v.array(v.string())
},
handler: async (ctx, args) => {
const postId: Id<"posts"> = await ctx.runMutation(
internal.posts.createPost,
{
image: args.image,
title: args.title,
description: args.description,
userId: ctx.user._id,
likes: 0,
likeIds: [],
tags: args.tags
}
);

return postId;
},
});
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
Alright , so something like this ?
posts: defineTable({
title: v.string(),
userId: v.string(),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
author: v.optional(v.string()),
likes: v.number(),
likeIds: v.optional(v.array(v.string())),
tags: v.array(v.string()),
}),
postTags: defineTable({
postId: v.id('posts'),
tagId: v.id('tags'),
}).index('postId_tags', ['postId', 'tagId']),
posts: defineTable({
title: v.string(),
userId: v.string(),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
author: v.optional(v.string()),
likes: v.number(),
likeIds: v.optional(v.array(v.string())),
tags: v.array(v.string()),
}),
postTags: defineTable({
postId: v.id('posts'),
tagId: v.id('tags'),
}).index('postId_tags', ['postId', 'tagId']),
export const createPost = internalMutation({
args: {
title: v.string(),
userId: v.id("users"),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
likes: v.number(),
likeIds: v.array(v.string()),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const user = await ctx.db.get(args.userId);

if (!user) {
throw new ConvexError("User not found.");
}

const id = await ctx.db.insert("posts", {
title: args.title,
userId: user._id,
image: args.image,
profileImage: user.profileImage,
description: args.description,
author: user.name,
likes: 0,
likeIds: [],
tags: args.tags,
});

return id;
},
});
export const createPost = internalMutation({
args: {
title: v.string(),
userId: v.id("users"),
image: v.string(),
profileImage: v.optional(v.string()),
description: v.string(),
likes: v.number(),
likeIds: v.array(v.string()),
tags: v.array(v.string()),
},
handler: async (ctx, args) => {
const user = await ctx.db.get(args.userId);

if (!user) {
throw new ConvexError("User not found.");
}

const id = await ctx.db.insert("posts", {
title: args.title,
userId: user._id,
image: args.image,
profileImage: user.profileImage,
description: args.description,
author: user.name,
likes: 0,
likeIds: [],
tags: args.tags,
});

return id;
},
});
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/13/2024 in #support-community
Adding tags
Result from console
console.log("Tag Name:", tagName);
console.log("Params:", params);
console.log("Blogs:", blogs);
Tag Name: typescript
page.tsx:22 Params: {tagName: 'typescript'}
page.tsx:35 Blogs: []
console.log("Tag Name:", tagName);
console.log("Params:", params);
console.log("Blogs:", blogs);
Tag Name: typescript
page.tsx:22 Params: {tagName: 'typescript'}
page.tsx:35 Blogs: []
27 replies
CCConvex Community
Created by Hārūn | هارون on 2/4/2024 in #support-community
Weird bugs
Well, now I'm aware of this stuff and how easy it is for it to happen, thanks a lot for the help Tom!
19 replies
CCConvex Community
Created by Hārūn | هارون on 2/4/2024 in #support-community
Weird bugs
I highly appreciate the time you took to respond even though this was just a dumb mistake on my end
19 replies
CCConvex Community
Created by Hārūn | هارون on 2/4/2024 in #support-community
Weird bugs
No description
19 replies
CCConvex Community
Created by Hārūn | هارون on 2/4/2024 in #support-community
Weird bugs
If that's the bug I feel so stupid that I didn't catch it
19 replies
CCConvex Community
Created by Hārūn | هارون on 2/4/2024 in #support-community
Weird bugs
I'm gonna try it out tomorrow but from the looks of it it looks like that's the bug
19 replies