MongoDB Import avatar
MongoDB Import
Try for free

No credit card required

View all Actors
MongoDB Import

MongoDB Import

drobnikj/mongodb-import
Try for free

No credit card required

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.

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 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:

1function transform(object){
2    object.newAttribute = 'some_value';
3    return object;
4}

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:
1{
2  "mongoUrl": "mongodb://user:pwd@85.90.244.43:27017/db",
3  "collection": "my-collection",
4  "timestampAttr": "created_at",
5  "uniqueKeys": ["localUniqueKey"],
6  "imports": {
7    "plainObjects": [
8      {
9        "test": "Hello"
10      },
11      {
12        "test": "word"
13      }
14    ]
15  }
16}
  • Imports objects from Apify key-value store:
1{
2  "mongoUrl": "mongodb://user:pwd@85.90.244.43:27017/db",
3  "collection": "my-collection",
4  "imports": {
5    "objectsFromKvs": {
6        "storeId": "a7hasd86jds",
7        "keys": ["results1"]
8    }
9  }
10}
Developer
Maintained by Community
Actor metrics
  • 2 monthly users
  • 0.0% runs succeeded
  • 30.0 days response time
  • Created in Dec 2017
  • Modified 6 months ago
Categories