I am creating two meteor apps One is an admin app that helps clients (Restaurants) set and run deals, the second is a mobile app that users would have and will receive deals through push notifications. What is the best way to go about this in terms of the apps and database.
My hunch is to build the admin section which would house all the collections and then create another meteor app (The user mobile app) that connects to the admin database (It will not have its own) using DDP.
I have seen solutions that recommends a third party database company like Modulus to host the data and both apps connect
I also know I can build the App and admin section all in the same Meteor app
What is the best way to architect this app that will allow me run it at a decent cost and also give me the provision to switch to native apps later on
Can you recommend a tutorial where I can connect apps to the same database (That is not the local in build one in meteor) all the stuff I am seeing mention using a shell script and I am a little lost
No, you create them as you normally would for a single app. But set the
MONGO_URL environment (linux shell environment for the startup script) for
both apps to point at the same mongodb, wherever it is you host the db.
Will this allow my application to update as if it were not just a client application? Eg: when I am using DDP.connect, it seems to intepret my application as a client and use minimongo instead.
Your app connects from its web/mobile client via ddp to a server and uses minimongo for its data requirements. then the server connects to a mongodb server to get/store data.
Now, the client can commect to its own server or another server but as long as it uses the same database, how it works and performs does not differ.
In fact you are alreay using ddp connect anyway, only to a âdefaultâ endpoint of your own server.
So thereâs no âinterpretationâ sonce it is all the same.
@adim86 letâs assume you have a mongodb instance running over at mongodb://x.x.x.x:xxxxx
what you should do is, in your app directory, instead of
$ meteor
or
$ meteor run
you do
$ MONGO_URL=mongodb://x.x.x.x:xxxxx/myappdb MONGO_OPLOG_URL=mongodb://x.x.x.x:xxxxx/local --port 3000 meteor run
and thatâs it now your app will store its data on that server within a db named myappdb
now if you do the same for another app, using another port like 4000, they both use the same db and if you update something from one app, youâll see it on the other app immediately as long as your mongodb database has oplog enabled
Awesome that was the answer I was looking for. Because there is no file in meteor during development where I can set the development db (At least i dont know of one) So I was confused how to set this. I have seen some examples say I need to precede the command you showed with âexportâ. What difference does that make?
normally meteor starts a mongodb server dor you if you donât provide a
custom mongo url like this. and that database is save in your project
folderâs .meteor/local/db folder
if you want a custom db, you use the command I shared
if the complete command is in one line, you donât need export syntax
but instead of writing that everytime you can set your user environment
variable on the operating system using the export syntax but thatâs done
differently on every operating system
@serkandurusoy I have used the system you mentioned above (there is some syntax problems like ââportâ comes after âmeteorâ but it worked out great
How do I store this in a file that gets called every time I run the app. Is this a shell file? What will be the command to call if I want this to execute everytime I run meteor. Or do I just put this in my bashrc and give it an alias? I dont know what the âCorrectâ way to always set these environment variables.