Skip to content

Commit

Permalink
fix: createdUpdatedIdFields to return string id
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Apr 16, 2022
1 parent 7a7aaa2 commit 4e15582
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/model.util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringId } from '@naturalcycles/nodejs-lib'
import { CreatedUpdated, CreatedUpdatedId, ObjectWithId } from '@naturalcycles/js-lib'
import { CreatedUpdated, CreatedUpdatedId } from '@naturalcycles/js-lib'

export function createdUpdatedFields(
existingObject?: Partial<CreatedUpdated> | null,
Expand All @@ -12,8 +12,8 @@ export function createdUpdatedFields(
}

export function createdUpdatedIdFields(
existingObject?: Partial<CreatedUpdatedId> | null,
): CreatedUpdatedId {
existingObject?: Partial<CreatedUpdatedId<string>> | null,
): CreatedUpdatedId<string> {
const now = Math.floor(Date.now() / 1000)
return {
created: existingObject?.created || now,
Expand All @@ -22,12 +22,6 @@ export function createdUpdatedIdFields(
}
}

export function idField(existingObject?: Partial<CreatedUpdatedId> | null): ObjectWithId {
return {
id: existingObject?.id || stringId(),
}
}

export function deserializeJsonField<T = any>(f?: string): T {
return JSON.parse(f || '{}')
}
Expand Down

0 comments on commit 4e15582

Please sign in to comment.