Coder Social home page Coder Social logo

Comments (1)

Rodriq avatar Rodriq commented on July 27, 2024

In https://developer.rocket.chat/api/rest-api/query-and-fields-info#fields-example , it's explained:

To only return the usernames for users, you would do something like this:
http://localhost:3000/api/v1/users.list?fields={ "username": 1 }

However, as discussed with @rodrigok, this example won't only return usernames, it would return the username field among other default fields, i.e. those listed at https://github.com/RocketChat/Rocket.Chat/blob/develop/app/api/server/lib/users.js#L53

Maybe the documentation is just out of date because this comment (back in 2017) looks to match with what explained in the current documentation.

So for me it boils down to the following questions:

  • Do we still want to illustrate the same example, i.e "how to only return specific fields ? (my opinion is it's an useful use case).
  • If we do, how do we do that ?
  • Do we rather want to remove this use case, and explain how the default fields are coming into place (the specified fields in the request are merged with the defaults ones)

In addition, at https://developer.rocket.chat/api/rest-api/methods/users/list - where a ref to the Query and Fields Query Parameter page above is inserted - it is mentioned :

Gets all of the users in the system and their information (...)

all could let us think that what's returned by default (without fields parameter) are all the fields the callee has access to, while it's rather all fields the callee has access to among the default fields.

Also I would repeat there that including a specific field with 1 doesn't filter out the default fields from the answer, but rather merge it with some default fields.

Once we're clear with the points above, I'd be glad to propose a Pull Request.

@mhow2 You are right.

I've tested the endpoints and passed in the parameters like documented.
Setting a field value of 0, only excludes it from all the fields being returned. Meanwhile, some other fields(defaults) are being returned along.
Since there are just so many fields, not logical to go eliminating one after the other.

There's no clear way of returning just particular fields stated.

from developer-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.