Datasource factory

The datasource factory creates datasource instances for the two types of datasources (Optionlists in JavaScript SDK).

Note

In the following code examples, the client variable refers to the ContentHubClient instance. When using the JavaScript SDK, the variable name can be chosen freely, but is also called client at instantiation in the documentation.

Creating flat datasources

To create a flat datasource, pass a unique name for the datasource to the createFlatOptionList method:

RequestResponse
await client.optionListFactory.createFlatOptionList("NewFlatDataSource");

Creating hierarchical datasources

To create a hierarchical datasource, pass a unique name for the datasource to the createHierarchicalOptionList method:

RequestResponse
await client.optionListFactory.createHierarchicalOptionList("NewHierarchicalDataSource");
Note

The datasource instance is not persisted. The factory only creates an object. If the datasource needs to be persisted, use the createAsync method on the IDataSourcesClient.

Do you have some feedback for us?

If you have suggestions for improving this article,