HATEOAS-first backend framework.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

data-source.ts 410 B

12345678910111213141516
  1. import {DataSource} from '../../src/backend/data-source';
  2. export const autoIncrement = async (dataSource: DataSource) => {
  3. const data = await dataSource.getMultiple() as Record<string, string>[];
  4. const highestId = data.reduce<number>(
  5. (highestId, d) => (Number(d.id) > highestId ? Number(d.id) : highestId),
  6. -Infinity
  7. );
  8. if (Number.isFinite(highestId)) {
  9. return (highestId + 1);
  10. }
  11. return 1;
  12. };