feathers-hooks-common icon indicating copy to clipboard operation
feathers-hooks-common copied to clipboard

Why fastJoin is preferred over using populate?

Open soullivaneuh opened this issue 4 years ago • 1 comments
trafficstars

This sentence is repeated on both hooks related documentation sections:

  • https://hooks-common.feathersjs.com/hooks.html#fastjoin
  • https://hooks-common.feathersjs.com/hooks.html#populate

fastJoin is preferred over using populate

But I didn't find any link or explanation about why.

So I am asking: why? :slightly_smiling_face:

soullivaneuh avatar Apr 11 '21 15:04 soullivaneuh

I am asking because I consider populate more "easier to use" than fastJoin. We can have the related data with just some configuration lines:

I used fastJoin to calculate a price of a record:

fastJoin(
  {
    joins: {
      totalPrice: () => async (ride) => {
        ride.totalPrice = getTotalPrice(ride.price);
      },
    },
  },
),

This works, but you will certainly say I should use alterItem for that.

Plus, you show alterItem example on the documentation to load something that looks like a relation:

alterItems(rec => {
  rec.userRecord = (async () => await service.get(...) )()
})

Well, I am pretty confused. :upside_down_face:

I hope you may clarify this. :+1:

soullivaneuh avatar Apr 11 '21 15:04 soullivaneuh