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

publishComposite #113

Closed proft closed 7 years ago

proft commented 7 years ago

Hello!

Is there any possibility to get data from publishComposite?

My publish (meteor side)

Meteor.publishComposite('messagesToUser', function(to) {
    return {
        find: function() {
            return Messages.find({to: to}, {sort: {created: 1}})
        },
        children: [{
            find: function(item) {
                return Entities.find({_id: item.entity});
            }
        }]
    }
})

My subscribe (android side)

        meteor.subscribe("messagesToUser", new Object[]{userID}, new SubscribeListener() {
            @Override
            public void onSuccess() {
                Document[] messages = db.getCollection("Messages").whereEqual("to", userID ).find();

                // prepare list
                for (Document msg : messages) {
                    Log.i("VVV", "MSG " + msg.toString());
                }
            }

            @Override
            public void onError(String s, String s1, String s2) {}
        });

Output

MSG {to=v7zBKuRKD7ayyWaM2, entity=amF6cWiHWCNwZLgmf, message=1111, from=vo4TAbJaT7LiDXJiv, created={$date=1475350399184}, isRead=false}

How to get linked Entities object?

ocram commented 7 years ago

Thanks for reporting this!

Is that publishComposite from englue/meteor-publish-composite?

If so, you may find https://github.com/englue/meteor-publish-composite/issues/67 helpful. It suggests that there's a problem in that library which causes the operation to be marked as completed when actually only the primary cursor has returned and the secondary cursor is still not done.

Can you check that? Perhaps the data from the second cursor arrives a little later?

Anyway, doesn't seem like something we can fix here.