Operations with arrays
Accessing array items
In PonyORM array indexes are zero-based, as in Python. It is possible to use negative indexes to access array from the end. You can also use array slices.
Select specific item of array
select(p.tags[2] for p in Product)[:] # third element
select(p.tags[-1] for p in Product)[:] # last element
Using slice
select(p.tags[:5] for p in Product)[:] # first five elements
Note
Steps are not supported for slices.
Check if item or list of items in or not in array
select(p for p in Product if 'apple' in p.tags)[:]
select(p for p in Product if ['LCD', 'DVD', 'SSD'] in p.tags)[:]
Change array’s items
product = Product.select().first()
product.tags.remove('factory-new')
product.tags.append('reconstructed')