@@ -0,0 +1,1072 @@
+%22%22%22%0AExamples using DynamoDB indexes%0A%22%22%22%0Afrom datetime import datetime%0Afrom pynamodb.models import Model, GlobalSecondaryIndex, AllProjection%0Afrom pynamodb.attributes import UTCDateTimeAttribute, UnicodeAttribute, NumberAttribute%0A%0A%0Aclass ViewIndex(GlobalSecondaryIndex):%0A    %22%22%22%0A    This class represents a global secondary index%0A    %22%22%22%0A    read_capacity_units = 2%0A    write_capacity_units = 1%0A    # All attributes are projected%0A    projection = AllProjection()%0A%0A    # This attribute is the hash key for the index%0A    # Note that this attribute must also exist%0A    # in the model%0A    view = NumberAttribute(default=0, hash_key=True)%0A%0A%0Aclass TestModel(Model):%0A    %22%22%22%0A    A test model that uses a global secondary index%0A    %22%22%22%0A    table_name = 'TestModel'%0A    forum = UnicodeAttribute(hash_key=True)%0A    thread = UnicodeAttribute(range_key=True)%0A    view_index = ViewIndex()%0A    view = NumberAttribute(default=0)%0A%0A%0A# Indexes can be queried easily using the index's hash key%0Afor item in TestModel.view_index.query(1):%0A    print(%22Item queried from index: %7B0%7D%22.format(item))%0A

Index Query example