Sara
Sara4mo ago

Is there an option to use another

Is there an option to use another database provider like postgres but with convex functions?
2 Replies
Hmza
Hmza4mo ago
While its not natively supported to do that (yet) convex is just functions on top of serverless architecture so it is a possibility in future. but just for fun of it you can use postgres listen/notify https://www.postgresql.org/docs/current/sql-listen.html using convex node.js runtime https://docs.convex.dev/functions/runtimes#nodejs-runtime you can write listeners for changes in data on postgres and catch them in convex actions. (it'll be short lived listener though because convex actions are short lived and doesn't run a loop forever). scheduling the actions also not work because there'll be a time gap in execution of actions. like;
const pgClient = new Client({});

pgClient.query('LISTEN anychanges');

//inside convex action
export default action({
pgClient.on('notification', async (x) => {
console.log('recieved', x.payload);
//timeout (this is a possible problem)
});
})
const pgClient = new Client({});

pgClient.query('LISTEN anychanges');

//inside convex action
export default action({
pgClient.on('notification', async (x) => {
console.log('recieved', x.payload);
//timeout (this is a possible problem)
});
})
other option is obviously directly running queries using pg client. but that'll come up with latency issues. would you mind opening a thread in #support-community so team/community can catch on later. this is interesting!
PostgreSQL Documentation
LISTEN
LISTEN LISTEN — listen for a notification Synopsis LISTEN channel Description LISTEN registers the current session as a listener on …
Runtimes | Convex Developer Hub
Convex functions can run in two runtimes:
Sara
SaraOP4mo ago
Thanks! I still need the majority of the convex functions so I'll stick with that for now, but thanks for the information! I might do some example runs

Did you find this page helpful?