Property.is_multi_valued#
relationalai
#Property.is_multi_valued
Returns True
if the property is multi-valued and False
otherwise.
Example#
Use .is_multi_valued
to check if a property is multi-valued:
#import relationalai as rai
# Create a model named "pets" with Person and Pet types.
model = rai.Model("people")
Person = model.Type("Person")
Pet = model.Type("Pet")
with model.rule():
# Add a person named Alice with two pets.
alice = Person.add(name="Alice")
alice.pets.extend([
Pet.add(name="Fluffy", type="cat"),
Pet.add(name="Spot", type="dog")
])
# The 'pets' property of the Person type is multi-valued.
print(Person.pets.is_multi_valued)
# Output:
# True
# The 'name' property of the Person type is not multi-valued.
print(Person.name.is_multi_valued)
# Output:
# False