/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/core/database/src/fields/timestamp.ts
16 строк
560 B
DMehaffy
enhancement(database): reduce per-column work when mapping rows to entities (#27144)
03 авг 2026, 10:34
Не верифицирован
03 авг 2026, 10:34
10e3b9c
Код
Авторство
О чём код?
import { parseDateTimeOrTimestamp } from './shared/parsers'; import Field from './field'; export default class TimestampField extends Field { toDB(value: unknown) { return parseDateTimeOrTimestamp(value); } fromDB(value: unknown) { // Same redundant re-parse as `datetime`. `format(cast, 'T')` is the epoch in // milliseconds as a string, which `getTime()` already gives us. const cast = value instanceof Date ? value : new Date(value as any); const time = cast.getTime(); return Number.isNaN(time) ? null : String(time); } }