"use strict";

var cov_15erv6hag8 = function () {
    var path = "/home/travis/build/parpeoficial/stackerjs-orm/src/Util.js",
        hash = "f76c7dc562eee0c836160a9ff63f349063dfd167",
        Function = function () {}.constructor,
        global = new Function('return this')(),
        gcv = "__coverage__",
        coverageData = {
        path: "/home/travis/build/parpeoficial/stackerjs-orm/src/Util.js",
        statementMap: {
            "0": {
                start: {
                    line: 7,
                    column: 23
                },
                end: {
                    line: 7,
                    column: 47
                }
            },
            "1": {
                start: {
                    line: 9,
                    column: 21
                },
                end: {
                    line: 9,
                    column: 49
                }
            },
            "2": {
                start: {
                    line: 10,
                    column: 26
                },
                end: {
                    line: 10,
                    column: 36
                }
            },
            "3": {
                start: {
                    line: 11,
                    column: 8
                },
                end: {
                    line: 25,
                    column: 11
                }
            },
            "4": {
                start: {
                    line: 13,
                    column: 12
                },
                end: {
                    line: 24,
                    column: 13
                }
            },
            "5": {
                start: {
                    line: 15,
                    column: 27
                },
                end: {
                    line: 15,
                    column: 65
                }
            },
            "6": {
                start: {
                    line: 16,
                    column: 16
                },
                end: {
                    line: 19,
                    column: 18
                }
            },
            "7": {
                start: {
                    line: 20,
                    column: 16
                },
                end: {
                    line: 23,
                    column: 18
                }
            },
            "8": {
                start: {
                    line: 27,
                    column: 8
                },
                end: {
                    line: 29,
                    column: 11
                }
            },
            "9": {
                start: {
                    line: 28,
                    column: 23
                },
                end: {
                    line: 28,
                    column: 34
                }
            },
            "10": {
                start: {
                    line: 31,
                    column: 8
                },
                end: {
                    line: 49,
                    column: 11
                }
            },
            "11": {
                start: {
                    line: 33,
                    column: 12
                },
                end: {
                    line: 48,
                    column: 15
                }
            },
            "12": {
                start: {
                    line: 36,
                    column: 20
                },
                end: {
                    line: 44,
                    column: 76
                }
            },
            "13": {
                start: {
                    line: 37,
                    column: 24
                },
                end: {
                    line: 37,
                    column: 75
                }
            },
            "14": {
                start: {
                    line: 38,
                    column: 25
                },
                end: {
                    line: 44,
                    column: 76
                }
            },
            "15": {
                start: {
                    line: 42,
                    column: 24
                },
                end: {
                    line: 42,
                    column: 74
                }
            },
            "16": {
                start: {
                    line: 43,
                    column: 25
                },
                end: {
                    line: 44,
                    column: 76
                }
            },
            "17": {
                start: {
                    line: 44,
                    column: 24
                },
                end: {
                    line: 44,
                    column: 76
                }
            },
            "18": {
                start: {
                    line: 46,
                    column: 20
                },
                end: {
                    line: 46,
                    column: 32
                }
            },
            "19": {
                start: {
                    line: 51,
                    column: 8
                },
                end: {
                    line: 51,
                    column: 39
                }
            },
            "20": {
                start: {
                    line: 56,
                    column: 8
                },
                end: {
                    line: 71,
                    column: 26
                }
            },
            "21": {
                start: {
                    line: 56,
                    column: 32
                },
                end: {
                    line: 56,
                    column: 51
                }
            },
            "22": {
                start: {
                    line: 57,
                    column: 13
                },
                end: {
                    line: 71,
                    column: 26
                }
            },
            "23": {
                start: {
                    line: 57,
                    column: 34
                },
                end: {
                    line: 57,
                    column: 57
                }
            },
            "24": {
                start: {
                    line: 58,
                    column: 13
                },
                end: {
                    line: 71,
                    column: 26
                }
            },
            "25": {
                start: {
                    line: 60,
                    column: 12
                },
                end: {
                    line: 67,
                    column: 13
                }
            },
            "26": {
                start: {
                    line: 62,
                    column: 16
                },
                end: {
                    line: 62,
                    column: 41
                }
            },
            "27": {
                start: {
                    line: 66,
                    column: 16
                },
                end: {
                    line: 66,
                    column: 29
                }
            },
            "28": {
                start: {
                    line: 69,
                    column: 13
                },
                end: {
                    line: 71,
                    column: 26
                }
            },
            "29": {
                start: {
                    line: 70,
                    column: 12
                },
                end: {
                    line: 70,
                    column: 47
                }
            },
            "30": {
                start: {
                    line: 71,
                    column: 13
                },
                end: {
                    line: 71,
                    column: 26
                }
            },
            "31": {
                start: {
                    line: 76,
                    column: 19
                },
                end: {
                    line: 76,
                    column: 48
                }
            },
            "32": {
                start: {
                    line: 77,
                    column: 27
                },
                end: {
                    line: 87,
                    column: 72
                }
            },
            "33": {
                start: {
                    line: 89,
                    column: 8
                },
                end: {
                    line: 94,
                    column: 78
                }
            },
            "34": {
                start: {
                    line: 90,
                    column: 12
                },
                end: {
                    line: 94,
                    column: 77
                }
            },
            "35": {
                start: {
                    line: 93,
                    column: 20
                },
                end: {
                    line: 94,
                    column: 76
                }
            },
            "36": {
                start: {
                    line: 94,
                    column: 24
                },
                end: {
                    line: 94,
                    column: 74
                }
            },
            "37": {
                start: {
                    line: 99,
                    column: 19
                },
                end: {
                    line: 99,
                    column: 48
                }
            },
            "38": {
                start: {
                    line: 100,
                    column: 27
                },
                end: {
                    line: 108,
                    column: 21
                }
            },
            "39": {
                start: {
                    line: 110,
                    column: 8
                },
                end: {
                    line: 116,
                    column: 15
                }
            },
            "40": {
                start: {
                    line: 111,
                    column: 12
                },
                end: {
                    line: 116,
                    column: 14
                }
            },
            "41": {
                start: {
                    line: 113,
                    column: 16
                },
                end: {
                    line: 113,
                    column: 70
                }
            },
            "42": {
                start: {
                    line: 113,
                    column: 41
                },
                end: {
                    line: 113,
                    column: 70
                }
            },
            "43": {
                start: {
                    line: 115,
                    column: 16
                },
                end: {
                    line: 115,
                    column: 78
                }
            },
            "44": {
                start: {
                    line: 121,
                    column: 19
                },
                end: {
                    line: 121,
                    column: 48
                }
            },
            "45": {
                start: {
                    line: 122,
                    column: 27
                },
                end: {
                    line: 129,
                    column: 14
                }
            },
            "46": {
                start: {
                    line: 131,
                    column: 8
                },
                end: {
                    line: 136,
                    column: 78
                }
            },
            "47": {
                start: {
                    line: 132,
                    column: 12
                },
                end: {
                    line: 136,
                    column: 77
                }
            },
            "48": {
                start: {
                    line: 135,
                    column: 20
                },
                end: {
                    line: 136,
                    column: 76
                }
            },
            "49": {
                start: {
                    line: 136,
                    column: 24
                },
                end: {
                    line: 136,
                    column: 74
                }
            }
        },
        fnMap: {
            "0": {
                name: "(anonymous_0)",
                decl: {
                    start: {
                        line: 5,
                        column: 4
                    },
                    end: {
                        line: 5,
                        column: 5
                    }
                },
                loc: {
                    start: {
                        line: 6,
                        column: 4
                    },
                    end: {
                        line: 52,
                        column: 5
                    }
                },
                line: 6
            },
            "1": {
                name: "(anonymous_1)",
                decl: {
                    start: {
                        line: 11,
                        column: 32
                    },
                    end: {
                        line: 11,
                        column: 33
                    }
                },
                loc: {
                    start: {
                        line: 12,
                        column: 8
                    },
                    end: {
                        line: 25,
                        column: 9
                    }
                },
                line: 12
            },
            "2": {
                name: "(anonymous_2)",
                decl: {
                    start: {
                        line: 28,
                        column: 17
                    },
                    end: {
                        line: 28,
                        column: 18
                    }
                },
                loc: {
                    start: {
                        line: 28,
                        column: 23
                    },
                    end: {
                        line: 28,
                        column: 34
                    }
                },
                line: 28
            },
            "3": {
                name: "(anonymous_3)",
                decl: {
                    start: {
                        line: 31,
                        column: 35
                    },
                    end: {
                        line: 31,
                        column: 36
                    }
                },
                loc: {
                    start: {
                        line: 32,
                        column: 8
                    },
                    end: {
                        line: 49,
                        column: 9
                    }
                },
                line: 32
            },
            "4": {
                name: "(anonymous_4)",
                decl: {
                    start: {
                        line: 34,
                        column: 21
                    },
                    end: {
                        line: 34,
                        column: 22
                    }
                },
                loc: {
                    start: {
                        line: 35,
                        column: 16
                    },
                    end: {
                        line: 47,
                        column: 17
                    }
                },
                line: 35
            },
            "5": {
                name: "(anonymous_5)",
                decl: {
                    start: {
                        line: 54,
                        column: 4
                    },
                    end: {
                        line: 54,
                        column: 5
                    }
                },
                loc: {
                    start: {
                        line: 55,
                        column: 4
                    },
                    end: {
                        line: 72,
                        column: 5
                    }
                },
                line: 55
            },
            "6": {
                name: "(anonymous_6)",
                decl: {
                    start: {
                        line: 74,
                        column: 4
                    },
                    end: {
                        line: 74,
                        column: 5
                    }
                },
                loc: {
                    start: {
                        line: 75,
                        column: 4
                    },
                    end: {
                        line: 95,
                        column: 5
                    }
                },
                line: 75
            },
            "7": {
                name: "(anonymous_7)",
                decl: {
                    start: {
                        line: 89,
                        column: 15
                    },
                    end: {
                        line: 89,
                        column: 16
                    }
                },
                loc: {
                    start: {
                        line: 90,
                        column: 12
                    },
                    end: {
                        line: 94,
                        column: 77
                    }
                },
                line: 90
            },
            "8": {
                name: "(anonymous_8)",
                decl: {
                    start: {
                        line: 92,
                        column: 22
                    },
                    end: {
                        line: 92,
                        column: 23
                    }
                },
                loc: {
                    start: {
                        line: 93,
                        column: 20
                    },
                    end: {
                        line: 94,
                        column: 76
                    }
                },
                line: 93
            },
            "9": {
                name: "(anonymous_9)",
                decl: {
                    start: {
                        line: 93,
                        column: 44
                    },
                    end: {
                        line: 93,
                        column: 45
                    }
                },
                loc: {
                    start: {
                        line: 94,
                        column: 24
                    },
                    end: {
                        line: 94,
                        column: 74
                    }
                },
                line: 94
            },
            "10": {
                name: "(anonymous_10)",
                decl: {
                    start: {
                        line: 97,
                        column: 4
                    },
                    end: {
                        line: 97,
                        column: 5
                    }
                },
                loc: {
                    start: {
                        line: 98,
                        column: 4
                    },
                    end: {
                        line: 117,
                        column: 5
                    }
                },
                line: 98
            },
            "11": {
                name: "(anonymous_11)",
                decl: {
                    start: {
                        line: 110,
                        column: 15
                    },
                    end: {
                        line: 110,
                        column: 16
                    }
                },
                loc: {
                    start: {
                        line: 111,
                        column: 12
                    },
                    end: {
                        line: 116,
                        column: 14
                    }
                },
                line: 111
            },
            "12": {
                name: "(anonymous_12)",
                decl: {
                    start: {
                        line: 111,
                        column: 40
                    },
                    end: {
                        line: 111,
                        column: 41
                    }
                },
                loc: {
                    start: {
                        line: 112,
                        column: 12
                    },
                    end: {
                        line: 116,
                        column: 13
                    }
                },
                line: 112
            },
            "13": {
                name: "(anonymous_13)",
                decl: {
                    start: {
                        line: 119,
                        column: 4
                    },
                    end: {
                        line: 119,
                        column: 5
                    }
                },
                loc: {
                    start: {
                        line: 120,
                        column: 4
                    },
                    end: {
                        line: 137,
                        column: 5
                    }
                },
                line: 120
            },
            "14": {
                name: "(anonymous_14)",
                decl: {
                    start: {
                        line: 131,
                        column: 15
                    },
                    end: {
                        line: 131,
                        column: 16
                    }
                },
                loc: {
                    start: {
                        line: 132,
                        column: 12
                    },
                    end: {
                        line: 136,
                        column: 77
                    }
                },
                line: 132
            },
            "15": {
                name: "(anonymous_15)",
                decl: {
                    start: {
                        line: 134,
                        column: 22
                    },
                    end: {
                        line: 134,
                        column: 23
                    }
                },
                loc: {
                    start: {
                        line: 135,
                        column: 20
                    },
                    end: {
                        line: 136,
                        column: 76
                    }
                },
                line: 135
            },
            "16": {
                name: "(anonymous_16)",
                decl: {
                    start: {
                        line: 135,
                        column: 44
                    },
                    end: {
                        line: 135,
                        column: 45
                    }
                },
                loc: {
                    start: {
                        line: 136,
                        column: 24
                    },
                    end: {
                        line: 136,
                        column: 74
                    }
                },
                line: 136
            }
        },
        branchMap: {
            "0": {
                loc: {
                    start: {
                        line: 13,
                        column: 12
                    },
                    end: {
                        line: 24,
                        column: 13
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 13,
                        column: 12
                    },
                    end: {
                        line: 24,
                        column: 13
                    }
                }, {
                    start: {
                        line: 13,
                        column: 12
                    },
                    end: {
                        line: 24,
                        column: 13
                    }
                }],
                line: 13
            },
            "1": {
                loc: {
                    start: {
                        line: 15,
                        column: 27
                    },
                    end: {
                        line: 15,
                        column: 65
                    }
                },
                type: "cond-expr",
                locations: [{
                    start: {
                        line: 15,
                        column: 41
                    },
                    end: {
                        line: 15,
                        column: 52
                    }
                }, {
                    start: {
                        line: 15,
                        column: 55
                    },
                    end: {
                        line: 15,
                        column: 65
                    }
                }],
                line: 15
            },
            "2": {
                loc: {
                    start: {
                        line: 36,
                        column: 20
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 36,
                        column: 20
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }, {
                    start: {
                        line: 36,
                        column: 20
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }],
                line: 36
            },
            "3": {
                loc: {
                    start: {
                        line: 38,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 38,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }, {
                    start: {
                        line: 38,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }],
                line: 38
            },
            "4": {
                loc: {
                    start: {
                        line: 39,
                        column: 24
                    },
                    end: {
                        line: 40,
                        column: 53
                    }
                },
                type: "binary-expr",
                locations: [{
                    start: {
                        line: 39,
                        column: 24
                    },
                    end: {
                        line: 39,
                        column: 50
                    }
                }, {
                    start: {
                        line: 40,
                        column: 24
                    },
                    end: {
                        line: 40,
                        column: 53
                    }
                }],
                line: 39
            },
            "5": {
                loc: {
                    start: {
                        line: 43,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 43,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }, {
                    start: {
                        line: 43,
                        column: 25
                    },
                    end: {
                        line: 44,
                        column: 76
                    }
                }],
                line: 43
            },
            "6": {
                loc: {
                    start: {
                        line: 56,
                        column: 8
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 56,
                        column: 8
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }, {
                    start: {
                        line: 56,
                        column: 8
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }],
                line: 56
            },
            "7": {
                loc: {
                    start: {
                        line: 57,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 57,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }, {
                    start: {
                        line: 57,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }],
                line: 57
            },
            "8": {
                loc: {
                    start: {
                        line: 58,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 58,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }, {
                    start: {
                        line: 58,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }],
                line: 58
            },
            "9": {
                loc: {
                    start: {
                        line: 69,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 69,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }, {
                    start: {
                        line: 69,
                        column: 13
                    },
                    end: {
                        line: 71,
                        column: 26
                    }
                }],
                line: 69
            },
            "10": {
                loc: {
                    start: {
                        line: 69,
                        column: 17
                    },
                    end: {
                        line: 69,
                        column: 63
                    }
                },
                type: "binary-expr",
                locations: [{
                    start: {
                        line: 69,
                        column: 17
                    },
                    end: {
                        line: 69,
                        column: 38
                    }
                }, {
                    start: {
                        line: 69,
                        column: 42
                    },
                    end: {
                        line: 69,
                        column: 63
                    }
                }],
                line: 69
            },
            "11": {
                loc: {
                    start: {
                        line: 70,
                        column: 19
                    },
                    end: {
                        line: 70,
                        column: 46
                    }
                },
                type: "cond-expr",
                locations: [{
                    start: {
                        line: 70,
                        column: 27
                    },
                    end: {
                        line: 70,
                        column: 39
                    }
                }, {
                    start: {
                        line: 70,
                        column: 42
                    },
                    end: {
                        line: 70,
                        column: 46
                    }
                }],
                line: 70
            },
            "12": {
                loc: {
                    start: {
                        line: 113,
                        column: 16
                    },
                    end: {
                        line: 113,
                        column: 70
                    }
                },
                type: "if",
                locations: [{
                    start: {
                        line: 113,
                        column: 16
                    },
                    end: {
                        line: 113,
                        column: 70
                    }
                }, {
                    start: {
                        line: 113,
                        column: 16
                    },
                    end: {
                        line: 113,
                        column: 70
                    }
                }],
                line: 113
            }
        },
        s: {
            "0": 0,
            "1": 0,
            "2": 0,
            "3": 0,
            "4": 0,
            "5": 0,
            "6": 0,
            "7": 0,
            "8": 0,
            "9": 0,
            "10": 0,
            "11": 0,
            "12": 0,
            "13": 0,
            "14": 0,
            "15": 0,
            "16": 0,
            "17": 0,
            "18": 0,
            "19": 0,
            "20": 0,
            "21": 0,
            "22": 0,
            "23": 0,
            "24": 0,
            "25": 0,
            "26": 0,
            "27": 0,
            "28": 0,
            "29": 0,
            "30": 0,
            "31": 0,
            "32": 0,
            "33": 0,
            "34": 0,
            "35": 0,
            "36": 0,
            "37": 0,
            "38": 0,
            "39": 0,
            "40": 0,
            "41": 0,
            "42": 0,
            "43": 0,
            "44": 0,
            "45": 0,
            "46": 0,
            "47": 0,
            "48": 0,
            "49": 0
        },
        f: {
            "0": 0,
            "1": 0,
            "2": 0,
            "3": 0,
            "4": 0,
            "5": 0,
            "6": 0,
            "7": 0,
            "8": 0,
            "9": 0,
            "10": 0,
            "11": 0,
            "12": 0,
            "13": 0,
            "14": 0,
            "15": 0,
            "16": 0
        },
        b: {
            "0": [0, 0],
            "1": [0, 0],
            "2": [0, 0],
            "3": [0, 0],
            "4": [0, 0],
            "5": [0, 0],
            "6": [0, 0],
            "7": [0, 0],
            "8": [0, 0],
            "9": [0, 0],
            "10": [0, 0],
            "11": [0, 0],
            "12": [0, 0]
        },
        _coverageSchema: "332fd63041d2c1bcb487cc26dd0d5f7d97098a6c"
    },
        coverage = global[gcv] || (global[gcv] = {});

    if (coverage[path] && coverage[path].hash === hash) {
        return coverage[path];
    }

    coverageData.hash = hash;
    return coverage[path] = coverageData;
}();

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.Util = undefined;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _stackerjsDb = require("stackerjs-db");

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Util = exports.Util = function () {
    function Util() {
        _classCallCheck(this, Util);
    }

    _createClass(Util, null, [{
        key: "makeEntity",
        value: function makeEntity(defaultEntity, attributes) {
            var _this = this;

            cov_15erv6hag8.f[0]++;

            var metadata = (cov_15erv6hag8.s[0]++, defaultEntity.metadata());

            var entity = (cov_15erv6hag8.s[1]++, Object.create(defaultEntity)),
                _attributes = (cov_15erv6hag8.s[2]++, attributes);
            cov_15erv6hag8.s[3]++;
            metadata.fields.forEach(function (field) {
                cov_15erv6hag8.f[1]++;
                cov_15erv6hag8.s[4]++;

                if (typeof attributes[field.name] !== "undefined") {
                    cov_15erv6hag8.b[0][0]++;

                    var name = (cov_15erv6hag8.s[5]++, field.alias ? (cov_15erv6hag8.b[1][0]++, field.alias) : (cov_15erv6hag8.b[1][1]++, field.name));
                    cov_15erv6hag8.s[6]++;
                    entity[name] = _this.fieldValueParser(field.type, attributes[field.name]);
                    cov_15erv6hag8.s[7]++;
                    _attributes[field.name] = _this.fieldValueParser(field.type, attributes[field.name]);
                } else {
                    cov_15erv6hag8.b[0][1]++;
                }
            });

            cov_15erv6hag8.s[8]++;
            Object.defineProperty(entity, "_attributes", {
                get: function get() {
                    cov_15erv6hag8.f[2]++;
                    cov_15erv6hag8.s[9]++;
                    return _attributes;
                }
            });

            cov_15erv6hag8.s[10]++;
            metadata.relations.forEach(function (relation) {
                cov_15erv6hag8.f[3]++;
                cov_15erv6hag8.s[11]++;

                Object.defineProperty(entity, relation.name, {
                    get: function get() {
                        cov_15erv6hag8.f[4]++;
                        cov_15erv6hag8.s[12]++;

                        if (relation.type === "HASMANY") {
                                cov_15erv6hag8.b[2][0]++;
                                cov_15erv6hag8.s[13]++;

                                return _this.HASMANYAssociation(entity, relation)();
                            } else {
                                cov_15erv6hag8.b[2][1]++;
                                cov_15erv6hag8.s[14]++;
                                if ((cov_15erv6hag8.b[4][0]++, relation.type === "HASONE") || (cov_15erv6hag8.b[4][1]++, relation.type === "BELONGSTO")) {
                                        cov_15erv6hag8.b[3][0]++;
                                        cov_15erv6hag8.s[15]++;

                                        return _this.HASONEAssociation(entity, relation)();
                                    } else {
                                        cov_15erv6hag8.b[3][1]++;
                                        cov_15erv6hag8.s[16]++;
                                        if (relation.type === "MANYMANY") {
                                                cov_15erv6hag8.b[5][0]++;
                                                cov_15erv6hag8.s[17]++;

                                                return _this.MANYMANYAssociation(entity, relation)();
                                            } else {
                                            cov_15erv6hag8.b[5][1]++;
                                        }
                                    }
                            }cov_15erv6hag8.s[18]++;
                        return null;
                    }
                });
            });

            cov_15erv6hag8.s[19]++;
            return Promise.resolve(entity);
        }
    }, {
        key: "fieldValueParser",
        value: function fieldValueParser(type, value) {
            cov_15erv6hag8.f[5]++;
            cov_15erv6hag8.s[20]++;

            if (type === "boolean") {
                    cov_15erv6hag8.b[6][0]++;
                    cov_15erv6hag8.s[21]++;
                    return value === 1;
                } else {
                    cov_15erv6hag8.b[6][1]++;
                    cov_15erv6hag8.s[22]++;
                    if (type === "date") {
                            cov_15erv6hag8.b[7][0]++;
                            cov_15erv6hag8.s[23]++;
                            return new Date(value);
                        } else {
                            cov_15erv6hag8.b[7][1]++;
                            cov_15erv6hag8.s[24]++;
                            if (type === "json") {
                                cov_15erv6hag8.b[8][0]++;
                                cov_15erv6hag8.s[25]++;

                                try {
                                    cov_15erv6hag8.s[26]++;

                                    return JSON.parse(value);
                                } catch (err) {
                                    cov_15erv6hag8.s[27]++;

                                    return value;
                                }
                            } else {
                                    cov_15erv6hag8.b[8][1]++;
                                    cov_15erv6hag8.s[28]++;
                                    if ((cov_15erv6hag8.b[10][0]++, type === "created_at") || (cov_15erv6hag8.b[10][1]++, type === "updated_at")) {
                                            cov_15erv6hag8.b[9][0]++;
                                            cov_15erv6hag8.s[29]++;

                                            return value ? (cov_15erv6hag8.b[11][0]++, value * 1000) : (cov_15erv6hag8.b[11][1]++, null);
                                        } else {
                                            cov_15erv6hag8.b[9][1]++;
                                            cov_15erv6hag8.s[30]++;
                                            return value;
                                        }
                                }
                        }
                }
        }
    }, {
        key: "MANYMANYAssociation",
        value: function MANYMANYAssociation(entity, relation) {
            var _this2 = this;

            cov_15erv6hag8.f[6]++;

            var expr = (cov_15erv6hag8.s[31]++, _stackerjsDb.DB.Factory.getQueryCriteria());
            var queryBuilder = (cov_15erv6hag8.s[32]++, _stackerjsDb.DB.Factory.getQueryBuilder().select().from(relation.table).set(relation.referencedEntity.metadata().table + ".*").join("INNER", relation.referencedEntity.metadata().table, relation.table + "." + relation.referencedField + " = " + (relation.referencedEntity.metadata().table + ".id")).where(expr.eq(relation.field, entity["_attributes"]["id"])));

            cov_15erv6hag8.s[33]++;
            return function () {
                cov_15erv6hag8.f[7]++;
                cov_15erv6hag8.s[34]++;
                return queryBuilder.execute().then(function (results) {
                    cov_15erv6hag8.f[8]++;
                    cov_15erv6hag8.s[35]++;
                    return Promise.all(results.map(function (result) {
                        cov_15erv6hag8.f[9]++;
                        cov_15erv6hag8.s[36]++;
                        return _this2.makeEntity(relation.referencedEntity, result);
                    }));
                });
            };
        }
    }, {
        key: "HASONEAssociation",
        value: function HASONEAssociation(entity, relation) {
            var _this3 = this;

            cov_15erv6hag8.f[10]++;

            var expr = (cov_15erv6hag8.s[37]++, _stackerjsDb.DB.Factory.getQueryCriteria());
            var queryBuilder = (cov_15erv6hag8.s[38]++, _stackerjsDb.DB.Factory.getQueryBuilder().select().from(relation.referencedEntity.metadata().table).set("*").where(expr.eq(relation.referencedField, entity["_attributes"][relation.field])).limit(1));

            cov_15erv6hag8.s[39]++;
            return function () {
                cov_15erv6hag8.f[11]++;
                cov_15erv6hag8.s[40]++;
                return queryBuilder.execute().then(function (results) {
                    cov_15erv6hag8.f[12]++;
                    cov_15erv6hag8.s[41]++;

                    if (results.length <= 0) {
                            cov_15erv6hag8.b[12][0]++;
                            cov_15erv6hag8.s[42]++;
                            return Promise.resolve(null);
                        } else {
                        cov_15erv6hag8.b[12][1]++;
                    }cov_15erv6hag8.s[43]++;
                    return _this3.makeEntity(relation.referencedEntity, results[0]);
                });
            };
        }
    }, {
        key: "HASMANYAssociation",
        value: function HASMANYAssociation(entity, relation) {
            var _this4 = this;

            cov_15erv6hag8.f[13]++;

            var expr = (cov_15erv6hag8.s[44]++, _stackerjsDb.DB.Factory.getQueryCriteria());
            var queryBuilder = (cov_15erv6hag8.s[45]++, _stackerjsDb.DB.Factory.getQueryBuilder().select().from(relation.referencedEntity.metadata().table).set("*").where(expr.eq(relation.referencedField, entity["_attributes"][relation.field])));

            cov_15erv6hag8.s[46]++;
            return function () {
                cov_15erv6hag8.f[14]++;
                cov_15erv6hag8.s[47]++;
                return queryBuilder.execute().then(function (results) {
                    cov_15erv6hag8.f[15]++;
                    cov_15erv6hag8.s[48]++;
                    return Promise.all(results.map(function (result) {
                        cov_15erv6hag8.f[16]++;
                        cov_15erv6hag8.s[49]++;
                        return _this4.makeEntity(relation.referencedEntity, result);
                    }));
                });
            };
        }
    }]);

    return Util;
}();