Actor

jaroslavhejlek/mongo-import

  • Builds
  • latest 0.0.3 / 2018-03-29
  • Created 2018-03-29
  • Last modified 2018-09-12
  • grade 4

Description

Sadly, this actor has no description.


API

To run the actor, send a HTTP POST request to:

https://api.apify.com/v2/acts/jaroslavhejlek~mongo-import/runs?token=<YOUR_API_TOKEN>

The POST payload will be passed as input for the actor. For more information, read the docs.


Example input

Content type: application/json; charset=utf-8

{ "hello": 123 }

Readme

apify-act-mongodb-import

This act imports array of object to specific MongoDB colection.

Input

You can specified import with attributes:

mongoUrl(String) - required

Connection url to MongoDB, see [https://docs.mongodb.com/manual/reference/connection-string/](Connection String URI Format).

collection(String) - required

Collection name, where act imports objects.

proxyUrl(String)

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.

timestampAttr(String)

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

uniqueKeys(Array)

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

transformFunction(String)

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;
}

imports(Object)

plainObjects(Array)

Array of object to import to DB.

objectsFromKvs(Object)

Defines object from Apify key-value store to import.

storeId(String)

Apify key-value store Id.

keys(Array)

List of keys in Apify key-value store.

Input examples

  • Imports list of plains objects:

    {
    "mongoUrl": "mongodb://user:pwd@85.90.244.43:27017/db",
    "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@85.90.244.43:27017/db",
    "collection": "my-collection",
    "imports": {
      "objectsFromKvs": {
          "storeId": "a7hasd86jds",
          "keys": ["results1"]
      }
    }
    }