shell
shell8mo ago

https://docs.convex.dev/quickstart/

https://docs.convex.dev/quickstart/nodejs how do i streamline data to my database with nodejs it looks here like they are just showing how to get data right?
9 Replies
Michal Srb
Michal Srb8mo ago
If you need something else let us know more details: What is the problem you're trying to solve? Including relevant details.
shell
shellOP8mo ago
just trying to insert data from my api into my convex db
Michal Srb
Michal Srb8mo ago
Ah. The client from the Node.js quickstart has a mutation method, which lets you call your mutations: https://docs.convex.dev/functions/mutation-functions
Mutations | Convex Developer Hub
Mutations insert, update and remove data from the database, check authentication
shell
shellOP8mo ago
No description
shell
shellOP8mo ago
am I on the right track here using an action?
Michal Srb
Michal Srb8mo ago
Not really. I recommend going through the tutorial to understand what is where. In this case it looks like you're putting the action definition (which belongs in your convex/ folder and will be executed by your Convex backend) into your "client" code (in this case, a Node.js server). https://docs.convex.dev/get-started Your Node.js code should be using the ConvexHTTPClient to call actions/mutations/queries, and your Convex code should be separate and define the actions/mutations/queries.
Welcome to Convex | Convex Developer Hub
Convex is a novel, fun, and extremely productive way to make backends for your
shell
shellOP8mo ago
does it have to be in that convex folder though? cause its using typescript and im using nodejs why is it so complex why cant i just write to the db? i dont see in the docs where it mentions nodejs its all just react references
Michal Srb
Michal Srb8mo ago
In the quickstart, there is a step for setting up a query, and then the query is called from Node.js. Indeed in Convex you cannot "just write to the db", you have to define mutations that write to the DB. This lets you define what (and who) can and cannot write to the DB. Most people don't use Node.js once they adopt Convex, although I can see that you're using custom websockets, so that might necessitate using Node.js - it depends on where those websocket messages are coming from. If you have a website that talks to your Node.js server, you can probably replace Node.js entirely with Convex.

Did you find this page helpful?