Sling
Slingdata.ioBlogGithubHelp!
  • Introduction
  • Sling CLI
    • Installation
    • Environment
    • Running Sling
    • Global Variables
    • CLI Pro
  • Sling Platform
    • Sling Platform
      • Architecture
      • Agents
      • Connections
      • Editor
      • API
      • Deploy from CLI
  • Concepts
    • Replications
      • Structure
      • Modes
      • Source Options
      • Target Options
      • Columns
      • Transforms
      • Runtime Variables
      • Tags & Wildcards
    • Hooks / Steps
      • Check
      • Command
      • Copy
      • Delete
      • Group
      • Http
      • Inspect
      • List
      • Log
      • Query
      • Replication
      • Store
    • Pipelines
    • Data Quality
      • Constraints
  • Examples
    • File to Database
      • Custom SQL
      • Incremental
    • Database to Database
      • Custom SQL
      • Incremental
      • Backfill
    • Database to File
      • Incremental
  • Connections
    • Database Connections
      • BigTable
      • BigQuery
      • Cloudflare D1
      • Clickhouse
      • DuckDB
      • MotherDuck
      • MariaDB
      • MongoDB
      • Elasticsearch
      • MySQL
      • Oracle
      • Postgres
      • Prometheus
      • Proton
      • Redshift
      • StarRocks
      • SQLite
      • SQL Server
      • Snowflake
      • Trino
    • Storage Connections
      • AWS S3
      • Azure Storage
      • Backblaze B2
      • Cloudflare R2
      • DigitalOcean Spaces
      • FTP
      • Google Storage
      • Local Storage
      • Min.IO
      • SFTP
      • Wasabi
Powered by GitBook
On this page
  • Setup
  • Using sling conns
  • Environment Variable
  • Sling Env File YAML
  • Examples
  1. Connections
  2. Database Connections

MongoDB

Extract data from a MongoDB instance

Setup

The following credentials keys are accepted:

  • host (required) -> The hostname / ip of the instance

  • user (required) -> The username to access the instance

  • password (optional) -> The password to access the instance

  • port (optional) -> The port of the instance. Default is 27017.

  • tls (optional) -> whether to use TLS for connecting (true/false).

  • cert_file (optional) -> the client certificate to use to access the instance via TLS (file path or raw)

  • cert_key_file (optional) -> the client key to use to access the instance via TLS (file path or raw)

  • cert_ca_file (optional) -> the client CA certificate to use to access the instance via TLS (file path or raw)

Using sling conns

Here are examples of setting a connection named MONGODB. We must provide the type=mongodb property:

$ sling conns set MONGODB type=mongodb host=<host> user=<user> password=<password> port=<port> 

Environment Variable

# see https://www.mongodb.com/docs/manual/reference/connection-string-options/#std-label-connections-connection-options for URL options
export MONGODB='mongodb://root:password@host.ip:27017?authSource=<database>'
export MONGODB='{ type: mongodb, user: "root", password: "password", host: "host.ip", port: 27017, authSource: "<database>" }'

Sling Env File YAML

connections:
  MONGODB:
    type: mongodb
    host: host.ip
    port: 27017
    user: <user>
    password: <password>
    tls: true # if TLS connection needed

  # see https://www.mongodb.com/docs/manual/reference/connection-string-options/#std-label-connections-connection-options for URL options
  MONGODB_URL:
    type: mongodb
    url: mongodb://root:password@host.ip:27017?authSource=<database>

  MONGODB_TLS:
    type: mongodb
    url: mongodb://root:password@host.ip:27017?tls=true

Examples

source: mongodb
target: oracle

defaults:
  mode: full-refresh
  object: user1.{stream_schema}_{stream_table}
s
streams:
  db1.collection1:
  db1.collection2:
    select: [col1, col2]
    where: '{"field": "value", "field2": {"$gt": 100}}'  # use "where" starting v1.3.6
  db2.collection3:
    where: '[{"$or": [{"field1": "value1"}, {"field2": "value2"}]}]'  # use "where" starting v1.3.6
  db2.collection4:
    mode: incremental
    primary_key: [id]
    update_key: last_mod_at
PreviousMariaDBNextElasticsearch

Last updated 5 days ago

See to learn more about the sling env.yaml file.

If you are facing issues connecting, please reach out to us at , on or open a Github Issue .

support@slingdata.io
discord
here
here