# tMongoDBGridFSDelete

Automates the delete action over specific files in MongoDB GridFS.

tMongoDBGridFSDelete connects to a given MongoDB GridFS system, executes a user-defined query to select specific files and deletes these files from this system.

This component is not shipped with your Talend Studio by default. You need to install it using the Feature Manager. For more information, see [Installing features using the Feature Manager](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/install-features-to-talend-studio).

## tMongoDBGridFSDelete Standard properties

These properties are used to configure tMongoDBGridFSDelete running in the Standard Job framework.

The Standard tMongoDBGridFSDelete component belongs to the Big Data and the Databases NoSQL families.

The component in this framework is available in all Talend products with Big Data and in Talend Data Fabric.

## Basic settings

| Properties | Description |
| --- | --- |
| Property type | Either Built-In or Repository.<br><br><br>Built-In: No property data stored centrally.<br><br><br>Repository: Select the repository file where the<br>properties are stored. |
| Use existing connection | Select this check box and in the Component<br>List drop-down list, select the desired connection component to<br>reuse the connection details you already defined.<br><br>Note that when a Job contains the parent Job and the child Job,<br>Component List presents only the<br>connection components in the same Job level. |
| DB Version | List of the database versions.<br><br>Available when the Use existing connection check box is not selected. |
| Use connection string | Select this option to establish a connection using a MongoDB<br>Atlas URI. Enter the URI in the field to the right. See [Connection String URI Format](https://docs.mongodb.com/manual/reference/connection-string/) for related information.<br><br>This option is available when you select MongoDB 4.4.X and<br>later from the DB Version drop-down<br>list.<br><br>Information noteNote: This option is available only when you have installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator. |
| Use replica set address or multiple query routers | Select this check box to show the Server<br>addresses table.<br><br>In the Server addresses<br>table, define the shared MongoDB databases or the MongoDB replica sets you want<br>to connect to. |
| Server and Port | IP address and listening port of the database server.<br><br>Available when the Use replica set<br>address check box is not selected.<br><br>Note that if you use the authentication mechanisms to connect to this MongoDB<br>database, you must enter the name, rather than the IP address, of the host of the database<br>server. |
| Database | Name of the database. |
| Use SSL connection (Configure the SSL authentication<br>in tSetKeystore or in Studio preferences) | Select this checkbox to enable the SSL or TLS encrypted connection.<br><br>Then you need to use the tSetKeystore<br>component in the same Job to specify the encryption information.<br><br>Note that the SSL connection is available only for the version 2.4 + of<br>MongoDB. |
| Set read preference | Select this check box and from the Read preference<br>drop-down list that is displayed, select the member to which you need to direct the read<br>operations.<br><br>If you leave this check box clear, the Job uses the default Read preference, that is to<br>say, uses the primary member in a replica set.<br><br>For further information, see MongoDB's documentation about Replication and its Read<br>preferences. |
| Use authentication | Select this check box to enable the database authentication.<br><br>Among the mechanisms listed on the Authentication mechanism<br>drop-down list, the NEGOTIATE one is recommended if<br>you are not using Kerberos, because it automatically select the authentication mechanism<br>the most adapted to the MongoDB version you are using.<br><br>Because the SCRAM-SHA-256 authentication mechanism is only supported by<br>MongoDB 4.x and later versions, SCRAM-SHA-256 SASL option is available<br>only when MongoDB 4.4.X and later is selected from the DB<br>Version drop-down list.<br><br>Information noteNote: The X509 option is available only when you have<br>installed the R2021-12 Talend Studio Monthly update or a later one delivered by Talend. For more information, check with your administrator.<br><br>For details about the other mechanisms in this list, see [MongoDB Authentication](https://docs.mongodb.org/manual/reference/parameters/#param.authenticationMechanisms) from the MongoDB<br>documentation. |
| Set Authentication database | If the username to be used to connect to MongoDB has been created in a specific<br>Authentication database of MongoDB, select this check box to enter the name of this<br>Authentication database in the Authentication database<br>field that is displayed.<br><br>For further information about the MongoDB Authentication database, see [User Authentication database](https://docs.mongodb.org/manual/core/security-users/#user-authentication-database). |
| Username and Password | DB user authentication data.<br><br>To enter the password, click the [...] button<br>next to the password field, enter the password in double quotes in the pop-up dialog box,<br>and click OK to save the settings.<br><br>Available when the Required<br>authentication check box is selected.<br><br>If the security system you have selected from the Authentication mechanism dropdown list is Kerberos, you need to<br>enter the User principal, the Realm and the KDC<br>server fields instead of the Username and the Password<br>fields. |
| Bucket | Enter the name of the bucket from which you need to delete files. A<br>bucket of GridFS is similar to a folder. |
| Query type | Select the type of the query you want tMongoDBGridFSDelete to perform to select the files to be<br>deleted.<br><br><ul> <li> <p> <span>Filename</span>: you need to enter                                    the name of the file to be deleted. This name is the value of                                    the <em>filename</em> attribute of                                    this file. Note that only one name is allowed.</p> <p>In GridFS, a file is identified only by its unique identifier                                    (its object ID); its file name is not necessarily unique.</p> </li> <li> <p> <span>Mongo Query</span>: enter the query                                    to be used to select the files to be deleted.</p> <p>The example query, <span>{}</span> within double quotation                                    marks provided with <span>tMongoDBGridFSDelete</span>, means to select all of the                                    files in a bucket. You can put                                    <span>{'filename':{'$regex':'REGEX_PATTERN'}}</span> to apply a                                    regular expression to defining the file names to be used. </p> </li> </ul> |

## Advanced settings

| Properties | Description |
| --- | --- |
| tStatCatcher Statistics | Select this check box to collect the log data at the component<br>level. |
| No query timeout | Select this check box to prevent MongoDB servers from stopping idle<br>cursors at the end of 10-minute inactivity of these cursors. In this<br>situation, an idle cursor will stay open until either the results of<br>this cursor are exhausted or you manually close it using the<br>cursor.close() method.<br><br>A cursor for MongoDB is a pointer to the result set of a query. By<br>default, that is to say, with this check box being clear, a MongoDB<br>server automatically stops idle cursors after a given inactivity period<br>to avoid excess memory use. For further information about MongoDB<br>cursors, see https://docs.mongodb.org/manual/core/cursors/. |

## Global Variables

| Variables | Description |
| --- | --- |
| Global Variables | NB\_FILE: the number of files processed. This is an After variable and<br>it returns an integer.<br><br><br>ERROR\_MESSAGE: the error message generated by the<br>component when an error occurs. This is an After variable and it returns a string. This<br>variable functions only if the Die on error checkbox is<br>cleared, if the component has this checkbox.<br><br>A Flow variable functions during the execution of a component<br>while an After variable functions after the execution of the component.<br><br>To fill up a field or expression with a variable, press Ctrl+Space to access the variable list and choose the variable to use from<br>it.<br><br>For more information about variables, see [Using contexts and variables](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/contexts-and-variables). |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component combines MongoDB GridFS connection and data iteration, thus usually used<br>as a single-component subJob to delete selected files from a given<br>bucket in MongoDB GridFS.<br><br>It is often connected to the Job using OnSubjobOk or OnComponentOk<br>link, depending on the context. |

**Related concepts**

* [Managing files using MongoDB GridFS](https://help.qlik.com/talend/en-US/components/8.0/mongodb/tmongodbgridfslist-tmongodbgridfsproperties-tlogrow-managing-files-using-mongodb-gridfs-standard-component-bigdata-in-this)