May 23, 2024

#changelog

ensure_field() simplifies field existence checks in APL


Changelog Screenshot
Author
Tola Ore-Aruwaji

Developer Relations Engineer

We’re excited to introduce the ensure_field() function in APL, a convenient way to ensure the existence of a field and return its value or a typed nil if it doesn't exist. This function simplifies working with fields that may or may not be present in your data, making your queries more robust and reducing the need for complex null checks.

  • Field existence check: Checks if the specified field exists in the data and returns its value if it does. If the field doesn't exist, it returns a typed nil based on the provided field type.

  • Simplified field access: Access fields without worrying about null values or missing fields. The function handles these cases smoothly, making your queries cleaner and more readable.

  • Future-proof queries: Prepare your queries for fields that are expected to exist in the future. For example, you can use ensure_field() to write logic around a field you know will be added soon, ensuring your queries are ready when the field becomes available.

  • Migrating schemas: When migrating to a new schema that introduces new fields, ensure_field() can help you write queries that work with both the old and new schemas during the transition period.

Check out the documentation to learn more and get started.

Share