sepia-search-motore-di-rice.../server/lib/elastic-search-avatar.ts

44 lines
778 B
TypeScript
Raw Normal View History

2020-02-19 15:39:35 +01:00
import { Avatar } from '@shared/models'
function formatAvatarForAPI (obj: { avatar?: Avatar }) {
if (!obj.avatar) return null
return {
path: obj.avatar.path,
createdAt: obj.avatar.createdAt,
updatedAt: obj.avatar.updatedAt
}
}
function formatAvatarForDB (obj: { avatar?: Avatar }) {
if (!obj.avatar) return null
return {
path: obj.avatar.path,
createdAt: obj.avatar.createdAt,
updatedAt: obj.avatar.updatedAt
}
}
function buildAvatarMapping () {
return {
path: {
type: 'keyword'
},
createdAt: {
type: 'date',
format: 'date_optional_time'
},
updatedAt: {
type: 'date',
format: 'date_optional_time'
}
}
}
export {
formatAvatarForAPI,
formatAvatarForDB,
buildAvatarMapping
}