perak / meteor-joins

Collection joins for Meteor
77 stars 7 forks source link

Can't join while using angular-meteor #4

Closed Lavan closed 9 years ago

Lavan commented 9 years ago

I have two collections that I want to join like this:

Data = new Mongo.Collection("data");
Templates = new Mongo.Collection("templates");
Data.join(Templates, 'templateId', 'template');

Since I really like angular I want to use angular-meteor for the client.

$scope.data = $scope.$meteorCollection(Data);

I get all the published data from the Data collection but I don't get anything from the Template collection at all. My initial thought was that there was something wrong with my publication but when I run the following:

var data = Data.find().fetch();

I get a nicely filled out array of object with the template included.

[{
  data: "...",
  template: { .... }
}]

So the publish actually does work (using the publishJoinedCursors method).

After digging though the source-code of angular-meteor it looks like it's using observeChanges to retrieve the data which apparently doesn't trigger the transforms in meteor-joins. Any idea if it's possible to make these two packages work together?

perak commented 9 years ago

Hi @Lavan , to be honest, I didn't play a lot of with angular+meteor and since I am super-busy with other things, most likely I'l not be able to help you in timely manner. But, if you can investigate what causes the problem and find some solution, I'l be happy to merge your code and add you to contributors list. Also, there is a plan to extend meteor-kitchen to produce app using angular (currently it produces blaze only), so if you are skilled and ready to help with this - please let me know.

Thanks and excuse me for not being helpful with your issue.

Lavan commented 9 years ago

I and thanks for the quick reply. I have managed to solve the issue myself. It was actually quite simple:

I was wrong. :p Angular-meteor (AM) actually does transform observed collections. The problem was with the publication.

While it worked it wasn't completely finished when AM started to observe the collection (only the main collection Data was synced).

Since there were no actual changes when the data finally arrived, the transform wasn't rerun.

I just had to make sure that the subscription was ready before actually fetching the data.

I'll do some more tests tomorrow to see if everything works.

"Petar Korponaić" notifications@github.com skrev: (8 augusti 2015 22:27:12 CEST)

Hi @Lavan , to be honest, I didn't play a lot of with angular+meteor and since I am super-busy with other things, most likely I'l not be able to help you in timely manner. But, if you can investigate what causes the problem and find some solution, I'l be happy to merge your code and add you to contributors list. Also, there is a plan to extend meteor-kitchen to produce app using angular (currently it produces blaze only), so if you are skilled and ready to help with this - please let me know.

Thanks and excuse me for not being helpful with your issue.


Reply to this email directly or view it on GitHub: https://github.com/perak/meteor-joins/issues/4#issuecomment-129042683

Skickat från min Android-telefon med K-9 E-post. Ursäkta min fåordighet.

Lavan commented 9 years ago

Since there doesn't seem to be any actual problems here I'll close this issue. :smile:

Lavan commented 9 years ago

Changes in the sub collection aren't updated in the angular-meteor collection due to the way AM is working. It creates an javascript array based on the collection contents (using observe and copying element per element). While this works find for the initial update and when the main collection is modified it can't detect any changes made to any sub collections as we only have raw data copies of them.

I'm going to see if I can make a AM version of this package and if I can make it play nicely with yours I send a PR. :smile:

perak commented 9 years ago

OK, thanks.