Closed romaluca closed 8 years ago
Thanks for your question!
As far as I know, using the onDataXxx
callbacks, you always get what is actually in the MongoDB collections. And since the transformation is not actually in the database, you don't get that.
The transformation is only in the scope of your JavaScript business logic. I don't think you can get this on Android without changing the actual database contents. Sorry!
Does this help?
Meteor.publish("actions", function (id, isNext) {
actions = Actions.find(where, {sort: sort, limit: LIMIT });
photoIds = _.compact(_.uniq(actions.map(function(a){ return a.photoId })));
photos = Photos.find({ _id: { $in: photoIds } }, { fields: {
_id: 1, position: 1, commentsCount: 1,
votesCount: 1, votedBy:{$elemMatch: { $eq: userId }},
uploaded: 1, createdAt: 1, user: 1
} });
return [actions, photos];
});
Thanks for the answer. Now i return an array of cursors. The problem is the elements of actions maybe arrive before the photo's elements. So when an action arrives i can't show it because the photo of the action is not arrived yet. So i think i have to memorize all data in a database and show them only when are complete. Have you any better solutions?
Thanks!
@romaluca Thanks for updating your solution!
If you need database access to store data temporarily, please take a look at this upcoming feature: https://github.com/delight-im/Android-DDP/issues/54 You can use it already today.
And if you need to know when all photos have been received, you may use the SubscribeListener
in combination with the subscribe
method, as explained here: https://github.com/delight-im/Android-DDP/issues/65
Is this of any help?
Thanks!
Hi, i have a collection defined like this:
In android in the onDataAdded method i receive the parameter of action but without the parameters of Photo. How i can do? Thanks