Skip to main content
Question

MongoDB writer with nested documents


txalaparta
Contributor
Forum|alt.badge.img+3

I am working with MongoDB trying to upsert nested MongoDB documents. The JSON format would be something like:

{

“name”: “XXX”,

“tables” : [ 

{

“name”: “XXXX”,

“num_rows” : 3423,

“fields”: [ 

        {“name”: “XXX”, “type”: “yyyy”} , …. 

    ]

}, ….

]

 

I have no problems when I use a JSON string attribute inserting a new document with Document Source”: Json Attribute” and Insert operation.

But, I do need to UPDATE existing features.

In this case, the nested dcouments (tables in the json above) are created as plain strings.  Which is a real inconvenience in my use-case.

{

“name”: “XXX”,

“tables” : [ “{“name”: “XXXX”,“num_rows” : 3423,“fields”: [         {“name”: “XXX”, “type”: “yyyy”} , ….     ]} “ , ….

]

Valid datatypes do not currently include arrays (of objects) 

 Is there any alternative or workarounds?

 

 

 

 

 

 

 

 

 

liamfez
Influencer
Forum|alt.badge.img+34
  • Influencer
  • May 2, 2024

Out of curiosity, what version of FME are you working with? I have been running into similar problems, I will link my post in another comment where I reference a couple old posts relating to mongo arrays. I too have been dealing with the limitation of only using RAW JSON on Insert.


liamfez
Influencer
Forum|alt.badge.img+34
  • Influencer
  • May 2, 2024

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings