Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
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