Connecting with MongoDB in Javascript without NodeJs - javascript

I have an UI5 Application [Mobile-Fiori], and I would like to connect it with MongoDB to get JSON data to be displayed in my views.
I know it would have been possible if I used Node.js with the package Mongoose, but for my applications developed locally, I use Eclipse with Tomcat Server.
I wonder if this is possible in this way.
Thanks

Yes it is possible, e.g. with Spring Data MongoDB.

Related

Can I create web api using express.js and not have node.js installed?

I am currently in the process of creating a portfolio website for myself but due to hosting restrictions, I cannot make use of Node.js.
I know Angular can run on any web server, but is it possible to make use of Express.js to create web api's with relying on Node.js to run these web api's using Express.js?
If not, is there an alternative solution to create web api's that I can call using Angular and later for my mobile version of my website?
Please note that my shared hosting runs using cPanel.
As per definition Express.js, or simply Express, is a web application framework for Node.js so you can't do that. Alternatives would be to use a different backend language.
That also depends if your server supports them, for example, you can go with .NET CORE
You cannot use Express without NodeJS by definition so you have to deploy your backend somewhere else in you want to use it.
I suggest giving a look Firebase: you could write your backend using http cloud functions in express without paying anything until a reasonable amount of traffic (after that, is pretty cheap). You could also get rid of cPanel and deploy your frontend there via Firebase hosting.
Maybe you can try to build at first a web application with express. Of course you can create a web app without express if you need it. With express and Node.js I created a MySQL REST API. With HTML and Ajax you can fetch the Data from the API. So you can create two applications. One application where you need to run Node.js because it`s much easier to create a REST API with express. The second one is fully without Node.js.
Maybe there are better solutions, but inside each Web Application you can than but you can then access this API in any web application using jQuery. It doesn't matter if it is written with PHP, ASP.Net Core, Java EE / EE4J. You can also access this API in Ruby, Angular, React, Vue etc. using an AJAX request.
In some scenarios you can't start Node.js as a server because an application is already running on apache2 or nginx. There this would be a workaround to use something like this. For example, one could also integrate applications with HTML+JS in a CMS system that accesses other database tables and thus extend such a system without an iframe.
So can be helpful for few scenarios. Now just doesn't get around the actual goal of doing without Node.js completely or even express. But why are there REST APIs? So that you can query the data and incorporate it somewhere else. Otherwise you would have to build a REST API with another technology. Especially in the example of accessing MySQL with JavaScript, this would not be quickly feasible.
If you are looking for a similar solution to separate the web app and the REST API, but you don't need Node.js, then you should really build a REST API with .Net Core or with another technology, depending on what is possible and installed on your server. It could be Java or PHP behind it or Ruby.
The API that provides the REST access does not have to be written in JavaScript. You only need to be able to access it with JavaScript. So you can use many different approaches to access JSON data. I hope that in the short time with my bad English I have explained the basic idea, how to proceed stylistically and where advantages exist in REST interfaces.
With this, it should be self-explanatory that you don't have to use NodeJS and Express, but with JavaScript it's a pleasant solution. Only you have to ask yourself if a JavaScript application has to provide this interface at all or if in the end only a JavaScript application has to access this interface. Very big difference.
For backend rest api you can use golang with gorilla framework. Golang simple keyword and easy to learn.best important point is performance. If your server support golang you can use golang for backend..
ExpressJS is NodeJS framework so it's impossible to create an API without NodeJS.
Angular is front-end framework so you can host it on web hosting server.
If you need to create back-end APIs, you can use other clouding host servers that support NodeJS.
It's fairly simple to build this with just the net/http package. Set up a router that handles various commands and deal with the response accordingly.

Display UART in HTML (web site)

I receive continuously data by uart sérial port.
How can i print this data on my html web site and update it dynamically ?
I use a raspberry pi 3 with apache server.
I can use php, javascript, python... and many languages.
You could create a NodeJS server, with express for example.
Then use the serialport npm module to get data from your serial port.
Then send this data through a websocket, create a web page, and use the Websocket Javascript API to retrieve the data from your websocket.
This way, you can display real-time data from serial port on your website. I've used this 'stack' to build a connected aquaponics system in a Hackathon and it worked well !
It would even be simplier if you use socket.io, since it provides simple library and code example for both the back-end and the front-end part.
Hope it helps,
Best regards

Mongodb to Android Application

I want to connect android application to Mongodb. I had installed Mongodb into my system but i don't know to connect with android.I tried mongo with java applicaion.can you help me?
It is a very large question but,
The best way to achieve this is to create a restful webservice to access your mongodb database and also respond to clients with that service.
There are lots of choices to pick a framework for your restful webservice however, you can use Jersey because of its ease of using.
First, deploy your jersey application as your backend application to
your localhost or to some remote hosting provider as y.
Second, make http calls to your backend and fetch the data from
mongodb in json format
Third, parse the json formatted data in your android application and show it on your layout.

Connecting to a MySQL database using AngularJS

I'm trying to create a mobile application using AngularJS and Ionic Framework. However, I'm lost when trying to find a solution for backend database support. Is there a plugin or third-party API available to use to accomplish this?
Client side web applications do not connect directly to SQL database servers.
You need to pick a server side programming language and write a web service interface to your database.
Then access that interface using XMLHttpRequest (which Angular wraps with $http).

Connectin to MongoDB using Javascript

I am working on a little fun project(webcalender) and I want to use mongoDB. MongoDB is running and I figured out how to deal with it. I also got the connection to PHP.
I was wondering is there any chance to connect to the MongoDB using simple javascript?
I have searched a lot and I always passed by Node.js? Do I need Node.js to connect to mongoDB over Javascript?
Does anyone have a great link? Tutorial? or arguments why I should not do that?
Thanks for help
there are client side ways of doing this but its not safe at all.
there are a few reasons for the lack of security.
1. connection info is in the source for anyone to see.
2. if you use a service like mongoHQ where its a restful API to connect to Mongo your secret is exposed on the client side.
Both of these reasons scared me enough to not use a JS library that allowed me to connect to mongo on client side.
is your application being built in node? or PHP?
if PHP I know theres a PEAR library for MongoDB, then you can use javascript on the client side to interact with php to do what you need on the DB.
if the application is being built in node.js then sure why not? I've had success using Mongoose with express in node.
hope that helps.
Yes, you need Node.js to access MongoDB via JavaScript, because simple plain JavaScript runs on the user browser, not on the server, and Node.js is meant to run on the server.
Accessing a database directly from the browser would be a huge security issue, since JS files are always available to those viewing the page.

Categories

Resources