Metafacture meets MongoDB
metafacture-mongodb is a plugin for Metafacture. It provides the modules to-mongodb and from-mongodb to store and retrieve Metafacture streams to and from Mongo database collections.
- Stores Metafacture streams to a Mongo database collection
- Maps Metafacture records to MongoDB records
- Retrieves stored records by using record identifiers
- Keeps the hierachical structure of Metafacture records intact
metafacture-mongodb can be used as a plugin in the Metafacture distribution or as a Java library in your own programs.
Both modules need a MongoURI to connect to the Mongo database instance.
Acts as a StreamReciever
and writes each stream record as MongoDB record to the given MongoDB collection. This module provides no output.
Acts as an ObjectPipe<String, StreamReceiver>
. Each input string represents the identifier of one record, which is fetched from the given MongoDB collection and transformed to a Metafacture stream.
The following Flux script opens a file, interprets the content as pica records and stores them to a MongoDB database.
default fileName = FLUX_DIR + "10.pica";
default mongoUri = "mongodb://localhost/pica.records";
fileName|
open-file|
as-lines|
decode-pica|
to-mongodb(mongoUri);
This Flux script retrieves a record by its identifier and writes the stored stream to stdout:
default identifier = "1234567890";
default mongoUri = "mongodb://localhost/pica.records";
identifier|
from-mongodb(mongoUri)|
encode-formeta(style="multiline")|
write("stdout");