import {dataSources, Resource} from '../../src'; import {DataSource} from '../../src/backend/data-source'; import {BaseDataSource} from '../../src/common/data-source'; export const autoIncrement = async (dataSource: BaseDataSource) => { const data = await (dataSource as DataSource).getMultiple() as Record[]; const highestId = data.reduce( (highestId, d) => (Number(d.id) > highestId ? Number(d.id) : highestId), -Infinity ); if (Number.isFinite(highestId)) { return (highestId + 1); } return 1; }; export const dataSource = (resource: Resource) => new dataSources.jsonlFile.DataSource(resource, 'examples/basic');