patochem
patochem
CCConvex Community
Created by patochem on 11/10/2023 in #support-community
Problems using useQuery inside a Context
Yep, that's what is happening... I don't have anything to do Looks like magic actually! Thanks @Michal Srb !
8 replies
CCConvex Community
Created by patochem on 11/10/2023 in #support-community
Problems using useQuery inside a Context
could you give an quick example of the first option, please?
8 replies
CCConvex Community
Created by patochem on 11/10/2023 in #support-community
Problems using useQuery inside a Context
Thanks for answering @StoicWanderer This was my first thought but it doesn't work because you can't use "useQuery" inside useEffect, since it's a hook React Hook "useQuery" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.eslintreact-hooks/rules-of-hooks
8 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
Thanks a lot again for the support! I'll make sure to publish my app in #show-and-tell when it's done and spread the word about Convex!
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
oh, alright.. So I guess I'm safe since I'm building this project on my own👍
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
Great!! What do you mean by "early projects"?
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
yep, that's what I'll do! Thanks a million!
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
That's absolutely awesome since those rows will never change!
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
-------------------------------------- For example, in my current project, I have a 'modules' table of hundreds of rows. Each 'module' can be made of another module or raw material. So I need another table called "requirements" that maps each module with its components. So each time I want to display a list of modules with all the raw materials involved in its construction, I have to recursively call on those 2 tables until I parse the whole tree of components. If I rely exclusively on cloud functions, this computational and bandwidth cost could escalate pretty fast, because of the recursive nature of app So my guess is that I should find some kind of "caching" mechanism for that.
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
I'm still prototyping so I'm not sure it's the best way... As soon as I take a decision, I'll let you know. As a side note and as a long time user of Firestore, I know how quick you can reach the monthly limits for functions call and/or bandwidth when you work with large databases. That said, Convex prices look way cheaper than firestore and this shouldn't be an issue
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
Also, @ballingt Mentioned that you might have an example on how to combine Convex and Redux. That would be of great help too!
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
ok. I'll check it out. Thanks a lot
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
Any update on this one, please?
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
As for the state management, I am not sure yet. I was considering zustand (https://github.com/pmndrs/zustand)
But if you have an example with another one, I'm interested in checking it out!
25 replies
CCConvex Community
Created by patochem on 11/8/2023 in #support-community
How do I get a jwtToken from outside React
Auth Provider: I'm using Clerk, through a Provider, as you say. This is the code:
import { ClerkProvider, useAuth } from '@clerk/clerk-react';
import { ConvexReactClient } from 'convex/react';
import { ConvexProviderWithClerk } from 'convex/react-clerk';
import { ReactNode } from 'react';

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export const ConvexClientProvider = ({ children }: { children: ReactNode }) => {
return (
<ClerkProvider
publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!}
>
<ConvexProviderWithClerk useAuth={useAuth} client={convex}>
{children}
</ConvexProviderWithClerk>
</ClerkProvider>
);
};
import { ClerkProvider, useAuth } from '@clerk/clerk-react';
import { ConvexReactClient } from 'convex/react';
import { ConvexProviderWithClerk } from 'convex/react-clerk';
import { ReactNode } from 'react';

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export const ConvexClientProvider = ({ children }: { children: ReactNode }) => {
return (
<ClerkProvider
publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!}
>
<ConvexProviderWithClerk useAuth={useAuth} client={convex}>
{children}
</ConvexProviderWithClerk>
</ClerkProvider>
);
};
25 replies
CCConvex Community
Created by patochem on 11/3/2023 in #support-community
Can't import ID when using cli import feature
I already have that. Those id fields are the actual id of the MySql database. But what I wanted is to use the convex native Reference field to simulate a PK/FK relationship
19 replies
CCConvex Community
Created by patochem on 11/3/2023 in #support-community
Can't import ID when using cli import feature
sure. I'm still prototyping the app so the whole data model is not completely defined yet. That's the reason why I had to export a table from convex, add some fields and fill the values from other tables/data I have somewhere else. I could try to do all this programmatically but, working with sql is so much easier nad faster
19 replies
CCConvex Community
Created by patochem on 11/3/2023 in #support-community
Can't import ID when using cli import feature
This issue is the following: I'm importing the data from an existing mySQL database where there are several tables "linked" together by PK/FK relationships I wanted to take advantage of the v.id('tableName') feature of convex to maintain those relationship. Let's imagine the following:
const ObjectSchema = {
name: v.string(),
....
}

const PieceSchema = {
name: v.string(),
....
}

const ObjectPiecesSchema = {
text: v.string(),
objectId: v.id('objects'),
pieceId: v.id('pieces')
}

export default defineScema( {
pieces: defineTable(PieceSchema),
objects: defineTable(ObjectSchema),
objectsPieces: defineTable(ObjectPiecesSchema)
})
const ObjectSchema = {
name: v.string(),
....
}

const PieceSchema = {
name: v.string(),
....
}

const ObjectPiecesSchema = {
text: v.string(),
objectId: v.id('objects'),
pieceId: v.id('pieces')
}

export default defineScema( {
pieces: defineTable(PieceSchema),
objects: defineTable(ObjectSchema),
objectsPieces: defineTable(ObjectPiecesSchema)
})
So in order to 'migrate' my db, I have to: - import the 'pieces' to convex (without Id) - import the 'objects' to convex (without Id) - export the 'pieces' and 'objects' tables with autogenerated id - update the pieceId field of the "objectsPieces" table in my database, with the autogenerated Id, to maintain the relationship - Do the same with the ObjectId - export the 'objectsPieces' table to json - import this json to convex. So far so good. However, now I need to change some fields and values in the convex 'pieces' table. So I - export the table to json - import this json to my MySQL database - work the data in MySQL - export the data back to a json file to import again in convex. I can't let convex re-generate the _id field because then it would break the relationship in the "objectsPieces" convex table. Can I solve this using the CLI?
19 replies
CCConvex Community
Created by patochem on 11/3/2023 in #support-community
Can't import ID when using cli import feature
{
"_id" : "4m04b2em2dp8ynmntab6cz929k4m528",
"id" : 1198,
"level" : 2,
"name" : "SXXXXXXXXX",
"type" : "xxxxxxx",
"url" : "https://xxxxxxxxxxx",
"resource_id" : null
},
{
"_id" : "4m04b2em2dp8ynmntab6cz929k4m528",
"id" : 1198,
"level" : 2,
"name" : "SXXXXXXXXX",
"type" : "xxxxxxx",
"url" : "https://xxxxxxxxxxx",
"resource_id" : null
},
19 replies