Skip to content

Streamline resource creation api #798

Description

@Polleps

Creating new resources with @tomic/lib is currently very unintuitive, to create a resource you need to "fetch" or "get" a resource but tell the store it is new. It also doesn't set any properties so you can't directly save it.

We should have a separate function to create new resources e.g. store.newResource(). Ideally this also takes a class(es) and parent because you have to set those on all resources anyway.

Something like

const resource = store.newResource('https://my-folder', dataBrowser.classes.folder, 'https://my-parent');

Alternatively we could add an overload to the Resource constructor e.g.

const resource = new Resource('https://my-folder', dataBrowser.classes.folder, 'https://my-parent');

Maybe we can add a way to quickly set additional properties too

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions