Given
class Category(db.Model): name = db.Stringproperty()
Say I have a nested hierarchy
-root |-a | |-b | |-c |-x |-y |-z1 |-z2
where a
's parent is root
, b
's parent is a
, c
's parent is b
etc.
Is there a simple way by which I could move node y
from x
to b
such that z1
and z2
continue to remain children of y
:
-root |-a | |-b | |-c | |-y | |-z1 | |-z2 |-x
That would mean I simply change y
's parent.
However, if that is not possible than it would require
ny = Category(parent=b, name=y)
and y
creating a new record that has ny
as a parent and y
and its children. Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. Datastore features include: Atomic transactions. Datastore can execute a set of operations where either all succeed, or none occur. High availability of reads and writes.
const taskKey = datastore. key('Task'); await datastore. delete(taskKey);
The Python Datastore API provides two classes for preparing and executing queries: Query uses method calls to prepare the query. GqlQuery uses a SQL-like query language called GQL to prepare the query from a query string.
The parent relationship is encoded in an entity's key, and the key is immutable once created, so no, you can't change the key of an existing entity. In order to do so, you need to reinsert all the relevant items with new keys.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With