Files
ent/examples/fs
Justin Johnson 38d4d5fb5c entc/gen: propagate nodes post-save mutations (#2525)
* Failing test

* Fix propagating entirely models from OpCreate hook

* Apply suggestions from code review

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* whitespace

* Failing test for updateone

* fix for updateone

* Regnerate

* regen from root

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-05-05 11:19:21 +03:00
..

Recursive Traversal Using CTE

In this example, we create a file system with a tree structure, and want to query all "undeleted" files. A file is considered as "deleted", if it's marked as "deleted" (a bool field), or any of its parents is marked as "deleted".

Given the following tree structure:

a/
├─ b/
│  ├─ ba
│  ├─ bb
│  └─ bc (deleted)
├─ c/ (deleted)
│  ├─ ca
│  └─ cb
└─ d (deleted)

Query "undeleted" files should return the following structure:

a/
└─ b/
   ├─ ba
   └─ bb

As you can see, in order to check if "cb" (or "ca") is "deleted", we need to "look behind" recursively until we find a "deleted" parent, or reach the root ("a").

Generate Assets

go generate ./...

Run Example

go test