John
John

Reputation: 4028

Access an item in ListProperty

I have a Model like below

class XXX(db.Model):
    f_list = db.ListProperty(int,indexed=True) #Store 50000 numbers

How to access the 3rd item in f_list?

Upvotes: 0

Views: 55

Answers (1)

Tim Hoffman
Tim Hoffman

Reputation: 12986

You would use a standard list indexing operation to access the 3rd item in the list

some_obj.f_list[2]

However the entire entity will be loaded into memory when you fetch an instance of XXX

There is no way around it with the model you have.

Even a projection query will return the entire list.

The only possibility would be to start creating multiple sub entities.

Upvotes: 2

Related Questions