delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Can I call two publish? #58

Closed cristianhoyos66-zz closed 8 years ago

cristianhoyos66-zz commented 8 years ago

I need to do something like this:

 // server
 BlogPosts = new Mongo.Collection('posts');

Meteor.publish('posts-current-user', function publishFunction() {
   return BlogPosts.find({author: this.userId}, {sort: {date: -1}, limit: 10});
 }
 Meteor.publish('posts-by-user', function publishFunction(who) {
   return BlogPosts.find({authorId: who._id}, {sort: {date: -1}, limit: 10});
 }

 // client
 Meteor.subscribe('posts-current-user');
 Meteor.subscribe('posts-by-user', someUser);

I do this because in meteor in the client use minimongo and the collections are overlaped if publish return data from the same collection.

¿Can I do the same thing or is there a better way to do this with Android-DDP?

Thank you.

ocram commented 8 years ago

The behaviour should be the same in your JavaScript client and on Android using this library. So for best practices on how to write your server-side code, please refer to the various Meteor resources online. This is not something that is related to this library.

But if you encounter any problems, e.g. the data that you receive on Android is not what you receive in JavaScript (when using these two publications), please report this here.

cristianhoyos66-zz commented 8 years ago

Ok man, thank you very much