Mapping Examples

Basic Mapping Without Nested Documents

</tbody>
Document
{
    "_id": {
        "$oid" : "5716054bee6e764c94fa7ddd"
    },
    "name": "MongoDB extractor"
}
Mapping
{
    "_id.$oid": "id",
    "name": "name"
}
Output extractors
idname
5716054bee6e764c94fa7dddMongoDB extractor

Defining Primary Key

</tbody>
Document
{
    "_id": {
        "$oid" : "5716054bee6e764c94fa7ddd"
    }
}
Mapping
{
    "_id.$oid": {
        "type": "column",
        "mapping": {
            "destination": "id",
            "primaryKey": true
        }
    }
}
Output extractors
id (marked as PK)
5716054bee6e764c94fa7ddd

With Nested Documents

</tbody>
Document
{
    "_id": {
        "$oid" : "5716054bee6e764c94fa7ddd"
    },
    "name": "MongoDB extractor",
    "revisions": [
        {
            "id": "1c6262e",
            "desc": "First version"
        },
        {
            "id": "68fc980",
            "desc": "Second version"
        }
    ],
    "status": {
        "isActive": 1,
        "isDeleted": 0
    }
}
Mapping
{
    "_id.$oid": {
        "type": "column",
        "mapping": {
            "destination": "id",
            "primaryKey": true
        }
    },
    "name": "name",
    "status.isActive": "isActive",
    "status.isDeleted": "isDeleted",
    "revisions": {
        "type": "table",
        "destination": "extractors-revisions",
        "tableMapping": {
            "id": "id",
            "desc": "desc"
        }
    }
}
Output extractors
id (marked as PK)nameisActiveisDeleted
5716054bee6e764c94fa7dddMongoDB extractor10
extractors-revisions
iddescextractors_pk
1c6262eFirst version5716054bee6e764c94fa7ddd
68fc980Second version5716054bee6e764c94fa7ddd
As you can see, joining those two tables will be as easy as pie.

With Lists

</tbody>
Document
{
    "_id": {
        "$oid" : "5716054bee6e764c94fa7ddd"
    },
    "name": "MongoDB extractor",
    "tags": [
        "keboola", "extractor", "mongodb"
    ]
}
Mapping
{
    "_id.$oid": {
        "type": "column",
        "mapping": {
            "destination": "id",
            "primaryKey": true
        }
    },
    "name": "name",
    "tags": {
        "type": "table",
        "destination": "extractors-tags",
        "tableMapping": {
            ".": {
                "mapping": {
                    "destination": "tag"
                }
            }
        }
    }
}
Output extractors
id (marked as PK)name
5716054bee6e764c94fa7dddMongoDB extractor
extractors-tags
tagextractors_pk
keboola5716054bee6e764c94fa7ddd
extractor5716054bee6e764c94fa7ddd
mongodb5716054bee6e764c94fa7ddd

Boolean values

</tbody>
Documents
[
    {
        "_id": {
            "$oid" : "764c94fa7ddd5716054bee6e"
        },
        "name": "MySQL extractor",
        "isActive": false
    },
    {
        "_id": {
            "$oid" : "5716054bee6e764c94fa7ddd"
        },
        "name": "MongoDB extractor",
        "isActive": true
    }
]
Mapping
{
    "_id.$oid": {
        "type": "column",
        "mapping": {
            "destination": "id",
            "primaryKey": true
        }
    },
    "isActive": "isActive"
}
Output extractors
id (marked as PK)nameisActive
764c94fa7ddd5716054bee6eMySQL extractor(empty string)
5716054bee6e764c94fa7dddMongoDB extractor1