stevanfreeborn
stevanfreeborn
CCConvex Community
Created by stevanfreeborn on 9/17/2023 in #show-and-tell
conve-X
You guys have something real cool in Convex!
3 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
Oh no worries at all. I really appreciate you guys being so willing to help me especially on a Saturday morning. I think I'm all square now for what I need to accomplish. 🙏
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
Which does seem to work in other filter expressions okay.
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
And I was going based off this statement on this page of the docs:
To filter to documents that are missing a field, use q.eq("fieldName", undefined).
To filter to documents that are missing a field, use q.eq("fieldName", undefined).
https://docs.convex.dev/text-search#equality-expressions
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
Yeah exactly basically I have posts that can also potentially be replies to other posts based on whether they have a parent or not. When I'm searching I just want to consider posts that are truly just parents only.
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
I'm for now just going with a filter() call after the withSearchIndex call and that seems to be working, but I think if I could do that filtering within the search it might be more performant. Is undefined as an argument not supported within that method?
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
If I pass an empty string to the eq() call instead of undefined the error also does not get thrown.
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
And when I remove the .eq() call the error stops being thrown.
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
Which is what I expect
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
So I console logged args in the query and I get this:
[CONVEX Q(posts.js:getPostsBySearchTerm)] [LOG] {
paginationOpts: {
cursor: null,
id: 2,
numItems: 10
},
term: 'Hello'
}
[CONVEX Q(posts.js:getPostsBySearchTerm)] [LOG] {
paginationOpts: {
cursor: null,
id: 2,
numItems: 10
},
term: 'Hello'
}
19 replies
CCConvex Community
Created by stevanfreeborn on 9/16/2023 in #support-community
Help Debugging
Okay sounds good. I tried console logging args last night and saw the term which is what made me confused. I’ll try again fresh this morning and give ‘er another go.
19 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Select or Project Method
Oh that is way cleaner. Okay perfect. Thank you both so much!
8 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Select or Project Method
const posts: PaginationResult<{ _creationTime: number}> = await ctx.db
.query('posts')
.withIndex('by_user_id', q => q.eq('userId', args.userId))
.order('desc')
.paginate(args.paginationOpts);

posts.page = posts.page.map(({ _creationTime }) => ({ _creationTime }));
return posts;
const posts: PaginationResult<{ _creationTime: number}> = await ctx.db
.query('posts')
.withIndex('by_user_id', q => q.eq('userId', args.userId))
.order('desc')
.paginate(args.paginationOpts);

posts.page = posts.page.map(({ _creationTime }) => ({ _creationTime }));
return posts;
8 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Select or Project Method
Or do you just type the page like this?
8 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Select or Project Method
@ballingt how do you go about replacing the page though? The page is typed to the documents I queryed. If I want to map over them and just return a subset of fields and then replace the page with this array of objects it won't statisfy the expected type of the page.
export const getUsersPostById = query({
args: { userId: v.id('users'), paginationOpts: paginationOptsValidator },
handler: async (ctx, args) => {
const posts = await ctx.db
.query('posts')
.withIndex('by_user_id', q => q.eq('userId', args.userId))
.order('desc')
.paginate(args.paginationOpts);

posts.page = posts.page.map(({ _id }) => _id);
return posts;
},
});
export const getUsersPostById = query({
args: { userId: v.id('users'), paginationOpts: paginationOptsValidator },
handler: async (ctx, args) => {
const posts = await ctx.db
.query('posts')
.withIndex('by_user_id', q => q.eq('userId', args.userId))
.order('desc')
.paginate(args.paginationOpts);

posts.page = posts.page.map(({ _id }) => _id);
return posts;
},
});
8 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Joining and Paging
@sshader thank you! I didn't realize that you could actually work with the page of results before returning the page. I think I can do what I want if I can figure that out. If not I'll come back with some concrete examples of what is not working for me. Really appreciate you helping me 🙏🏻
3 replies
CCConvex Community
Created by stevanfreeborn on 9/11/2023 in #support-community
Select or Project Method
Oh I didn't know that. I'll explore that some.
8 replies
CCConvex Community
Created by stevanfreeborn on 9/10/2023 in #support-community
Mutating Arrays
Okay good deal. Thank you helping me 🙏🏻
3 replies
CCConvex Community
Created by stevanfreeborn on 9/9/2023 in #support-community
Collaborative Editing Experience
I’m not. This is really my first experience trying to implement something like this. I built a small prototype using socket.io just to try and grok the overall idea and pattern. I’m trying to use codemirror as my editor so I’ll dig into that prosemirror poc and see if I can’t take inspiration from that. From the thread you shared it sounds like this is very much though a use case convex can support.
7 replies
CCConvex Community
Created by stevanfreeborn on 9/9/2023 in #support-community
How to call public query from action?
Okay I’ll try that. Thank you!
7 replies