Path: redb/redb.Templates/templates/redb-bff/RedbBff.Backend/Controllers/CategoriesController.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Templates/templates/redb-bff/RedbBff.Backend/Controllers/CategoriesController.cs
----
using redb.Core.Models.Contracts;
using redb.Core.Models.Entities;
using redb.Route.Controllers.Attributes;
using RedbBff.Backend.Props;
using RedbBff.Models;
namespace RedbBff.Backend.Controllers;
/// The category tree: every root with its subtree, add a node, delete a subtree.
[Route("/api/categories")]
public sealed class CategoriesController : ApiController
{
/// The top-level nodes from a tree query, each loaded with its subtree.
[HttpGet]
public async Task> Tree()
{
var redb = Redb;
var roots = await redb.TreeQuery().WhereRoots().ToListAsync();
var result = new List();
foreach (var root in roots)
result.Add(ToNode(await redb.LoadTreeAsync(root.Id)));
return result;
}
/// A top-level node, or a child of ParentId.
[HttpPost]
public async Task