class Model1
attribute1 = ndb.StringProperty()
class Model2
attribute2 = = ndb.LocalStructuredProperty(Model1, repeated=True)
class Model3
attribute3 = = ndb.LocalStructuredProperty(Model2, repeated=True)
class Model4
attribute4 = = ndb.LocalStructuredProperty(Model3, repeated=True)
class Model1
attribute1 = ndb.StringProperty()
class Model2
attribute2 = = ndb.KeyProperty(kind=Model1, repeated=True)
class Model3
attribute3 = = ndb.KeyProperty(kind=Model2, repeated=True)
class Model4
attribute4 = = ndb.KeyProperty(kind=Model3, repeated=True)
[ { "attribute4": [ { "attribute3": [ { "attribute2": [ { "attribute1": "somevalue" } ] } ] } ] }]
--
You received this message because you are subscribed to the Google Groups "appengine-ndb-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appengine-ndb-di...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
A list of one Model4 looks like this:
[
{
"attribute4": [
{
"attribute3": [
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
}
]
},
{
"attribute3": [
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
}
]
},
{
"attribute3": [
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
},
{
"attribute2": [
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
},
{
"attribute1": "somevalue"
}
]
}
]
}
]
}
]
I realized that I was using a terrible method to retrieve the data. I got all the Model4, iterated on the list of Model4's, got all the Model3's in each Model4 and repeated the same process for each level. This is how I got the 5.5 seconds.
I tried to optimize the method but the lowest time I was able to get was 3.5 seconds. I get all the Model4's, iterate on the list of Model4's, got all the keys that I need of Model3, get the Model3's with the list of keys, assign the Model3 to the correct object of Model4 and repeat the same process for each level.
I hope this is not that confusing... I am aware that my method is not that great but I am open for suggestions if you have any idea of how to improve it.
I actually think that indexing the models is a very interesting idea. Using your example, how exactly should I index it? Should an User and its attributes (Device, Messages and Lines) be under the same index name? Should the index contain only keys or should it contain a replica of the objects? Does this mean that when I update the data, I will also have to update the index?