dist/Definitions/Decorators.js
function FieldReference(typeFunction, fieldOptions = {}) {
    return function (target, key) {
        let fieldType = Reflect.getMetadata("design:type", target, key);
        let schema = MongoSchemaRegistry_1.MongoSchemaRegistry.getSchema(target.constructor.name);
        if (!schema) {
            schema = new MongoSchema_1.MongoSchema(target.constructor);
            MongoSchemaRegistry_1.MongoSchemaRegistry.register(target.constructor.name, schema);
        }
        if (!typeFunction) {
            typeFunction = type => {
                return fieldOptions.type || Reflect.getMetadata("design:type", target, key).name;
            };
        }
        fieldOptions.foreignField = fieldOptions.foreignField || "_id";
        if (!fieldType || fieldType.name != "Array") {
            fieldOptions.relationType = MongoSchema_1.ERelationType.SingleObjectId;
        }
        if (fieldType && fieldType.name == "Array") {
            fieldOptions.relationType = MongoSchema_1.ERelationType.ArrayObjectId;
        }
        schema.addField(key, typeFunction, fieldOptions);
    };
}
function FieldReference(typeFunction, fieldOptions = {}) {
    return function (target, key) {
        let fieldType = Reflect.getMetadata("design:type", target, key);
        let schema = MongoSchemaRegistry_1.MongoSchemaRegistry.getSchema(target.constructor.name);
        if (!schema) {
            schema = new MongoSchema_1.MongoSchema(target.constructor);
            MongoSchemaRegistry_1.MongoSchemaRegistry.register(target.constructor.name, schema);
        }
        if (!typeFunction) {
            typeFunction = type => {
                return fieldOptions.type || Reflect.getMetadata("design:type", target, key).name;
            };
        }
        fieldOptions.foreignField = fieldOptions.foreignField || "_id";
        if (!fieldType || fieldType.name != "Array") {
            fieldOptions.relationType = MongoSchema_1.ERelationType.SingleObjectId;
        }
        if (fieldType && fieldType.name == "Array") {
            fieldOptions.relationType = MongoSchema_1.ERelationType.ArrayObjectId;
        }
        schema.addField(key, typeFunction, fieldOptions);
    };
}
function FieldReference ( typeFunction , fieldOptions = { } ) { return function ( target , key ) { let fieldType = Reflect . getMetadata ( "design:type" , target , key ) ; let schema = MongoSchemaRegistry_1 . MongoSchemaRegistry . getSchema ( target . constructor . name ) ; if ( ! schema ) { schema = new MongoSchema_1 . MongoSchema ( target . constructor ) ; MongoSchemaRegistry_1 . MongoSchemaRegistry . register ( target . constructor . name , schema ) ; } if ( ! typeFunction ) { typeFunction = type => { return fieldOptions . type || Reflect . getMetadata ( "design:type" , target , key ) . name ; } ; } fieldOptions . foreignField = fieldOptions . foreignField || "_id" ; if ( ! fieldType || fieldType . name != "Array" ) { fieldOptions . relationType = MongoSchema_1 . ERelationType . SingleObjectId ; } if ( fieldType && fieldType . name == "Array" ) { fieldOptions . relationType = MongoSchema_1 . ERelationType . ArrayObjectId ; } schema . addField ( key , typeFunction , fieldOptions ) ; } ; }
Single field representing a singl object
Single field representing a singl object