Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does ndb have a list property

Instead of a single StringProperty(), I want to store a list of strings

class BlogPost(ndb.Model):
    s1 = ndb.StringProperty(required=True)
    s2 = ndb.StringProperty(required=True)
    s3 = ndb.StringProperty(required=True)

I would rather go

class BlogPost(ndb.Model):
    my_strings = ndb.StringListProperty() # does this exist?
like image 247
robert king Avatar asked Aug 10 '12 04:08

robert king


1 Answers

yes, use a repeated property:

Any property with repeated=True becomes a repeated property. The property takes a list of values of the underlying type, rather than a single value. For example, the value of a property defined with IntegerProperty(repeated=True) is a list of integers.

see the docs: Repeated Properties

like image 176
robert king Avatar answered Oct 13 '22 21:10

robert king