Using MongoDB in Quasar
-
Hi,
I’m following a Vue.JS course on Udemy and it is using MongoDB as the database which is fine.
It then goes through creating models and controllers, and I was wondering two things:Can we use the Mongo Cloud database in Quasar, and can we also use the models/controllers in Quasar to fetch and view the data using API’s? I have followed Danny Connells course, and it doesn’t mention any of this.
I know Quasar is built on top of Vue, but I was just curious. I am doing this course The Complete Vue JS Developer Course – inc. Vue JS 2! if that helps
Thanks,
Nick -
I think Danny really likes Firebase :-). With Firebase you can directly make requests from quasar( or any js) to access Firebase data without a server in between. With Mongo Cloud database on the other hand you need a (nodejs) server in between Quasar and Mongodb ( correct me if I am wrong).
btw I am using a Meteor.js as a server to deliver data from MongoDB to my Quasar apps.
-
Documentation on referencing other data is scarce. How do I create a relationship between data objects? Are there any good tutorials for Firebase?
-
Documentation on referencing other data is scarce.
Say woot?!? There is tons of documentation out there. Just not so much specific to Quasar, but it is also “just Vue” or even “just SPA/ PWA” or “just Electron” or, well you get the gist and thus, there is a ton of it out there.
Scott
-
@NickBloodworth I fact Vue.JS or Quasar , we use them as UI framework. If you want to communicate with backend you need a backend languages like php ,nodejs … . If you want to use Mongodb Cloud as your database you can use (nodejs express mongoose) to build API as my recommendation. If you want to move from local to Cloud just change the connection string. Hope it help
-
VueJS cannot use MongoDB directly. VueJS is a frontend library (works in the browser), while MongoDB is a server-side database technology. In the course you mentioned, the author is probably bridging VueJS and MongoDB through an ExpressJS app, which runs in a server. You should be seeing things like
fetch(
oraxios
in the examples. Those words indicate the client-side application connecting to a backend.The models are probably written for a MongoDB library that runs in ExpressJS. Controllers must be either self-developed or using a library that allows creating controllers for ExpressJS.
Notice I keep saying ExpressJS. There are other server frameworks for NodeJS, but ExpressJS is the most popular one.
Also, the only difference between running your own MongoDB instance and using MongoDB atlas (for the ExpressJS app) is where to connect. One connects to MongoDB running on http://localhost, the other connects to something like https://srv05-nickb.atlas.mongodb.com
Long story short, yes, you can use MongoDB with Vue or Quasar. But it won’t be Vue or Quasar using / connecting to MongoDB but an intermediary app written in something like ExpressJS.