Domanda

I'm trying to make some reports using meteor and raphael js. I have to report data from an existing MySQL database. I do not wish to write to that database. I need only the "R" from CRUD. I have thought of various manual ways of: exporting .csv files from the MySQL db via the application itself (Limesurvey) and using mongoimport to populate a MongoDB collection, and then do my CollectionName.find() etc in Meteor. or perhaps some way of exposing REST full endpoints only to consume data, and use the http package for Meteor.

Is there a good clean solution for using existing SQL data in a Meteor JS application? How can one use pre-existing SQL data?

(I've no problem with duplication in MongoDB, mind you. however it has to be...) Thank You

È stato utile?

Soluzione

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:

  1. Using `meteor-sync-methods
  2. Spinning out your own version from advice from the issue to allow this natively
  3. Use this easy to implement one-time pattern: "fence has already activated -- too late to add writes"

Hope that helps.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top