Closed khalilsarabey closed 5 years ago
I was able to make this work. For anyone who faced an issue here's the pipeline:
$pipeline = [
'project' => ['tags' => 1],
'unwind' => '$tags',
'lookup' => [
'from' => 'Tag',
'localField' => 'tags.objectId',
'foreignField' => '_id',
'as' => 'popular'
],
'group' => [
'objectId' => '$popular',
'count' => ['$sum' => 1]
],
'sort' => [ 'count' => -1],
'limit' => 10,
];
Would love to know if there's any way we can create stages with the same name, for instance I would like to use 'project' twice in the above pipeline
can create stages with the same name
This isn't supported in the SDK. We could use a 2D array instead of an associate array for it.
I can do a PR for it.
can create stages with the same name
This isn't supported in the SDK. We could use a 2D array instead of an associate array for it.
I can do a PR for it.
I think that would be great man, sometimes stages with the same name are important, for instance what I have is good, but it would be great if I clean it up with another project stage.
Issue Description
Hello,
I'm trying to create a function that returns the top most popular tags used by users, but I keep getting an empty array for the lookup. The way the data is saved is like the following: I have a a Tag class and a _User class. inside the _User class, I have a Tags field of type array, and it contains an array of pointers for each user, the pointers of course point to the "Tag" class.
I tried multiple things but I keep getting the same results, not sure if it's a bug in the PHP SDK or I'm doing something wrong.
As a reference, here's a snippet of both Schema classes:
User class:
Tag class:
I'm running Parse version 2.8.2 cause NodeChef didn't upgrade Parse that's running on their server. PHP version is: 7.0 The PHP SDK version is: 1.5.1 And the MongoDB version is: 3.4.4
Thanks