Datasource factory
The datasource factory creates datasource instances for the two types of datasources (Optionlists in JavaScript SDK).
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:
await client.optionListFactory.createFlatOptionList("NewFlatDataSource");
Creating hierarchical datasources
To create a hierarchical datasource, pass a unique name for the datasource to the createHierarchicalOptionList method:
await client.optionListFactory.createHierarchicalOptionList("NewHierarchicalDataSource");
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.