You can do it without any duplication completely from inside Meteor, but you will have to jump through a couple of hoops.
Firstly, use the mysql
npm package to query the SQL database. Though Meteor provides Npm
to require
node packages, I find that using meteor-npm
is an easier. Then to do the "R"eading form MySQL, create a Meteor.method
on your server which queries the MySQL directly.
Then the second problem is that the mysql
package is completely asynchronous. Hence, the execution of the SQL query returns value in a call back and by that point, your Meteor.method
call would return leaving the client with an undefined.
To fix that issue, we can use Future
.
There are a couple of ways of smoothing over this step:
- Using `meteor-sync-methods
- Spinning out your own version from advice from the issue to allow this natively
- Use this easy to implement one-time pattern: "fence has already activated -- too late to add writes"
Hope that helps.