Odysseus allows to read and write from a MongoDB store. As MongoDB stores its content in JSON format, only JSON can be read from MongoDB. Tuples send to MongoDB will automatically be transformed.

To use MongoDB please install the MongoDB-Feature.

Writing

Writing can be done with the Operator MongoDBSink.

Parameter

  • HOST: Server where the MongoDB server runs
  • PORT: Port of the MongoDB server
  • Database: Name of the MongoDB database (if not exists, it will be created)
  • Collectionname: Name of the collection to write to (if not exists, it will be created)
  • User: If configured with security: MongoDB user name
  • Password: If configured with security: MongoDB password
  • DeleteBeforeInsert: Remove tuples from the collection before inserting new ones (after start), default is false
  • DeleteEqualAttribute: If DeleteBeforeInsert = true and DeleteEqualAttribute is set with attribute name, only elements that have the same value in the attribute are removed from the collection.
  • BatchSize: How many elements should be read before writing to store.
  • BatchSizeTimeout: How many milliseconds should the writing wait, before writing to store.

Example

out = MONGODBSINK({HOST = 'localhost', PORT = 27017, Database = 'test', COLLECTIONNAME = 'person2'}, person)

Reading

Reading can be done with the Operator MongoDBSource. Remark: The source will always read key value objects. If you want to have tuples you need to apply the KeyValueToTuple operator.

Parameter

  • HOST: Server where the MongoDB server runs
  • PORT: Port of the MongoDB server
  • Database: Name of the MongoDB database (if not exists, it will be created)
  • Collectionname: Name of the collection to write to (if not exists, it will be created)
  • Reference_Object: A JSON string as reference object.
  • User: If configured with security: MongoDB user name
  • Password: If configured with security: MongoDB password
  • Delay_between_tuple: slow down the reading (milliseconds)
  • reload_data: when the collection is fully read, should be read from the beginning again
  • reload_data_interval: if reload_data is set to true, this parameter defines a pause between the runs (in milliseconds)
  • Max_Tuple_Count: Limit the number of elements that should be read from the source.

Example

in = MONGODBSOURCE({COLLECTIONNAME = 'person', HOST = 'localhost', PORT = 27017, Database = 'test'})
  • No labels