mongodb Table Function
Allows SELECT queries to be performed on data that is stored on a remote MongoDB server.
Syntax
Arguments
| Argument | Description | 
|---|---|
| host:port | MongoDB server address. | 
| database | Remote database name. | 
| collection | Remote collection name. | 
| user | MongoDB user. | 
| password | User password. | 
| structure | The schema for the ClickHouse table returned from this function. | 
| options | MongoDB connection string options (optional parameter). | 
| oid_columns | Comma-separated list of columns that should be treated as oidin the WHERE clause._idby default. | 
Tip
If you are using the MongoDB Atlas cloud offering please add these options:
You can also connect by URI:
| Argument | Description | 
|---|---|
| uri | Connection string. | 
| collection | Remote collection name. | 
| structure | The schema for the ClickHouse table returned from this function. | 
| oid_columns | Comma-separated list of columns that should be treated as oidin the WHERE clause._idby default. | 
Returned value
A table object with the same columns as the original MongoDB table.
Examples
Suppose we have a collection named my_collection defined in a MongoDB database named test, and we insert a couple of documents:
Let's query the collection using the mongodb table function:
or:
