Meteor.js and Mongoose Compatibility - mongodb

I want to use the Mongoose ORM with meteor mainly on the server side until meteor releases a schema approach.
Can i call Mongoose ORM operations within Meteor methods and publish using the Mongoose retrieving methods likefindById.
Are there any potential problems or meteor features that i would miss out on if i approached things this way?

Unfortunately, there are problems. We've wanted to do the same thing, but (out of the box) the mongoose package doesn't use Meteor's DDP protocol, and won't trigger the reactivity when you do CRUD operations. There may be also issues with Fibers/etc, although we haven't pushed with Mongoose enough to find them.
The good news is that (server-side) Meteor watches the db for any changes, DDP-induced or not, and will pick them up in about 10-seconds or so. It will then publish them to the clients, which will pick them up in standard meteor format.
We've been looking for a mongoose-ddp-meteor package to solve this issue, and might have to end up building one ourselves.
EDIT:
As of December 2013, Meteor's Mongo package listens to Mongo's oplog, and will reflect any changes done by external mongoose activity in real-time.

Related

Managing database validations in MERN stack

I'm coming from a Rails background and am trying out building a simple web app with the MERN stack.
With Rails, I had a simple way to manage database-level validations: I would create a migration and set up the schema with validations, then run the migration. Moving to a production environment or after dropping the database, I could just run the same migration.
With MongoDB, I know how to create database-level validations in the mongo console, but not how to manage the validations for reuse later.
What are the best practices for managing database level validations with MongoDB (specific solutions for MERN are fine, though general solutions for just Mongo are fine too? Even better, is there a way to manage up/down validations in case I ever want to change something to a required field later in development but don't want to redo all of the validations from scratch?
Thanks in advance!
As we know that mongo is schema less, so we have to implement data validation in the application itself.
There is a well known npm package called mongoose which serves all these feature and also implements schema at application level.

Using Sails.js with AWS DynamoDB....not ideal

I started working on a small POC and decided to give Sails.js a try :)
Part of the POC we wanted to use DynamoDB since the project will eventually involve high scalability and we're not looking to hire full-time MongoDB expert at this point.
We used the module: https://github.com/gadelkareem/sails-dynamodb
Problem is there is no documentation and the module does not even work...
It seems the sails ORM is not ideal for DynamoDB and requires writing custom DB services. Does anyone have experience with this?
I was very excited to come across Sails but if it won't let us play nice with DynamoDB then it might very well be out as an option to us....
Anyone have experience with this or maybe something I'm missing?
One of the important plus of vogels is excellent documentation.
Sails-dynamodb adapter based on the vogels, but not all features are implemented in sails-dynamodb adapter. For example, vogels has Expression Filters.
Vogels able to create tables. Adapter can't. An adapter needs duplication table schema in sails files and dynamodb shell.
Vogels has some own types, such as uuid type, StringSet, NumberSet, TimeUUID. (Adapter can use it too, if includes Vogels and Joi lib)
Vogels and adapter have the same query (create, update, delete, find) capabilities.
Adapter allows without changing the code switch to another data base. Adapter encapsulates establishment of connection to database.
Conclusion - for most purposes this adapter is suitable for the work and do not need to work directly with the Vogels
Sails comes loaded with an ORM called "Waterline". There are some official waterline plugins such as mongodb, postgresql, mysql and then there are some unofficial ones created by the community. I'd assume right now that Dynamo is in the latter category since I have not come across it before. However, with that being said I would not take this experience as a reason to ditch Sails.js.
Sails.js is built with the intention that all of its components can be swapped out, this means you are not tied to a specific template engine, authentication libraries etc. and including your ORM choice.
Waterline is still being actively developed but it is sat at v0.12.1 as of writing this response. It isn't fully there yet so there will be the odd issues still around!
My recommendation? Take a look at swapping out waterline for a different ORM. Keep the flexibility Sails gives you and change out the component that doesn't meet your criteria. There are still many benefits to Sails you can utilise.
Vogels might be worth checking out: https://github.com/ryanfitz/vogels
Turning off waterline: Is there a way to disable waterline and use a different ORM in sails.js?

Does mongoose still have reactivity issues with meteor?

I want to use mongoose in my meteor app for validation and also because I am quite comfortable with it coming from Node background. I read at multiple places that using mongoose gives 10 sec delay in comparison to using Meteor's in-built Mongo driver. But on this question (Meteor.js and Mongoose Compatibility), it says
EDIT: As of December 2013, Meteor's Mongo package listens to Mongo's
oplog, and will reflect any changes done by external mongoose activity
in real-time.
Is it true that reactivity issues with mongoose has been solved? If not, is there any other package I can use? Thanks
I can't find article on Meteor blog, but yes, there is no more problem with reactivity, changes are pushed on instant, not after 10 seconds.
I would recommend that you look at aldeed:simple-schema and possibly even aldeed:collection2 and aldeed:autoform. Their functionality is not a direct overlap, but they give you similar schema validation capability as mongoose.

PouchDB/CouchDB like alternative for MongoDB

I'm amazed by the sync capabilities of Pouch and Couch DB, but I'm looking for for an alternative that will let me use my MongoDB databases for client-sync. Is there such thing?
If there is, I'd like to hear your experience with it, what should I be aware of, if there are any catches, etc...
Minimongo is specifically what you are looking for. It was originally developed as part of the excellent Meteor framework, but it can now be used independently to get the local db store and synchronization with a remote db, all using Mongo api.

How to use Mongoose in Meteor?

I've looked at the answer posted here: Meteor: integration with Mongoose?, but I'm looking for a simpler, more modular solution if possible for using Mongoose with Meteor.js.
Is there a better way that I should be handling ODM or native support I haven't seen?
I've decided to just use the Collection2 package because it seems to offer everything that I wanted from Mongoose as an ORM. This packages uses the Simple Schema as a dependency.
Meteor already talks to mongodb. But you can use mongoose. You might have an issue with a 10 second delay with reactivity. Also you won't be able to enjoy using it on the client.
Meteor already has methods to query/update,etc mongodb. But if want you could force mongoose in:
Install mongoose (npm install mongoose). And use it in your meteor code:
require = __meteor_bootstrap__.require; //to use npm require must be exposed.
var mongoose = require('mongoose');