( model: IModelService, item: any, )
| 686 | }; |
| 687 | |
| 688 | export const getSearchData = ( |
| 689 | model: IModelService, |
| 690 | item: any, |
| 691 | ): Record<string, any> => { |
| 692 | const result: Record<string, any> = {}; |
| 693 | |
| 694 | if (model.instance.search) { |
| 695 | for (const field of model.instance.search) { |
| 696 | result[field] = item[field]; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | // If there is a deleted at column, we should put it to the index data |
| 701 | if (model.instance.deletedAtColumn) { |
| 702 | result[model.instance.deletedAtColumn] = |
| 703 | item[model.instance.deletedAtColumn]; |
| 704 | } |
| 705 | |
| 706 | // We should add the parent relations if there is any |
| 707 | const relations = model.relations.filter( |
| 708 | (relation) => relation.type === Relationships.HAS_ONE, |
| 709 | ); |
| 710 | for (const relation of relations) { |
| 711 | result[relation.foreignKey] = item[relation.foreignKey]; |
| 712 | } |
| 713 | |
| 714 | return result; |
| 715 | }; |
no outgoing calls
no test coverage detected