Generic list of items that is stored in a given block.
Note: If you make any changes to the item contents manually, do not forget to notify the list about the changes by calling updated(itemID)
method.
Note: Each list item should at least hold a numerical ID ("id" field). The ID of a list item should be unique in that list. If the items have an amount accociated, the field "amount" should also be given. You can get the next unique free ID from nextID property.
Note: If you remove the items from the list bypassing the removeItem()
call, do not forget to call updated()
method without any parameters to notify the server that the whole list was updated.
This class is described in detail in Generic Containers article.
new (s:ServerClass, b:Block, a:String)
Creates a new generic list of items on top of cache block.
Parameters:
s
Slave server.
b
Cache block.
a
Block attribute name.
Adds an item to the list.
Parameters:
item
New item.
Returns:
Operation status.
ok
- operation successful.
idExists
- item with this ID exists in the list.
getByField (field:String, val:Dynamic):Item
Returns the first list item with a given field value.
Parameters:
field
List item field.
val
List item value.
Returns:
List item. Returns null if not found.
Returns list item index by its ID.
Parameters:
id
List item ID.
Returns:
List item index. Returns -1 if not found.
Returns list item by its ID.
Parameters:
id
List item ID.
Returns:
List item. Returns null if not found.