Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can angularjs connect directly to mongodb?

I am new to angularjs and as the title said, I am wondering if there is a way to connect angularjs directly to mongodb without coding additional server side using express.js. i tried to search on the Internet but i cannot find any resources.

like image 981
ktlim Avatar asked Jun 18 '15 00:06

ktlim


People also ask

Can we connect angular with MongoDB?

We cannot connect angular to the database directly without sending an http request to the node. We would have our angular app and our MongoDB database on a server. We would directly send queries to the database from our angular app and surpass our node express application.

Can JavaScript connect to MongoDB?

It is used to programmatically manipulate the content of web pages. MongoDB JavaScript (NodeJS) connection will make the websites and applications user interactive, allow companies to use data through MongoDB JavaScript (NodeJS) connection, and manipulate data.

Which database is best for angular?

MySQL for Angular Developers. One of the most widely used databases is MySQL. For so many years, it has been an excellent preference for web applications. MySQL is a relational database system that has proven to be a very convenient solution for web-based applications.


1 Answers

Sorry what you are trying to do in not possible. You will need to introduce some serverside technologies so that you can talk to the database and form some sort of api that will return JSON data depending on certain business rules coded into the backend of your application. AngularJS has templating built into it which receives JSON data and places it as you direct it to throughout the DOM.

What your asking is logical, I used to wonder this as well coming from the frontend world. If this no-server side code where ever to happen, the database queries would be exposed to the user on the client side. The client could then modify the AngularJS "query syntax" in the code inspector. BAM... now all of the data held in your database is now exposed to the user. Ever worse this could mean that the user could perform delete ops and whatnot. Anyways I hope this sheds a bit of light on the subject for you! Here two resources that helped me on this server/client stuff:

http://tomdale.net/2015/02/youre-missing-the-point-of-server-side-rendered-javascript-apps/

https://medium.com/google-developers/tradeoffs-in-server-side-and-client-side-rendering-14dad8d4ff8b

like image 138
Alpha G33k Avatar answered Nov 15 '22 06:11

Alpha G33k