pocketbase / js-sdk

PocketBase JavaScript SDK
https://www.npmjs.com/package/pocketbase
MIT License
2.17k stars 127 forks source link

Back-relation expand not working with "getOne" #260

Closed jlak0 closed 11 months ago

jlak0 commented 11 months ago

I have tested same code with API or "getList" method and it works perfectly However, when using the 'getOne' method, the code for expand back-relation seems to be ignored

export default async function ProductPage({ params }) {
  let product;
  async function getProduct(product_id) {
    const record = await pb
      .collection("new_products")
      .getOne(product_id, { expand: "test(product_id)" });
    console.log(record);
    return record;
  }

  try {
    product = await getProduct(params.product_id);
  } catch {
    console.log("error");
  }
  return <div>{product.name}</div>;
}
ganigeorgiev commented 11 months ago

I'm using heavily expand with both direct and indirect/back relations, so I don't think it is a PocketBase or JS SDK issue.

Double check that:

To rule out JS SDK issue, you can also try sending the request directly with the equivalent web API.

If the above doesn't help, feel free to paste your collections configuration as json (Admin UI > Settings > Export collections) and I'll have a more detailed look.

jlak0 commented 11 months ago

I'm using heavily expand with both direct and indirect/back relations, so I don't think it is a PocketBase or JS SDK issue.

Double check that:

  • there is no cache involved (if you use Next.js note that they have custom global fetch implementation that has cache enabled by default)
  • make sure that your API request satisfy the View API rule of the related collection

To rule out JS SDK issue, you can also try sending the request directly with the equivalent web API.

If the above doesn't help, feel free to paste your collections configuration as json (Admin UI > Settings > Export collections) and I'll have a more detailed look.

I'm using heavily expand with both direct and indirect/back relations, so I don't think it is a PocketBase or JS SDK issue.

Double check that:

  • there is no cache involved (if you use Next.js note that they have custom global fetch implementation that has cache enabled by default)
  • make sure that your API request satisfy the View API rule of the related collection

To rule out JS SDK issue, you can also try sending the request directly with the equivalent web API.

If the above doesn't help, feel free to paste your collections configuration as json (Admin UI > Settings > Export collections) and I'll have a more detailed look.

Thank you a lot for your hint and sorry for incorrect issue, it was Next.js cache problem,I had encountered once before in an another situation, and was discuted here https://github.com/pocketbase/pocketbase/discussions/2695 ugh, how could I forget this