tabula-rasa usage examples

node v0.12.18
version: 1.0.0
endpointsharetweet
var Presentation = require("tabula-rasa") // create a collection var c = new Presentation.Collections.Collection() // create sub-collections var c1 = new Presentation.Collections.Collection( { _id: 'c1', '@id': 'https://somedomain.com/c1', label: "Collection 1" } ) var c2 = new Presentation.Collections.Collection( { _id: 'c2', '@id': 'https://somedomain.com/c2', label: "Collection 2" } ) var c3 = new Presentation.Collections.Collection( { _id: 'c3', '@id': 'https://somedomain.com/c3', label: "Collection 3" } ) // add sub collections to the first collection c.collections.add([c1,c2]) // add a sub-collection to a sub-collection c.collections.get('c1').collections.add([c3]) // add some manifests to the root collection c.manifests = new Presentation.ManifestList() c.manifests.add([ { _id: 'foo', '@id': 'bar', label: [{'@value':'Manifest 1'}]}, { _id: 'fez', '@id': 'baz', label: [{'@value':'Manifest 2'}]} ]) // get manifest by internal id and by json-ld @id console.log(c.manifests.get('foo').label[0]['@value']) c.manifests.get('baz', '@id').label[0]['@value']
Loading…

no comments

    sign in to comment