Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Question about accessing search result attributes in v3 #919

Closed
ecs-hk opened this issue Jul 25, 2023 · 1 comment
Closed

Question about accessing search result attributes in v3 #919

ecs-hk opened this issue Jul 25, 2023 · 1 comment

Comments

@ecs-hk
Copy link

ecs-hk commented Jul 25, 2023

I'm making the move from ldapjsv2 to v3, and I have read the release notes documentation:

My question: under v3, is there any way to access a search result attribute directly (like under v2) so that I don't have to iterate through an array of attributes every time?

Abbreviated example of a search result, entry.object, from v2:

{
    "dn": "cn=foo,dc=org",
    "member": [
      "uid=baz",
      "uid=fuz"
    ],
    "email": "foo@org",
    "private": "FALSE"
}

By contrast, abbreviated example of a search result, entry.pojo, from v3:

{
  "type": "SearchResultEntry",
  "objectName": "cn=foo,dc=org",
  "attributes": [
    {
      "type": "member",
      "values": [
        "uid=baz",
        "uid=fuz"
      ]
    },
    {
      "type": "email",
      "values": [
        "foo@org"
      ]
    },
    {
      "type": "private",
      "values": [
        "FALSE"
      ]
    }
}

Thanks for any help.

@jsumners
Copy link
Member

I think the comments in issue #841, which is linked from the v3 release notes, are pretty clear. But, to reiterate, the v2 .object property was not a direct access. It converted object to an object literal, i.e. serialized it to "JSON", and returned that object. So it was an expensive operation. This is exactly the way the .pojo accessor works.

We would definitely welcome a PR to @ldapjs/messages to provide utility accessors for the SearchEntry object. But as it stands, the best, most efficient, way to access the properties on this object are through the functional methods described in the above referenced issue.

@jsumners jsumners closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants