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

Expand single attribute not working #4900

Closed
ZeroPie opened this issue May 11, 2024 · 1 comment
Closed

Expand single attribute not working #4900

ZeroPie opened this issue May 11, 2024 · 1 comment

Comments

@ZeroPie
Copy link

ZeroPie commented May 11, 2024

Can't manage to expand only single attributes using dot notation.

I do have admin permissions
and can expand the whole collection succesfully
http://127.0.0.1:8090/api/collections/bookings/records?expand=class_id

When i try to expand a single attribute, it is not included
http://127.0.0.1:8090/api/collections/bookings/records?expand=class_id.price

same for the sdk.
this returns me the complete expanded collection

const records = await pb.collection("bookings").getFullList({
      sort: "-created",
      expand: "class_id",
    });
    return records;

this doesn't return the expanded attribute

const records = await pb.collection("bookings").getFullList({
      sort: "-created",
      expand: "class_id.name,class_id.shortDescription",
    });
    return records;
@ganigeorgiev
Copy link
Member

It is not expected to work this way. expand operates only with relation fields.

If you want to expand only the name and shortDescription fields you need to specify the fields query parameter, something like:

await pb.collection("bookings").getFullList({
    sort: "-created",
    expand: "class_id",
    fields: "*,expand.class_id.name,expand.class_id.shortDescription"
});

If you have other questions please use the Q&A discussions instead as the threaded format is more suitable for this.

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