- import {DataSource} from '../../src/backend/data-source';
-
- export const autoIncrement = async (dataSource: DataSource) => {
- const data = await dataSource.getMultiple() as Record<string, string>[];
-
- const highestId = data.reduce<number>(
- (highestId, d) => (Number(d.id) > highestId ? Number(d.id) : highestId),
- -Infinity
- );
-
- if (Number.isFinite(highestId)) {
- return (highestId + 1);
- }
-
- return 1;
- };
|