MongoDB Import

  • drobnikj/mongodb-import
  • Modified
  • Users 16
  • Runs 1.3M
  • Created by Author's avatarJakub Drobník

Act import objects to specific mongodb collection. You can pass list of plain objects or Apify key-value store as input. For info see readme bellow.

This act imports array of object to specific MongoDB colection.


You can specified import with attributes:

mongoUrl(String) - required

Connection url to MongoDB, see Connection String URI Format.

collection(String) - required

Collection name, where act imports objects.


Proxy url string. Only HTTP proxy can be used and it needs to allow "HTTP CONNECT" from non SSL ports. When this attribute is provided, connection to mongo database will be proxied through the provided proxy.


When this attribute is set to a String, the act will add a timestamp attribute to each record under the specified name.


Unique keys for object, if you specified unique keys, act try to find object with this attributes in DB and update it.


Text representation of a JavaScript function for transforming an object before importing it to the database. The function must be named transform, accept one parameter and return the transformed object (can be the same object). If the function returns undefined, the object will not be imported. The function may be async or return a promise. Note: If using double quotes, they need to be escaped. Example:

function transform(object){
    object.newAttribute = 'some_value';
    return object;



Array of object to import to DB.


Defines object from Apify key-value store to import.


Apify key-value store Id.


List of keys in Apify key-value store.

Input examples

  • Imports list of plains objects:
  "mongoUrl": "mongodb://user:pwd@",
  "collection": "my-collection",
  "timestampAttr": "created_at",
  "uniqueKeys": ["localUniqueKey"],
  "imports": {
    "plainObjects": [
        "test": "Hello"
        "test": "word"
  • Imports objects from Apify key-value store:
  "mongoUrl": "mongodb://user:pwd@",
  "collection": "my-collection",
  "imports": {
    "objectsFromKvs": {
        "storeId": "a7hasd86jds",
        "keys": ["results1"]


See how MongoDB Import is used in industries around the world