Is it possible or will it be possible to use MongoDB with Adonis?
What’s stopping you from using it?
Well, i can’t find anything about MongoDB in the docs and i guess there is a reason?
Well, AdonisJs doesn’t support it out of the box, that’s why. But nothing is stopping you from using Mongoose or any other MongoDb ORM.
Just like express, they don’t talk about MongoDb in their docs, but you can still use it
What is your opinion on using nonsql ?
I cant help getting influenced by the Mongo hype.
Almost everywhere in Node projects MongoDB is used and I wondered why it’s not used in Adonis?
IMO Mongo is a bit hyped. Theres nothng special about it as many programs/apps and sites are built not using it but relational databases (although I do like it for some projects). It also, not being “relational” has some downsides (which generally can be worked around). Apparently its not too easy building ORMs that accomodate both sql and nonsql (judging by the frameworks I have used that lack one or the other despite users clamouring for options).
Adonis gets a lot of its conventions and inspiration from Laravel which also does not talk much about Mongo (more Postgres and mysql). Still as Virk suggested Adonis and Node are modular enough you can hook up Mongoose. Personally the fact I am not locked into Mongo is a selling point for Adonis to me.
Great answer, i will drop the Mongo thoughts a once
As @MichaelMarks mongodb is over hyped
I have never seen any production grade app using Mongodb as the primary database
NoSQL has its place, and you should only reach for it when you need it.
Majority of people try to start with it, coz its the cool thing
I never built an ORM for it coz I am not an expert with NoSQL, so it doesn’t makes much sense for me to spend time on it
“Great answer, i will drop the Mongo thoughts a once”
didn’t mean you should, Adonis is based on node and one of the benefits is you can use a great deal in that node ecosystem including mongo . Thats what Virk I think was saying - its just that its not supported within the framework. So you will lose some of the cohesiveness but its not like you have to say - I use Adonis so cannot ever use mongo. people are using both though I know NOTHING of the stability/viability of their workarounds and Virk could more speak to that
Mongo can be cool and easy to work with in the beginning but I just found as things change in my data layer due to user feedback and expansion of ideas it became cumbersome and there was really nothing I could do with Mongo I couldn’t do with any SQL product.
By the way the universal love for mongo really isn’t universal. Google “mongodb (or mongo) sucks” and you’ll get a lot of opposing opinions.
Well, i feel confident using MariaDB so i will gladly continue to use it.
My concern was as i’m new to Node.js that i were doing a misstake not going with MongoDB from start.
I don’t see any advantage for me using MongoDB, only some concerns like how do i do mass import from csv files and how will my documents(tables) look like. As i understand there are no relationships between documents(tables) so everything is in json like sub items in the same document.
you must give a try for MongoDB, the awesome feathers as I said are here: Please give a FIRST-SUPPORT for MongoDB
For MongoDB i use this https://github.com/duyluonglc/lucid-mongo
Yeah, I choose it too. It’s an awesome project.
i don’t like Lucid with hasmany and all that, i use QueryBuilder in Repos that are called from controller. So i don’t use models at all, Is this doable with MongoDB ?
But how can you query with relationships? Maybe you can use
$lookup aggregation in mongodb but it’s not easy to use and you have to repeat the same code in every where you wanna query with related models.
Lucid Mongo has a lot of benefits like
morphTo relation and so on can save your time.
I used PHP/Laravel before Node and my Eloquent/Lucid wasn’t suitable for my complexed multi joins query so i got advised to use pure QueryBuilder.
Also the performance were better with QB so i have followed the same path here with Node/Adonis. Maybe this is wrong and i can go “the model way” with Adonis?
If so it probably would be better for me as no one seems to use QB. Just like in Laravel community, every discussion and every tutorial and every add on were using Eloquent/Lucid and Models.
I need to me able to have dynamic query’s depending on filtrations.
It should be easier to use Eloquent/Lucid than raw db query if you model your data follow some database design pattern, and almost every
sql join can be replaced with ORM/ODM.
If you have a lot of relationships between your models maybe you should consider use EMBED DOCUMENTS
/ JSON / Array in MongoDB. Just store any json or array data in each document so that you don’t need any
JOIN operation. e.g. product’s properties, people’s hobbits or phone’s attributes.
That’s exactly what I thought when I read “Well, i can’t find anything about MongoDB in the docs and i guess there is a reason?”! Just the case with ExpressJS.
Mongo is best suited as a CACHE layer to store denormalized data and so forth…
As the primary DB, it’s only really good for proof of concept/toy projects. All that “it’s web scale” nonsense is just that, nonsense.
I just migrated a large, application OFF of mongo to postgres. Performance is massively improved, running various arbitrary queries to gather useful statistics/etc is inifinitely easier and more performant… there’s a lot of downside to mongo, and in my experience not enough upside to bother most of the time.
A lot of people reach for mongo because they start building before they know what they’re building, and like the idea of “schemaless” … schemaless is BULLSHIT for a proper application. NoSQL or otherwise, you’ll eventually settle on some sort of data schema. That attitude of schemaless somehow being superior is ignorant, and highlights inexperience.
That many/most tutorials that have sprung up over around the JS/node ecosystem use nosql has really done a significant disservice to the community. And while they tout “schemaless” being great because it’s “flexible” and whatever other nonsense they come up with – more often than not those same tutorials are using Mongoose, which is virtually identical in function to sequelize! So there really is no good argument when things like postgres are much more mature and in most cases vastly more performant than mongo.