lfades / cottz-publish-relations

Edit your documents before sending without too much stress
https://atmospherejs.com/cottz/publish-relations
MIT License
26 stars 6 forks source link

the parent doc is removed, the related children doc is not removed. #17

Open fangjj opened 5 years ago

fangjj commented 5 years ago
this.cursor(Authors.find(authorId), function (id, doc) {
  this.cursor(Books.find({authorId: id}), function (id, doc) {
    this.cursor(Comments.find({bookId: id}));
  });
});

when i remove authorId1, the publish authorId1 is removed on client. but the published authorId1's books and comments to client not is removed. please help me out. thank you!

fangjj commented 5 years ago

@lfades any idea about this?

fangjj commented 5 years ago

@lfades any update, please

lfades commented 5 years ago

Hello! I'm no longer supporting this package because of lack of time and of the current state of Meteor, but I'm going to try to answer the question, I don't think that the comments or books should be removed, the cursors are stopped in the server, but you can manually remove the documents from the cache in the client.

fangjj commented 5 years ago

thank you for your reply. how to manually remove the documents from the cache in the client? just like this:

Authors.find(authorId).observeChanges({
    removed(id) {
        const bookIds = Books.find({authorId: id}).map(book => book._id);
        Books.remove(_id: {$in: bookIds});
        Comments.remove({bookId: {$in: bookIds}});
    }
})

Meteor platform is still alive, why you are running away meteor.

lfades commented 5 years ago

it was a performance and scalability decision, my current stack is Next.js + Apollo / Node.

The solution you're using may work, if you can do it from the client using minimongo, that may be better.