import BaseEntity from '../models/BaseEntity' ; import getSlothData from '../utils/getSlothData' ; import { join } from 'path' ; import getProtoData from '../utils/getProtoData' ; import SlothView from './SlothView' ; see export template S param { ( doc : S , emit : Function ) => void } fn param { string } docId param { string } viewId returns export default function SlothIndex < S , V extends string = string > ( viewId ? , docId ? ) { return ( target , key ) => { const field = getProtoData ( target ) . fields . find ( field => field . key === key ) ; if ( ! field ) { throw new Error ( 'Please use SlothIndex on top of a SlothField' ) ; } SlothView ( new Function ( 'doc' , 'emit' , `emit(doc['${ field . docKey }'].toString());` ) as any , viewId , docId ) ( target , key ) ; } ; }