share mongodb between nodejs and meteor - node.js

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

Related

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

Conceptual question: How do React Native, Apollo, Node, and GraphQL all work together?

I'm new to GraphQL, Apollo, AWS S3, and Redux. I've read the tutorials for each and I'm familiar with React Native, Node, Heroku, and Mongo. I'm having trouble understanding the following:
how a "GraphQL Server" is hosted for a mobile device using React Native?
can I create the GraphQL server with Node and host it on AWS S3?
how to grab that data by using Apollo/GraphQL in my React Native code and store that data locally using Apollo/Redux?
do I have to use Graphcool as the endpoint from the start instead? All I'm trying to do is pulling data from my database when the app loads (not looking to stream it, so that I am able to use the data offline).
Where should I look to get a better understanding?
I have a couple comments for you in your exploration of new territory.
GraphQL is simply the query language the talks to your database. So you are free to run any type of api (on a server, serverless, etc.) that will use graphql to take in a graphql query/mutation and interact with your database.
GraphCool is a "production-ready backend" basically back-end as a service. So you wouldn't worry about running a server (as I believe they run most everything on serverless infrastructure) or managing where your DB is housed.
You can run an HTTP server on AWS EC2 or serverless using AWS Lambda. (Or the same flavor with Google or Azure). Whatever you decide to use to accept requests, your endpoint will accept graphql query strings and then do stuff with the db. AWS S3 is more of static storage. You can store files there to be retrieved, or scripts that can be pulled, but S3 probably isn't where you would want any server-like code to run.
Apollo would be a tool to use on your frontend for easily interacting with your graphql server. React-Apollo
Apollo/Redux may help you then manage the state throughout the app. You'll simply be loading the data into the app state on load then interacting with that state without needing to make any more external calls it sounds like.
Hopefully this was helpful.

Socket io private messages using expressjs nodejs mongoose

I'm struggling with socket.io to make a chat app with the users that are logged in in my app. I followed the beginner course and I could make a private chat app, but the users aren't the ones that are in my database or they have to create a username to connect to the chat app.
In my search I found this one -
Realtime app with Vue, Laravel, Socket.io and Redis (He's making a similar app using Laravel)
I want the exact same app but using nodejs mongoose express.
Can you help me with some references or tutorials?
Here are some resources that might -
Make A Real-Time Chat Room using Node Webkit, Socket.io, and MEAN
Simple Chat Application using NodeJS and Socket.IO
Please start with any of these and be more specific with what extra feature you're trying to implement. (code would be very helpful)
Couldn't understand what do you mean by the users not in database bit.

Installing mongodb when deploying express application

finally, i am so happy because im about to deploy my first express app yey!
i choose heroku and already follow step by step guidance to deploy nodejs application but none of those steps shows me how to import database because at this moment i am coding my express app in my laptop with mongodb installed, i expect in heroku there is mongodb then i can import my mongodb data to it as i do it in PHP + mysql. i have read some articles on google but still confuse.
to sum up my question :
Where should i store my documents on mongodb when deploy ?
Please give us some recommended tips to deploy express app with mongodb.
Thank you.
For importing database ,you have to use mlab (mLab's MongoDB hosting platform is the fastest growing cloud Database-as-a-Service in the world).
https://mlab.com/ , just change the address in your app from local db to mlab db.

Resources