Skip to content

Conversation

@bevzzz
Copy link
Collaborator

@bevzzz bevzzz commented Oct 7, 2025

This PR extends data type support to include object and object[] properties.
The following is possible:

  1. Define nested collection properties:
client.collection.create(
  "Buildings", c -> c.properties(
    Property.object("address", p -> p.nestedProperties(
      Property.text("street"),
      Property.integer("building_nr")
    ),
    Property.objectArray("apartments", p -> p.nestedProperties(
      Property.int("door_nr"),
      Property.number("area")
    )
  )
);
  1. Insert(-Many) objects with nested properties. Here, object is allowed to be a Map or a custom record (leveraging our ORM) and and the container object[] can be represented either a List or an Array.
buildings.data.insertMany(
  Map.of(
    "address", Map.of("street", "Broadway", "building_nr", 124),
    "apartments", List.of(
      Map.of("door_nr", 1, "area", 54),
      Map.of("door_nr", 2, "area", 20)
    )
  ),
  Map.of(
    "address", new Address("Broadway", 81),
    "apartments", List.of(
      new Apartment(1, 47),
      new Apartment(2, 95)
    )
  )
);

Where Address and Apartment are records defined according to the existing "ORM"-rules (e.g. @Property annotation sets custom names for properties, etc). 📍

  1. Query
var building_1 = buildings.query.byId("building-1").get();

assert building_1.properties().get("address") instanceof Map<?, ?>;
assert building_1.properties().get("apartments") instanceof List<?>;

📍 Limitation: At the moment nested properties aren't supported in the higher-level ORM objects, e.g. it's not possible to do:

@Collection("Buildings")
record Building(Map<String, Object> address, Apartment[] apartments){}

This should be trivial to implement, but is probably not needed for GA.

@bevzzz bevzzz marked this pull request as draft October 7, 2025 14:37
Copy link

@orca-security-eu orca-security-eu bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

bevzzz added 4 commits October 7, 2025 17:22
Default behaviour is converting everything to floats,
which may be confusing especially when logging request bodies
@bevzzz bevzzz marked this pull request as ready for review October 7, 2025 15:46
@bevzzz bevzzz self-assigned this Oct 8, 2025
@bevzzz bevzzz merged commit 60c03e9 into v6 Oct 13, 2025
2 checks passed
@bevzzz bevzzz deleted the v6-nested-object branch October 13, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants