How to connect Angular2 with MongoDB? - mongodb

I need little help for connect my front end angular2 with MongoDB
I have created a form crud and need connect with database MongoDB
Any Idea?

You can not connect Angular2 directly to MongoDB you need to use NodeJs also. There is a course on Udemy which is called Angular2 & Node - The Prectical Guide MEAN Stack. It may help you.

You can connect MongoDB with Angular Application using NodeJs and Express .
You'll need to set up a server with which you'll have to configure your port , etc .
Later you can coonect to your MongoDb either using Mongoose or MongoJs .

Related

connect mongoose in nextjs middleware

I'm trying to connect next.js app to mongodb via mongoose in _middeware file(./pages/_middleware.ts )
But I get this error on incoming requests:
error - (middleware)\node_modules\mongoose\dist\browser.umd.js (1242:0) #
ReferenceError: regeneratorRuntime is not defined
How can I fix it?
+1 I have the same issue when trying to use in the middleware the instance created for mongoose so I don't have to connect it every time I make a request... but it seems this might not be supported yet.
It appears that it is not possible to use node api calls inside of NextJS middleware as this middleware is executed in the Edge runtime. Mongoose is a Node.js api, hence why is doesn't work.
Edge and Node.js Runtimes

Use AWS Amplify and App Sync with existing Node Server using Mongodb

Currently, I'm developing a native application using React-Native. I've decided to go with AWS Amplify because of it's real time updates as well as its authentication.
I also have a Web Application that runs on a Node.js with Epxress server. This web application connects to a Mongo database.
My big problem is that I would like to have all of my aws amplify queries run to my existing MongoDb instead of a new dynamoDb database which is provided with AWS AppSync, but unfortunately I dont know where to start. This is especially helpful in adding authentication easily in my existing web application as well.
My first idea was to just create all my API endpoints in a new node js server and have app sync call to these API end points, but I'm not sure how to implement calling end points on an existing server (and this seems kind of counter intuitive to the 'serverless' idea)
My other idea came from this: Can AWS App-Sync be used without dynamoDB
This states to use AWS Lambda to 'pipeline' my data to the existing mongodb, but I'm not really sure what that entails.
TL;DR - I would like to be able to query an existing Mongodb instead of using DynamoDb when using AWS Amplify with AppSync.
I hope this is clear enough and doesn't sound like I'm rambling. Thanks in advance!
I would suggest using either an HTTP datasource to connect to your MongoDB backend or a Lambda function. Here are a couple getting started tutorials for both:
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-http-resolvers.html
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html
If you go the Lambda route, then you can leverage the new #function feature of the GraphQL Transformer in the Amplify CLI: https://aws-amplify.github.io/docs/cli/graphql#function

How can I connect mongodb with reactjs?

I want to connect mongoDb with react.
My need is: I have to store my sass variable in mongoDb and than fetch them in my sass via mongoDb.
How can I do that?
You, unfortunately, can't
This is the standard setup for web applications
frontend --> backend --> db
With your current setup its:
frontend --> db
You must have a backend to access the db
----------------------------------
React being our frontend, you must have a backend if you would like to use MongoDB
Ruby on Rails, Django, Meteor.js, Express.js, Golang Gin, etc

Ways to connect mongodb to grafana

My question is different ways to connect mongodb with grafana
Link for reference ?
Try using MongoDB datasource for Grafana
It should allow you to hook up your MongoDB data source just fine...
Source
Right now grafana doesn't support MongoDB as a data source Using mongoDB as back-end repository
But they offer a workaround grafana simple json data source
There's also a new MongoDB data source plugin for paid Grafana:
https://grafana.com/grafana/plugins/grafana-mongodb-datasource

Implementing multitenancy in KeystoneJS

How can KeystoneJS be used to implement multi-tenancy? Is it possible at all?
Example use case: A company is creating a new blog platform using KeystoneJS and it wants to allow for multiple blog sites using the same models from one KeystoneJS instance but each blogger should only be able to control their own site.
Keystonejs does not really support this. Something that you could do, however, is to use something like Docker with an image of the Keystonejs website, then add some configuration to give each instance a different db path.
Or Spring up multiple Node Servers, something like this:
// Keystone 1
process.env.PORT=3000
// Keystone 2
process.env.PORT=3001
// ...
and Spring up one MongoDB server, and assign a unique database name to each node server / keystone instance, like
// Keystone 1: .env
MONGO_URI=mongodb://localhost:27017/KT_1
// Keystone 2: .env
MONGO_URI=mongodb://localhost:27017/KT_2
More info, check out Connection String URI Format[mongodb]
I like only use docker to spring up a MongoDB server and run Keystone locally since Docker works quite tricky with node.js.