Isomorphic library, which allows you to use Mongoose.js models via socket.io-rpc doing regular queries and liveQueries
isomorphic client side library and server framework, which brings Mongoose model to the browser(or over the network to other node process). Based on socket.io-rpc. Framework agnostic-usable with anything-let it be Angular, Aurelia, React or any other.
Probably the coolest feature is live queries. These are performance hungry, but Moonridge is caching live queries in memory, so that one query is being live checked only once. If 10000 users run the same query, the DB performance performs the same amount of operations as if one user was accessing it. So your DB should be under the same load no matter how many people use your web app(presuming they are not writing into the DB).
npm i moonridge -S
Serverside API is quite straightforward, if still not sufficent, read source code of examples.
var MR =MR //MongoDB address is optional-you can connect as always with mongoosevar mongoose = MRmongoosevar bookModel = MR...var app =var server =//bookModel is an extended mongoose model, so if you know how to work with mongoose models, you'll be right at homeMRapp // gives your REST api for your DB in case you need it alongside to socket.io APIserver
var Moonridge =//Moonridge backendvar mr =var fighterModel = mr//live queryvar LQ = fighterModelLQpromise;//create a new entityfighterModel;
Also you need to connect to your backend-just pass a simple object with url property like HERE.
The whole client side api for queries shadows the Mongoose query API.
All server-client communication is done with socket.io-rpc-another project of mine, so errors are propagated for all server-side calls which return an error(or reject their promise). This is especially helpful with schema validation errors, where backend tells the frontend exactly what failed.
Internet Explorer 8+ - though it needs es5shim Safari 4+ Google Chrome 4+ Firefox 4+ Opera 10.61+
iPhone Safari iPad Safari Android WebKit WebOs WebKit
One could ask why not just port mongoosejs to the client side and let clients talk to mongo directly. While this would surely be an interesting project, Moonridge has features which would not be possible without a server instance(live querying, custom authorization/authentication). I think these features are worth it introducing a new framework to the backend.
Every client liveQuery is serialized and sent via socket.io to backend. Backend parses it and constructs real mongoose query, which is immediately run(if it doesn't exist already in server memory). The return is sent back to client. Any change to a certain document (creation, deletion, update) is checked again for all in-memory queries. MongoDB checks just one recently changed document, not the whole query, so it should be pretty quick. If query is satisfied, the changed document is propagated to listening clients. And that is basically it.
Yes I know and if you need joins, you better look for something else. Moonridge is tailored for web apps which do a lot of small and custom queries. Basically you would want to save any bit of bandwith and show pieces of data in your app as soon as possible, you are best served using Moonridge.
I have few production apps running on moonrige, feel free to take a peek how moonridge is used: