import MetadataController from "issue-metadata";
const controller = new MetadataController('my_metadata_ID', {
owner: 'my_name',
repo: 'my_repo',
headers: {
authorization: `Bearer my_GITHUB_API_TOKEN`,
},
});
await controller.setMetadata(1, 'foo', 'bar');
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
await controller.setMetadata(1, { foo: 'bar' });
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
await controller.setMetadata(1, 'complex', [{ bar: 'baz' }]);
// In body of issue #1:
// <!-- my_metadata_ID = {"complex":[{"bar":"baz"}]} -->
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
let metadata = await controller.getMetadata(1, 'foo');
// metadata === "bar"
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
metadata = await controller.getMetadata(1);
// metadata === {foo: "bar"}
// In body of issue #1:
// <!-- my_metadata_ID = {"complex":[{"bar":"baz"}]} -->
metadata = await controller.getMetadata(1, 'complex');
// metadata === [{ bar: 'baz' }]
Important
In current implementation when setting metadata, it always overrides the previous metadata. For example:
// <!-- my_metadata_ID = {"foo":"bar", "complex":[{"bar":"baz"}]} -->
await controller.setMetadata(1, 'complex', [{ foo: 'bar' }]);
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar", "complex":[{"foo":"bar"}]} -->