import { BaseField , BaseFieldParams , NotImplementedError } from './base' ; import { RecordModel } from '../models/record-model' ; import { Record , RecordRawData } from '../datatypes/record' ; import { utilRecordModelFromRawData } from '../utils' ; import { SaveQuery , ChildQueryDescriber } from '../query/query' ; export interface ForeignRecordFieldParams extends BaseFieldParams { models : RecordModel [ ] ; } export class ForeignRecordField extends BaseField { internalName = 'ForeignRecordField' ; fromRAWtoInternal ( value ) { var model = utilRecordModelFromRawData ( this . backend , value ) ; return model . constructRecord ( false , value ) ; } fromInternalToRAW ( record ) { return record . __director__ . extractRAWData ( ) ; } getSaveQueries ( value ) { var result = [ ] ; if ( ! value ) return [ ] ; return [ { handle : '' , query : value . __director__ . getSaveQuery ( ) } ] ; } }