I don't even know if this repo is still active, but it's worth a shot.
I have a "loaded" hook on a model that uses this mixin in which i calculate some properties and assign it to ctx.data, it works well in the project but when it comes to the aggregate functions seems to be not working, any idea what could it be?
Here some code:
this is the hook:
Listing.observe("loaded", async (ctx: any) => {
if (ctx.data) {
if (ctx.options?.currentUser) {
const currentUser = ctx.options.currentUser;
let isLikedByYou = await Listing.app.models.LikedListing.findOne({
where: {
memberId: currentUser.id,
listingId: ctx.data.id,
},
});
ctx.data["isLikedByYou"] = !!isLikedByYou;
}
}
});
And this is the remote method aggregation which doesn't seem to be keeping the properties i set in the hook:
...
const pipeline: any = [{
$geoNear: {
near: point,
distanceField: "distance",
maxDistance: radius * 6378.1 * 1000,
query: query,
},
}, {
$skip: page * limit,
}, {
$limit: limit,
}];
return {
total: (await Listing.aggregate(count_pipeline))[0]?.total || 0,
page: page,
limit: limit,
listings: await Listing.aggregate({
include: ["agent", "agency"],
aggregate: pipeline,
}),
userSearch: user_search,
}
I couldn't verify if the problem is that the loaded event isn't being fired or if the data is not persisted trough the flow but I suspect it's the first case
Anyway, if you have any more insight on what could it be causing this, it would be much appreciated, btw it's a great mixin, thanks for developing it
I don't even know if this repo is still active, but it's worth a shot.
I have a "loaded" hook on a model that uses this mixin in which i calculate some properties and assign it to ctx.data, it works well in the project but when it comes to the aggregate functions seems to be not working, any idea what could it be?
Here some code:
this is the hook:
And this is the remote method aggregation which doesn't seem to be keeping the properties i set in the hook:
I couldn't verify if the problem is that the loaded event isn't being fired or if the data is not persisted trough the flow but I suspect it's the first case
Anyway, if you have any more insight on what could it be causing this, it would be much appreciated, btw it's a great mixin, thanks for developing it