简体   繁体   中英

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!

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.

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.

And what about other cases ? I mean browser applications ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM