Skip to content

getChildrenTree returns wrong tree with sort option #26

Description

@daaru00

I have some problem to fetch children of node, my data is:

{
  "_id": "56fbcfde91c3eca907b561b0",
  "path": "56fbcfde91c3eca907b561b0",
  "name": "root"
}
{
  "_id": "56fbd401947323790b06c02b",
  "path": "56fbcfde91c3eca907b561b0#56fbd401947323790b06c02b",
  "name": "1",
  "parent": "56fbcfde91c3eca907b561b0"
}
{
  "_id": "56fbd405947323790b06c02c",
  "path": "56fbcfde91c3eca907b561b0#56fbd401947323790b06c02b#56fbd405947323790b06c02c",
  "name": "2",
  "parent": "56fbd401947323790b06c02b"
}
{
  "_id": "56fbd408947323790b06c02d",
  "path": "56fbcfde91c3eca907b561b0#56fbd40c947323790b06c02e#56fbd408947323790b06c02d",
  "name": "3",
  "parent": "56fbd40c947323790b06c02e"
}
{
  "_id": "56fbd40c947323790b06c02e",
  "path": "56fbcfde91c3eca907b561b0#56fbd40c947323790b06c02e",
  "name": "4",
  "parent": "56fbcfde91c3eca907b561b0"
}

The tree should be:
root
-1
--2
-4
--3
the path property is correctly set: 3 path is 56fbcfde91c3eca907b561b0#56fbd40c947323790b06c02e#56fbd408947323790b06c02d translatable into root 4 3.
When I use rootcat.getChildrenTree({options:{sort:'order'}}, callback); the result is:
1
--2
--3
4
but if I don't use the order strategy rootcat.getChildrenTree(callback); the result is right!

I using mongoose v4.4.10, nodejs v0.10.25 and mongodb v3.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions