UNPKG

@webiny/api-headless-cms-ddb-es

Version:

DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.

39 lines (38 loc) 993 B
import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js"; import { FIELD_INDEXING_DEFAULT } from "../constants.js"; class DefaultFieldIndexImpl { fieldType = FIELD_INDEXING_DEFAULT; toIndex({ field, fieldRegistry, value }) { const fieldType = fieldRegistry.get(field.type); if (fieldType?.isSearchable === true) { return { value }; } return { rawValue: value }; } fromIndex({ field, fieldRegistry, value, rawValue }) { const fieldType = fieldRegistry.get(field.type); const isSearchable = fieldType?.isSearchable ?? false; if (isSearchable) { return value === undefined ? rawValue : value; } return rawValue === undefined ? value : rawValue; } } export const DefaultFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({ implementation: DefaultFieldIndexImpl, dependencies: [] }); //# sourceMappingURL=DefaultFieldIndex.js.map