Can we use Meteor framework with mysql database

后端 未结 4 984
我寻月下人不归
我寻月下人不归 2021-01-13 15:59

I found many refer url for Meteor framework where i found mongodb as database, since i don\'t have much knowledge in mongodb. So is there any way to implement mysql instead

相关标签:
4条回答
  • 2021-01-13 16:52

    There is maybe a way to do that but it's tricky :

    Install a Mysql driver from npm Then You can choose to use MongoDb as a first front-end or Meteor Streams from Arunoda. Then You just have to use the deny/allow system from Meteor.Collections to bind insert/update/remove from client side to Mysql You should also use the publish system to query Mysql database and return data to the client.

    The last problem is about server database observing : if something change in Mysql, it won't alert all other client, except maybe with Meteor.Streams. That could be rather fun to implement.

    0 讨论(0)
  • 2021-01-13 16:58

    From the documentation:

    Today most Meteor apps use MongoDB as their database because it is the best supported, though support for other databases is coming in the future. The Meteor.Collection class is used to declare Mongo collections and to manipulate them. Thanks to minimongo, Meteor's client-side Mongo emulator, Meteor.Collection can be used from both client and server code.

    As the client side uses minimongo, using a RDBMS may not provide the best fit (as the query language and data structures are very different).

    You might be interested in something like breeze.js which comes at the problem of rich data synchronization services from a different direction, but it fits relational databases.

    0 讨论(0)
  • 2021-01-13 16:59

    There is a way, but at the stage the framework is right now it's an unpaved road. Basically, you'd need to write a wrapper that would translate from SQL to Meteor's Minimongo and back. It's not a feasible task if you're not a Meteor and Mongo master already.

    There were attempts to write such adapter. The most advanced I know is this: https://github.com/drorm/meteor-sql . It's possible to use to play around, but I don't think it's production ready. Also, there is currently no way to use Meteor account system with anything other than Mongo. You either need to use it anyway for user accounts, or give up a great convenience they provide.

    I'd advice you to try Meteor as it currently is, together with Mongo - it's easier than you think. It doesn't add too much learning curve, and besides filter and update operators you won't notice that you use some strange db at all - it's just like working with native Javascript objects. There's no schema, no migrations, no object mapping needed. You just take data, put it in a collection and forget all the rest that SQL made you think about.

    0 讨论(0)
  • 2021-01-13 17:00

    You can take a look at this meteor package nodets:mysql . Use mysql at the server and at the client all subscriptions are updated every time db changes.

    0 讨论(0)
提交回复
热议问题