objectbox / objectbox-python

Superfast on-device object & vector database for Python
https://objectbox.io/
Apache License 2.0
113 stars 17 forks source link

complex entities #19

Closed piniSolomon closed 7 months ago

piniSolomon commented 7 months ago

Hi, I'm new to the objectbox DB and I want to define the first entity to store in the database, I want to create an entity that one of the members is another entity


@Entity(id=3, uid=3)
class Engine:
    id=Id(id=1, uid=1005)
    model= Property(str, id=2, uid=1002)

@Entity(id=2, uid=2)
class Car:
    id=Id(id=1, uid=1001)
    name= Property(str, id=2, uid=1003)
    engine=Property(Engine, id=3, uid=1004)

I would like to create and save the car entity with the engine members.

Is it possible?

on the same logic I would like to create entities with inheritance

greenrobot-team commented 7 months ago

This would be done using the relations feature. But according to the README, it is not available for the Python library, yet.

Also see #7

ariel3081 commented 7 months ago

Hi, is it available for the C++ library?

greenrobot-team commented 7 months ago

@ariel3081 Yes, relations are available for the C++ library. See https://cpp.objectbox.io/entity-annotations.