Can we use Meteor framework with mysql database

做~自己de王妃 提交于 2020-01-11 06:01:23

问题


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 of mongodb


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/19269075/can-we-use-meteor-framework-with-mysql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!