dist/cjs/Mock/mockProperties.js
function mockProperties(db, config = { relationshipBehavior: "ignore" }, exceptions) {
    return async (record) => {
        const meta = ModelMeta_1.getModelMeta(record);
        const props = meta.properties;
        const recProps = {};
        // below is needed to import faker library
        props.map(prop => {
            const p = prop.property;
            recProps[p] = mockValue_1.default(db, prop);
        });
        const finalized = Object.assign({}, recProps, exceptions);
        // write to mock db and retain a reference to same model
        record = await __1.Record.add(record.modelConstructor, finalized, {
            silent: true
        });
        return record;
    };
}
function mockProperties(db, config = { relationshipBehavior: "ignore" }, exceptions) {
    return async (record) => {
        const meta = ModelMeta_1.getModelMeta(record);
        const props = meta.properties;
        const recProps = {};
        // below is needed to import faker library
        props.map(prop => {
            const p = prop.property;
            recProps[p] = mockValue_1.default(db, prop);
        });
        const finalized = Object.assign({}, recProps, exceptions);
        // write to mock db and retain a reference to same model
        record = await __1.Record.add(record.modelConstructor, finalized, {
            silent: true
        });
        return record;
    };
}
function mockProperties ( db , config = { relationshipBehavior : "ignore" } , exceptions ) { return async ( record ) => { const meta = ModelMeta_1 . getModelMeta ( record ) ; const props = meta . properties ; const recProps = { } ; // below is needed to import faker library props . map ( prop => { const p = prop . property ; recProps [ p ] = mockValue_1 . default ( db , prop ) ; } ) ; const finalized = Object . assign ( { } , recProps , exceptions ) ; // write to mock db and retain a reference to same model record = await __1 . Record . add ( record . modelConstructor , finalized , { silent : true } ) ; return record ; } ; }
adds mock values for all the properties on a given model
adds mock values for all the properties on a given model