MongoDB and ObjectId

Five Stars

MongoDB and ObjectId

Hello,

I have a job in which I get documents from a collection with their _id (ObjectId), and I wish to realise a SET action on the collection with this _id as a key.

I try to use the Object field type for the _id field, but the set action doesn't work, and then I try upsert with set, it create me a new document with the same _id, but Integer format.

 

How can I do to declare the _id as ObjectId in my query ?

 

Capture3.JPG

Five Stars

Re: MongoDB and ObjectId

Hello,

I try the solution proposed in the help page of the "tWriteJSONField" : "For an object element, you need to add an attribute named class and set its static value to object". But it doesn't work, neither with object nor ObjectId.

 

Five Stars

Re: MongoDB and ObjectId

Hi,

 

When you fetch the documents, "_id" is coming as type string not ObjectId. So while upserting documents it will add a new docoument instead of updating existing one as

_id(str) != _id(ObjectId).

I tried to find solutions, but talend doesn't have any datatype as ObjectID. I hope they bring this datatype in future versions.

I upsert documents on some composite keys (not objectID) defined in query node in xml tree.

 

Regards

Ravinder