DEV Community

Kevin Jump
Kevin Jump

Posted on

Early Adopter's guide to Umbraco v14 [Trees] - Repositories

Once we have our data out in to a datasource, we can add it to our repository pattern and we are soooo nearly there !

Code for these posts is avalible in our TimeDashboard Repository FrontEnd (typescript) & Backend (c#)

Tree Repository.

Again to save on so much code, we are extending an umbraco UmbTreeRepositoryBase class.

This class takes our item/entity models. which is why we set them up first.

export class TimeTreeRepository extends 
    UmbTreeRepositoryBase<TimeTreeItemModel, TimeTreeRootModel>
    implements UmbApi
Enter fullscreen mode Exit fullscreen mode

in our constructore we pass our datasource, and a refernce to the store context.

    constructor(host: UmbControllerHost) {
        super(host, TimeTreeServerDataSource, TIME_TREE_STORE_CONTEXT);
    }
Enter fullscreen mode Exit fullscreen mode

The all we have to do is prodivde a requestTreeRoot method to return our tree route model

    async requestTreeRoot() {

        const data: TimeTreeRootModel = {
            unique: null,
            entityType: TIME_TREE_ROOT_ITEM_TYPE,
            name: 'time',
            hasChildren: true,
            isFolder: true,
        };

        return { data };

    }
Enter fullscreen mode Exit fullscreen mode

now we have a repo, we are set to define everything....

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay