How can I implement MongoDB on Angular 9? - node.js

I'd like to know how to implement MongoDB to Angular 9 for Inserting, Deleting and updating data. I heard it can be done using Node JS.
I need some sample code for an academic project.

This link is a great step towards learning NodeJS express and Mongo DB connection with CRUD operations.
The author has mentioned step by step procedure for DB operation with Node.
And to combine it with Angular, you can create something to call CRUD APIs of your Node application which will handle the DB connection.

Related

Mongo Atlas Data API and working with Mongoose Schemas

Hi we are looking into migrating our current mongo logic which uses mongoose schemas and the driver to conduct CRUD functions. We run this on serverless functions with many microservices that connect to the db so we have been hitting many issues with connection pool max limits.
We have decided to migrate to the Data API because it would resolve our connection issues. One issue we dont understand or can find documentation on is how do we leverage mongoose schema with the data api?

Reactjs and Mongodb connection

I have a fundamental question about Reactjs and Mongodb. I want to build a react app which has a "search" feature that shows results from the database. However, I have an issue on understanding how to implement the connection between the react app and the database.
Sorry for the general question. Every help or hint on how to proceed will be appreciated. Thanks in advance.
React is completely back-end agnostic. Which means you would have to implement the connection yourself.
The regular way is, you setup MongoDB and a Node.js server (or whatever back-end you like) then you connect the Node.js server to MongoDB (via MongoDBs JavaScript SDK) and your React client, which runs in the browser to your Node.js server (via HTTP, express framework could help here).
Browser -> Node.js -> MongoDB.
But MongoDB also has a REST interface you could use directly via the browser, like it's mentioned in the following answer:
https://stackoverflow.com/a/16277603/1016383
Would probably be okay for small proof of concepts or experiements,.

Angular 6 webapp that connects to PostgreSQL using sequelize-typescript

I'm using Angular6, PostgreSQL and sequelize-typescript. The goal is to connect to a DB and get a list of names and ages into a table.
I started by creating an Express server.
I then used sequelize-typescript to connect to my PostgreSQL DB and call this connection when initializing server
I created a model of my data element using sequelize-typescript and using it to connect to my PosgreSQL DB.
I then created a simple route to the data using Express Router
I added the route to the initial Express Server
This all seemed to work (albeit messy as I'm learning as I go). But I can reach my local server through the browser (localhost:3000) and use PostMan to get the data from the DB (localhost:3000/people).
Client side:
I already have the initial front-end app that was created with I ng'ed the project using command line. I can reach this at (localhost:4200)
I created a simple component called people using ng g component people.
How do I get the data from my server route into the client component? I believe it's through HTTP and then subscribe but there seems to be a lot of different ways to do this. I'm looking for advice on the best pattern to use in Angular6.
TL;DR How do I get the data from my route to the front end
I finally got it working correctly, I needed to create a service that listened to the API url and from there I could return the observable to the component.
The solution (even though it's not cleaned up properly) sits at:
https://github.com/micklynch/travelbudget

Realtime node.js app vs. mongodb

I have a node.js app that polls every x seconds a mongodb database to show data variations.
I think there must be a better way to do it, using all the capabilities of node.js environment ... which is the most efficient way to trigger mongodb data variations and showing them using node?
You can use a tailable cursor
http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/

share mongodb between nodejs and meteor

I just finished a REST server application in nodejs using express, passport and mongodb
I want to create a meteor app for the LIVE Statistics of that mongodb REST api's , like number of connections, user online etc.
But I can't figure out a way to use custom mongodb with meteor. Basically I want to share the same database with nodejs/express application and meteor.
Is it possible? I am sure it should be, but I can't figure out HOW!
Help please!
Okay, I got here what to do.
While deploying meteor, they have an option to choose the database.
So i created an app on meteor and then deployed it for nodejs
here is how,
meteor bundle myapp.tgz
extracted myapp.tgz and used the command below.
PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js
Here is complete doc : http://docs.meteor.com/#deploying

Resources