MongoDB

MongoDB is a free and open-source cross-platform document-oriented database.

Integration with LogicHub

Connecting with MongoDB

To connect to MongoDB following details are required:

  • Label: Connection name.
  • Reference Values: Define variables here to templatize integration connections and actions. For example, you can use https://www.{{hostname}}.com where, hostname is a variable defined in this input. For more information on how to add data, see 'Add Data' Input Type for Integrations.
  • Server IP or Hostname for MongoDB: Enter server's IP or Hostname where MongoDB is installed and the instance is running.
  • Port number for MongoDB: Enter the port number for MongoDB instance.
  • Enter database name: Database name for MongoDB.
  • Enter collection name: Collection name for MongoDB.
  • Username: Username for MongoDB.
  • Password: Password for MongoDB.

Actions with MongoDB

Query MongoDB (Deprecated)

Submits the given query to MongoDB and retrieves the result.

Inputs to this Action

  • Connection: Choose a connection that you have created.
  • Query for MongoDB: Enter the query string for the find operation. If you want to project certain fields provide them as comma-separated strings.
    Example: {"_id": "5"} or ip_address, _id

Output of Action
mongodb matched documents returned as multiple rows (uncorrelated).

  • has_error: True/False
  • error: message/null
  • other keys of mongodb document

Query MongoDB

Submits the given query to MongoDB and retrieves the result. Learn more on querying documents https://docs.mongodb.com/manual/tutorial/query-documents/

Inputs to this Action

  • Connection: Choose connection that you have created.
  • Query for MongoDB: Enter jinja-templated MongoDB query.
    Examples:
    {}
    {"mongo_col":"{{col_value}}"}
    {"mongo_col":"{{col_value}}"}, {"mongo_col": 1, "mongo_col1": 1, "mongo_col2": 1}
  • Limit (Optional): Limit number of results returned by running the above MongoDB query. (Default is 1000 results)

Output of Action
mongodb matched documents returned as multiple rows (correlated).

  • has_error: True/False
  • error: message/null
  • other keys of mongodb document

Aggregate

Performs an aggregate operation on MongoDB collections object.

Inputs to this Action

  • Connection: Choose a connection that you have created.
  • Pipeline: Enter jinja-templated pipeline for the aggregate operation.
    Example:
    [{"$match": {}}, {"$project": {"{{field_column}}": 1}}, {"$sort": {"{{field_column}}": -1, "_id": -1}}]

Output of Action
mongodb matched documents returned as multiple rows (correlated).

  • has_error: True/False
  • error: message/null
  • other keys of mongodb document

Did this page help you?