---
sidebar_position: 4
description: Delete documents and other functions to work with MongoDB in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, MongoDB]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Delete documents
 Deletes collection documents



`Function DeleteDocuments(Val Connection, Val Collection, Val Deletions, Val Base = Undefined, Val Parameters = Undefined) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Connection | --dbc | String, Arbitrary | &#x2714; | Connection or connection string |
  | Collection | --coll | String | &#x2714; | Collection name |
  | Deletions | --deletes | Array of Structure | &#x2714; | Deletion array. See GetDocumentDeletionStructure |
  | Base | --db | String | &#x2716; | Database name. Current database if not specified |
  | Parameters | --params | Structure Of KeyAndValue | &#x2716; | Additional insert options |

  
  Returns:  Map Of KeyAndValue - Operation result



```bsl title="1C:Enterprise/OneScript code example"
    Address  = "127.0.0.1:1234";
    Login    = "bayselonarrend";
    Password = "12we...";
    Base     = "main";

    ConnectionParams = New Structure("authSource", "admin");
    ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
    Connection       = OPI_MongoDB.CreateConnection(ConnectionString);

    Collection = "new_collection";

    Filter   = New Structure("stringField,doubleField", "Text", 999);
    Deletion = OPI_MongoDB.GetDocumentDeletionStructure(Filter, 1); // Array or single

    Result = OPI_MongoDB.DeleteDocuments(Connection, Collection, Deletion, Base);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint mongodb DeleteDocuments \
             --dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
             --coll "new_collection" \
             --deletes "{'q':{'stringField':'Text','doubleField':'999'},'limit':'1'}" \
             --db "main"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint mongodb DeleteDocuments ^
             --dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
             --coll "new_collection" ^
             --deletes "{'q':{'stringField':'Text','doubleField':'999'},'limit':'1'}" ^
             --db "main"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": true,
 "data": {
  "n": 1,
  "ok": 1
 }
}
```
