Skip to content
Fyodor Kupolov edited this page May 6, 2013 · 11 revisions

Connection declaration

Driver class: org.scriptella.mongodb.Driver
URL: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
Runtime dependencies: MongoDB Java Driver

Usage example.

ETL which inserts a single record and then queries the collection and sends results to the text output:

<script connection-id="mongo">
    {
        operation: 'db.collection.save',
        collection: 'test',
        data: {value: '?{etl.date.now()}'}
    }
</script>

<query connection-id="in">
    {
        operation: 'db.collection.find',
        collection: 'users',
        data: {}
    }
    <script connection-id="log">
        Migrating User: user_id=$user_id
    </script>
</query>

Supported operations:

db.runCommand

Run a specified command. See MongoDB documenation for description.

Example:

<!-- Drop test collection -->
<script connection-id="mongo">
    {
        operation: 'db.runCommand',
        data: { drop: 'test' }
    }
</script>

db.collection.find

Selects documents from the collection and executes nested script/query elements for each document returned. The "data" parameter specifies the selection criteria. See MongoDB documenation for description.

Example

<!-- Migrate all users -->
<query connection-id="in">
    {
        operation: 'db.collection.find',
        collection: 'users',
        data: {}
    }
  <script ....   >
  • db.collection.save
  • db.collection.update

Known Issues and Limitations

Clone this wiki locally