0.401 (17 Feb 2025)

17 February, 2025

Offset pagination

This release introduces support for offset pagination for all list actions. By default cursor pagination is used, but if the request contains a limit field, Offset pagination will be performed. For more information please refer to the API docs.

// POST /api/json/listItems
{
  "limit": 5,
  "offset": 5
}
 
// Response
{
  "pageInfo": {
    "count": 3,
    "endCursor": "2stp5GgcnJoakGgLhl8mqJi4i5n",
    "hasNextPage": false,
    "pageNumber": 2,
    "startCursor": "2stp5nqGsXvJq6VlsDQOmsy7L9f",
    "totalCount": 8
  },
  "results": [
    {
      "createdAt": "2025-02-11T14:35:44.276727Z",
      "id": "2stp5nqGsXvJq6VlsDQOmsy7L9f",
      "updatedAt": "2025-02-11T14:35:44.276727Z"
    },
    {
      "createdAt": "2025-02-11T14:35:42.269212Z",
      "id": "2stp5YCcPGWObc0GcU3hYqzPD75",
      "updatedAt": "2025-02-11T14:35:42.269212Z"
    },
    {
      "createdAt": "2025-02-11T14:35:40.008906Z",
      "id": "2stp5GgcnJoakGgLhl8mqJi4i5n",
      "updatedAt": "2025-02-11T14:35:40.008906Z"
    }
  ]
}

@set with relationships

The @set attribute has been limited to just setting a model field from actions inputs and ctx. This extends @set functionality to support looking up fields in related models in both create and update actions.

A nice example of this is to set the price of a purchase order once-off from a product's standard price:

model Order {
    fields {
        price Decimal
        quantity Number
        product Product
        total Decimal @computed(order.price * order.quantity)
    }
    actions {
        create createOrder() with (product.id, quantity, customer.id) {
            @set(order.price = order.product.standardPrice)
        }
        update resetOrderPrice(id) {
            @set(order.price = order.product.standardPrice)
        }
    }
}
 
model Product {
    fields {     
        standardPrice Decimal
    }
}

Fixes and Improvements

We've also released some other fixes and improvements to the CLI, Schema Validator and Console Tools; please refer to our changelog (opens in a new tab) on our repository page for a complete list.

For any issues or feedback, please visit the support channel on our community discord (opens in a new tab) or contact us at help@keel.so.

Thank you for using Keel!