Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for table field call by "." symbol during $project execution #218

Open
Ktoski opened this issue Apr 25, 2023 · 1 comment
Open

Comments

@Ktoski
Copy link

Ktoski commented Apr 25, 2023

Call for field by operator "." it seems to be not working using mongo-java-server.
ex.
"
{
$project: {
user: "$user._id",
},
}
"
where is "user" is a table in this example
Simiar case to mongo function "$toString"
ex. '$toString: "$_id" '

@Jofishy
Copy link

Jofishy commented Jun 25, 2023

I think I'm seeing the same issue with $graphFollow. I have documents with the following format and I'm trying to graph follow based on the directReports.employeeId

{
    "employeeId": "16a596ae-edd3-4847-99fe-c4518e82c86f",
    "firstName": "John",
    "lastName": "Lennon",
    "position": "Development Manager",
    "department": "Engineering",
    "directReports": [
      {
        "employeeId": "b7839309-3348-463b-a7e3-5de1c168beb3"
      },
      {
        "employeeId": "03aa1462-ffa9-4978-901b-7c001562cf6f"
      }
    ]
  }, ...

Here is my query

db.collection.aggregate([
  {
    $match: {
      "employeeId": "16a596ae-edd3-4847-99fe-c4518e82c86f"
    }
  },
  {
    $graphLookup: {
      from: "collection",
      startWith: "$directReports.employeeId",
      connectFromField: "directReports.employeeId",
      connectToField: "employeeId",
      as: "allReports"
    }
  },
  
])

In mongoplayground.net this is working as expected, with the "allReports" field in the output being populated with all child employees. But using it here I'm seeing that the allReports array is empty like so: "allReports": []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants