Skip to main content

SingleResourceContainerMixin

This mixin is very similar to ControlledContainerMixin except that the container will contain a single resource. This resource will be created on start, or when the storage is created in the case of Pod provider config. The content of the resource can be defined with the initialValue setting. The get, patch and put actions can be called without a resourceUri.

Usage

const { SingleResourceContainerMixin } = require('@semapps/ldp');

module.exports = {
name: 'bot',
mixins: [SingleResourceContainerMixin],
settings: {
acceptedTypes: ['Application'],
initialValue: {
name: 'Super bot'
}
// Other container options...
}
};

Settings

All container options are accepted.

These container options are overridden with the following values:

  • readOnly: true
  • excludeFromMirror: true
  • activateTombstones: false

Actions

he following service actions are available:

initializeResource

Automatically called on start, or when the storage is created in the case of Pod provider config

Parameters
PropertyTypeDefaultDescription
webIdURIUser doing the action (required in Pod provider config)

getResourceUri

Return the URI of the single resource

Parameters
PropertyTypeDefaultDescription
webIdURIUser doing the action (required in Pod provider config)