--- title: "system.mongodb.insertMany" description: "Inserts a list of PyDictionaries into a specified collection." --- # system.mongodb.insertMany > Inserts a list of PyDictionaries into a specified collection. This function is used in **Python Scripting**. :::note Project Library scripts will not provide hints for MongoDB system functions unless the Script Hint Scope is set to **Gateway**. See the [Scripting in Ignition](platform\scripting\scripting-in-ignition\scripting-in-ignition.md#system-functions-hints-and-autocomplete) page for more details on scripting hints. ::: ## Description ## Client Permission Restrictions This scripting function has no [Client Permission](../../../ignition-modules/vision/vision-project-properties/vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.mongodb.insertMany(connector, collection, document, [options])` ### Parameters Type | Parameter | Description ------- | ------- | ------ String| `connector` | The name of connector (case-insensitive). String| `collection` | The name of collection (case-sensitive). List[PyDictionary]| `document` | A list of PyDictionaries that will represent new records being added to the collection. [See MongoDB documentation](https://www.mongodb.com/docs/v6.0/core/document/) for more details about documents. PyDictionary| `options` | A PyDictionary for including additional insert configurations. [optional]. ### Returns **List[PyObject]** `objectIdList` - Keys representing the inserted documents. The keys will usually be BSON document ObjectId, unless a different key type is specified. ### Scope Gateway, Perspective Session ## Importing Classes You can import classes from system.mongodb.types like you would other Python classes: #### Example ``` from system.mongodb.types import ObjectId newObjectId = ObjectId.get() ``` You can also iterate those system.mongodb.types packages to see all available classes: #### Example ``` for d in dir(system.mongodb.types): print d ``` ### API Docs MongoDB-specific data types come from the org.bson.types package of the Mongo Java Driver API. The library of classes available for import can be accessed at this link: [Mongo Java Driver 3.6.0 API Docs for Package org.bson.types](https://mongodb.github.io/mongo-java-driver/3.6/javadoc/org/bson/types/package-summary.html). ## Types References The following values can be referenced for the types parameter at system.mongodb.types: ``` Binary Code CodeWScope CodeWithScope Decimal128 INSTANCE MaxKey MinKey ObjectId Symbol Timestamp ``` ## Code Examples ```python title="Example #1" # Import required BSON types. from system.mongodb.types import ObjectId # Specify required fields in a PyDictionary format for each BSON document in the list. documents = [ { "_id": ObjectId(), "username": "jdoe", "name": "Jane Doe", "address": '123 First Street, City CA 12345', "birthdate": system.date.getDate(2001, 4, 22), "email": "jdoe@email.com", "active": True, "accounts": [], "tier_and_details": {} }, { "_id": ObjectId(), "username": "tanderson", "name": "Thomas Anderson", "address": '456 Seventh Street, City CA 98765', "birthdate": system.date.getDate(1999, 3, 31), "email": "tanderson@email.com", "active": True, "accounts": [], "tier_and_details": {} } ] # Apply parameters for function call. print system.mongodb.insertMany("MongoDB", "customers", documents) ```