Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
fcolagiacomo
Contributor III
Contributor III

TAmazonDocumentDBOuput how to delete by ObjectId

Hi,

I want to delete into DocumentDB collection some documents by _id. Some _id are string type but others are ObjectId type.

I can delete _id with String type but I cannot remove the documents with ObjectId.

Can you help me?

I also tried to use MongoDB components to conntct DocumentDB database but Talend Studio append to find statement the noCursorTimeout method and DocumentDB not support this feature, find method fails.

Labels (4)
1 Solution

Accepted Solutions
fcolagiacomo
Contributor III
Contributor III
Author

Talend Amazon DocumentDB components are not functional:

- Output executes data action one document for each element of flow, you cannot execute delete or update by query.

Anyway I found a workaround, it is not elegant but it could be save the life 😄 :

The solution is: to create the query below into tAmazonDocumentDBOutput:

 

"{ $or: [{'_id': '"+globalMap.get("_id")+"'}, {'_id': ObjectId('"+globalMap.get("_id")+"')}]}"

 

 

Example of scenario:

Job has to delete all documents in a collection.

tAmazonDocumentDBInput --row1--> tJava --row2--> tAmazonDocumentDBOutput

tAmazonDocumentDBInput

field query: {}

schema: _id type Object or String (there isn't any differeces!) 

tJava

code: 

 

globalMap.put("_id", row1._id)

 

tAmazonDocumentDBOutput

schema: there shouldn't be a key field

field query:

 

"{ $or: [{'_id': '"+globalMap.get("_id")+"'}, {'_id': ObjectId('"+globalMap.get("_id")+"')}]}"

 

field Bulk write: unchecked (it is very important!)

field data action: Delete

View solution in original post

1 Reply
fcolagiacomo
Contributor III
Contributor III
Author

Talend Amazon DocumentDB components are not functional:

- Output executes data action one document for each element of flow, you cannot execute delete or update by query.

Anyway I found a workaround, it is not elegant but it could be save the life 😄 :

The solution is: to create the query below into tAmazonDocumentDBOutput:

 

"{ $or: [{'_id': '"+globalMap.get("_id")+"'}, {'_id': ObjectId('"+globalMap.get("_id")+"')}]}"

 

 

Example of scenario:

Job has to delete all documents in a collection.

tAmazonDocumentDBInput --row1--> tJava --row2--> tAmazonDocumentDBOutput

tAmazonDocumentDBInput

field query: {}

schema: _id type Object or String (there isn't any differeces!) 

tJava

code: 

 

globalMap.put("_id", row1._id)

 

tAmazonDocumentDBOutput

schema: there shouldn't be a key field

field query:

 

"{ $or: [{'_id': '"+globalMap.get("_id")+"'}, {'_id': ObjectId('"+globalMap.get("_id")+"')}]}"

 

field Bulk write: unchecked (it is very important!)

field data action: Delete