pocketbase/js-sdk

Back-relation expand not working with "getOne"

jlak0 opened this issue · 2 comments

jlak0 commented

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>;
}

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.

korosu commented

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 pocketbase/pocketbase#2695
ugh, how could I forget this