Quantcast
Viewing all articles
Browse latest Browse all 16689

Getting Array elements from MongoDB

Hi All,

I want to migrate data from mongodb to a relational database.

In mongo, we have a json with keys, arrays, sub documents and arrays in subdocument.

We are trying to flatten the structure to a csv format for each array, each subdocument etc., My immediate requirement is to convert each array object
to a separate record.

{
department : _id
depart_name : string
employee : array
employee_id : number
employee_name: string
phonenumber : string
}


I would like to create two files one containing the following fields

department_id,
depart_name

and another with the following structure

department_id
employee_array_id
employee_id
employee_name
phonenumber

The first file is pretty straightforward. Can you suggest the best way to extract all the element objects of an array into a separate flat record?
We can assume the json structure is fixed and is uniform across all documents.

Sample json format attached.


PDI 4.4 in linux version,

MongoDB 2.5.4,

Vertica 6.x.
Attached Files
  • Image may be NSFW.
    Clik here to view.
    File Type: txt
    JsonData.txt (540 Bytes)

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>