An early look at SQL in Meteor

Great news! Finally the dreams of using meteor and normal sql databases are becoming true.

Thank you, @sashko. Please, keep developing this project so we can see it in the docs in the near future. :wink:

3 Likes

I have no doubt this will increase the Meteor adoption. At least I will be able to play more times the Meteor card when designing a new app :smile:

1 Like

I agree: this is sure to increase Meteor adoption, if and when it is ready for prime time.

wondering how reactivity works with Postgres… is it polling or what?

From the code it looks like it uses both triggers and poll & diff:

Hiyas, I’d like to share my experiences using Meteor with MySQL.

One of my companies is using Ben Green’s numtel:mysql package, which provides reactive support in Meteor for MySQL. It relies on the MySQL binary log (using row mode) as the event source - similar to how the oplog is used with MongoDB.

We are running it in a production system used for real-time location tracking. We recently submitted some improved code which dramatically increased its performance and Ben has incorporated it into the latest release.

We chose MySQL over PostgreSQL for two reasons:

*We already had a LEMP-based ecosystem for our other apps and use MySQL slave-replication.

*We are using the TokuDB storage engine, which is not supported by PostgreSQL.

TokuDB is a fantastic piece of technology that has improved our database performance because of its more efficient fractal tree data structure. It has reduced our storage requirements thanks to its support for table compression and it has allowed easier maintenance by supporting online schema and index changes.

TokuDB is only officially supported with the MySQL forks Percona Server and MariaDB. Only Percona Server is compatible with Meteor because the current stable version of MariaDB (10.0) does not record the precision of datetime/timestamp fields in its binary log, but this will be fixed in MariaDB 10.1.

I strongly encourage the MDG to implement official Meteor support for MySQL based on Ben Green’s package.

At the moment, there is no “minisql” equivalent of “minimongo” so we sometimes use Mongo.Collections in memory as temporary storage, e.g. where the option “connection:null” is set.

However, I just did some googling and found sql.js - a port of sqlite to JavaScript - https://github.com/kripken/sql.js/ - I wonder if this could form the basis of a “minisql” for Meteor.

Also, the current official Meteor accounts packages are directly coupled with MongoDB, so we’ve had to develop our own accounts system.

It would be great if the official accounts-base code could be tweaked to allow users to add handlers to intercept/override the bits of code that initialize and access the Mongo.Collection “users”.

5 Likes

The comment says: “Note that the client-side stub is synchronous, so there is no need for a transaction”

I’m just referring to the method simulation. Clearly the server-side SQL calls will need transactions. We already have the implementation, just need to document it: https://github.com/meteor/postgres-packages/blob/c91c47d53cb8c8566a6e2c704add3cc653690fc4/packages/accounts-base-pg-driver/accounts-base-pg-driver.js#L78-L87

@tsamatech this should work fine on Windows, we just don’t have documentation for how to install PostgreSQL there. Have you tried it?

@jononomo you should be able to connect to Mongo and Postgres at the same time, if you pass both MONGO_URL and POSTGRESQL_URL and add the mongo and pg packages. Let me know if you get around to trying it!

@vchigne you mentioned AlaSql - what benefits would developers get if we supported it? I feel like shipping a whole SQL implementation to the client would have to bring a lot to be worth it (the Knex over Minimongo implementation is very light)

@vlasky implementing MySQL shouldn’t be too hard - there is only a little PostgreSQL-specific code. Hopefully we can build a proof of concept soon.

Thanks for all of the feedback so far!

1 Like

Wondering if -with the the coice for knex, which does not support it as far as I can see- MS SQL is out of scope? I think meteor would gain al lot by focussing on MS SQL (lots of users).

11/10, would meteor again

2 Likes

Yeah although I think it’s a much smaller step to just add support to Knex for MS SQL. This is still on the path to that eventual future.

If you would like to talk more about MSSQL support, send me an email. (ben@latenightsketches.com) While working on the Postgres live select package, I did research into MSSQL and it’s definitely possible.

Have you looked into this web/javascript based SQL engine by Google, pretty relevant

1 Like

nice work. I extended the work for Apache couchDB - https://github.com/mariobriggs/meteor-accounts-couchdb/

I’m using alasql as a client only persistent storage and it provides a very fast and small local database engine, with almost full SQL DML and DDL capacity.

I just finished reading “Your First Meteor Application” and want to use PostgreSQL.

The document http://meteor-postgres.readthedocs.org/en/latest/ is good but I find it hard to follow

The use of additional packages (React, Router, etc). As I do not see any require(...) it was hard to find out which meteor packages are used as there are too many packages with the same name.

If there is a similar book “Your First Meteor Application with PostgreSQL” it would be great.

Any news regarding this feature? Cheers.

This project is not actively worked on right now, but we respond to all PRs pretty quickly. Take a look yourself: https://github.com/meteor/postgres-packages/pulls?utf8=✓&q=is%3Apr+

1 Like

Meteor’s github project looks like abandonware. @numtel, would you say that we can use your PG package in production?

Yep - the Meteor Postgres experiment was never intended to be a production-level fully maintained project. It says that in several places on the repo. But I think some of the ideas are good, and could be integrated into packages such as @numtel’s.

1 Like

@sashko, Meteor is so good that we are trying to find workable solutions to one of the most important parts of the framework, Database access. I don´t know if you have tried, but there is no serious way to develop a Line of Business app using MongoDB.The fact that we are trying to use it instead of something like sails.js despite the lack of interest of the MDG about this feature is a good indicator of how good are the other parts of Meteor.I hope this changes soon.Regards