MongoDB Record Dataset

The MongoDB Record Dataset is a write-only dataset that writes to a MongoDB collection.

Rows are stored in collections with the following format:

{
    "_id" : <row name>,
    "<column name>", <column value>,
    ...
}

Caveats

Configuration

A new dataset of type mongodb.record named <id> can be created as follows:

mldb.put("/v1/datasets/"+<id>, {
    "type": "mongodb.record",
    "params": {
        "uriConnectionScheme": <string>,
        "collection": <string>
    }
})

with the following key-value definitions for params:

Field, Type, DefaultDescription

uriConnectionScheme
string

MongoDB connection scheme. mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database]]

collection
string

The collection to record to.

Example

Here we create the dataset named mldb_to_mongodb which will write to mongodb database zips collection mldb_coll.

mldb.put("/v1/datasets/mldb_to_mongodb", {
    "type": "mongodb.record",
    "params": {
        "connectionScheme": 'mongodb://somehost.mldb.ai:11712/zips',
        "collection": 'mldb_coll'
    }
})

Then we record a row with 2 columns.

print mldb.post('/v1/datasets/mldb_to_mongodb/rows', {
    'rowName' : 'row1',
    'columns' : [
        ['colA', 'valA', 0],
        ['colB', 'valB', 0]
    ]
})