0
votes

I'm wondering what the best way to store data is for my situation. I want to store a list of properties, like phone numbers, for one person. For example:

name: John Doe numbers: 0998234, 23443145, 2341234, 3425425

The problem is, given a number how can I search through the 'numbers' property to locate John Doe. From what I've read there's no LIKE statement using GAE?

Thanks,

EDIT:

I'm going to use python to scrap data and insert it into a datastore. Then I'm going to query this data using Google Cloud Endpoints (Java JPA Querys). At the minute I cannot search through multiple values in a property & return the corresponding entity as there is no LIKE statement available in GAE datastore.

1

1 Answers

0
votes

You can use the repeated property. Here is an example:

class User(ndb.Model):
    name = ndb.StringProperty(required=True)
    numbers = ndb.StringProperty(repeated=True)

# save a user
john_doe = User(name='John Doe',
                numbers=['0998234', '23443145', '2341234', '3425425'])
john_doe.put()

# query with a number '0998234'
query = User.query(User.numbers == '0998234')
for matched_user in query:
    # do something with matched_user
    ...
    ...