Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write to Meteor database from external application?

I'm trying to figure out how to insert data into a Meteor mongodb database from an external native mobile application that I'm writing (specifically for iOS using Cinder, right now). I'd like events that happen on the mobile device application to be written to my Meteor app's database, so that it can be immediately displayed on a browser elsewhere.

Importantly, I need to stay in my native application on the mobile device - I can't launch into a browser. I'm a bit new to Meteor, so apologies if I'm overlooking something obvious.

Any ideas on how to do this? Thanks!

like image 263
isTravis Avatar asked Jan 18 '13 23:01

isTravis


2 Answers

Your best bet is to use an iOS DDP client like this one. You can use this client natively in your existing iOS app and subscribe and write back to data in your Meteor ecosystem.

DDP stands for Distributed Data Protocol and is authored by the Meteor group as an external standard for real-time app frameworks to adopt. It's a much preferred method than communicating directly with the database because you can leverage the publish and subscribe methods within the Meteor ecosystem.

The protocol is under rapid development.

I believe there will be a release shortly that will expound on the current state of DDP and the evolution of its official specification. An official spec is slated for the 1.0 release.

Note: Here is a great video overview of DDP in its present form.

like image 74
TimDog Avatar answered Nov 16 '22 08:11

TimDog


Another option is to have your iOS app write directly to the MongoDB instance used by your Meteor app. You can use any MongoDB driver such as NuMongoDB. Meteor polls the MongoDB database every ten seconds so web based users will automatically see updates, albeit with a short lag.

DDP is evolving quickly, as Tim mentioned, so this option might be a little more stable.

In terms of hosting, for scalability I recommend separating your MongoDB instance from the free meteor.com site, by using a Mongo host such as MongoHQ.

like image 45
David Wihl Avatar answered Nov 16 '22 07:11

David Wihl