xataio / client-ts

Xata.io SDK for TypeScript and JavaScript
https://xata.io/docs/sdk/typescript/overview
Apache License 2.0
123 stars 8 forks source link

Reverse link results are not typed #1524

Open kostasb opened 4 months ago

kostasb commented 4 months ago

Reported on client version: 0.29.5

When aliasing a reverse link result with as, the alias is not typed in the returned object.

const record = await xata.db.ShoppingCarts.select([{
    name: "<-ShoppingCartLineItems.shoppingCart",
    columns: ["productId", "quantity", "type"],
    as: "lineItems"
}]).getFirst();

image

kostasb commented 4 months ago

The same type issue applies not just to aliased but to the reverse linked table records

const record = await xata.db.ShoppingCarts.select([
    {
        name: "<-ShoppingCartLineItems.shoppingCart",
        columns: ["productId", "quantity", "type"],
    },
]).getFirst();

console.log(record.<-lacks types);

anything under ShoppingCartLineItemsshoppingCart (included) is not typed.

raw record response sample:

{
  "ShoppingCartLineItemsshoppingCart": {
    "records": [
      {
        "id": "rec_cq2eqoejtvt7ohj3uh70",
        "productId": "pid1",
        "quantity": 1,
        "type": "item",
        "xata": {
          "createdAt": "2024-07-03T06:19:13.319792+00:00",
          "updatedAt": "2024-07-03T06:19:13.319792+00:00",
          "version": 0
        }
      }
    ]
  },
  "id": "rec_cq2eqjskrmoddioegtv0",
  "xata": {
    "createdAt": "2024-07-03T06:18:55.023Z",
    "updatedAt": "2024-07-03T06:18:55.023Z",
    "version": 0
  }
}