Mongo db updation with stream/discrete json data

Hi,
I have got a component like json writer which re-formats the data and then return an json output.
Many records come through the same way.Consider one of my sample json is something like this:

{
“upc”:“087206733420”,
“model”:“702010 L SH”,
“color”: “Bright Silver”,
“height”: “914.40”,
“length”: “1828.80”
}

I have got an Mongo database that have many records that have the same structure.I need to do an upsert operation in mongo.But to query against the database using “upc” ,i need to take the upc value from json metadata that comes from the json writer output port.Please suggest methods to achieve this.(building a upc query)

Hi sidharth,

If your JsonWriter composes result from single record then you can use following approach:

json_writer_consuming_1_record.png

(Copy of record is passed through JsonWriter and second copy directly into Combine where you can generate composed record [guid, json_content] and use that in Input Mapping of MongoDbWriter)

If your JsonWriter composes result from multiple records then you can use this approach:

json_writer_consuming_many_records.png.png

(Because Combine needs 1:1 streams you need to compose Json first, pass copy to combine and extract guid using JsonExtract, again in Combine you build composed record [guid, json_content] and pass into Mongo)

I hope this helps