UTS-eResearch / ro-crate-js

Research Object Crate (RO-Crate) utilities
GNU General Public License v3.0
2 stars 6 forks source link

Add lookup graph traversal methods #8

Closed ptsefton closed 4 years ago

ptsefton commented 4 years ago

Add convenience methods for following the graph without having to do this:

if (item["militaryService"] && item["militaryService"]["@id"]) {
                const mil = crate.getItem(item["militaryService"]["@id"]);
}

eg:

const mil = item.resolve({"property": "miltaryService"});

And also:

const militaryServiceName = item.resolve({"property": "miltaryService"}, ({"property": "name"});

AND a version with constraints:

const militaryServiceName = item.resolve([({"property": "@reverse"}, ({"property": "object", "includes": {"@type", "Action"}}]);

Which would follow @reverse properties, and find Items of @type Action that have an objectproperty that refers to item.