|
| 1 | +--- |
| 2 | +title: MongoDB |
| 3 | +description: Connect to MongoDB database |
| 4 | +--- |
| 5 | + |
| 6 | +import { BlockInfoCard } from "@/components/ui/block-info-card" |
| 7 | + |
| 8 | +<BlockInfoCard |
| 9 | + type="mongodb" |
| 10 | + color="#E0E0E0" |
| 11 | + icon={true} |
| 12 | + iconSvg={`<svg className="block-icon" xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 128'> |
| 13 | + <path |
| 14 | + fillRule='evenodd' |
| 15 | + clipRule='evenodd' |
| 16 | + fill='currentColor' |
| 17 | + d='M88.038 42.812c1.605 4.643 2.761 9.383 3.141 14.296.472 6.095.256 12.147-1.029 18.142-.035.165-.109.32-.164.48-.403.001-.814-.049-1.208.012-3.329.523-6.655 1.065-9.981 1.604-3.438.557-6.881 1.092-10.313 1.687-1.216.21-2.721-.041-3.212 1.641-.014.046-.154.054-.235.08l.166-10.051-.169-24.252 1.602-.275c2.62-.429 5.24-.864 7.862-1.281 3.129-.497 6.261-.98 9.392-1.465 1.381-.215 2.764-.412 4.148-.618z' |
| 18 | + /> |
| 19 | + <path |
| 20 | + fillRule='evenodd' |
| 21 | + clipRule='evenodd' |
| 22 | + fill='#45A538' |
| 23 | + d='M61.729 110.054c-1.69-1.453-3.439-2.842-5.059-4.37-8.717-8.222-15.093-17.899-18.233-29.566-.865-3.211-1.442-6.474-1.627-9.792-.13-2.322-.318-4.665-.154-6.975.437-6.144 1.325-12.229 3.127-18.147l.099-.138c.175.233.427.439.516.702 1.759 5.18 3.505 10.364 5.242 15.551 5.458 16.3 10.909 32.604 16.376 48.9.107.318.384.579.583.866l-.87 2.969z' |
| 24 | + /> |
| 25 | + <path |
| 26 | + fillRule='evenodd' |
| 27 | + clipRule='evenodd' |
| 28 | + fill='#46A037' |
| 29 | + d='M88.038 42.812c-1.384.206-2.768.403-4.149.616-3.131.485-6.263.968-9.392 1.465-2.622.417-5.242.852-7.862 1.281l-1.602.275-.012-1.045c-.053-.859-.144-1.717-.154-2.576-.069-5.478-.112-10.956-.18-16.434-.042-3.429-.105-6.857-.175-10.285-.043-2.13-.089-4.261-.185-6.388-.052-1.143-.236-2.28-.311-3.423-.042-.657.016-1.319.029-1.979.817 1.583 1.616 3.178 2.456 4.749 1.327 2.484 3.441 4.314 5.344 6.311 7.523 7.892 12.864 17.068 16.193 27.433z' |
| 30 | + /> |
| 31 | + <path |
| 32 | + fillRule='evenodd' |
| 33 | + clipRule='evenodd' |
| 34 | + fill='#409433' |
| 35 | + d='M65.036 80.753c.081-.026.222-.034.235-.08.491-1.682 1.996-1.431 3.212-1.641 3.432-.594 6.875-1.13 10.313-1.687 3.326-.539 6.652-1.081 9.981-1.604.394-.062.805-.011 1.208-.012-.622 2.22-1.112 4.488-1.901 6.647-.896 2.449-1.98 4.839-3.131 7.182a49.142 49.142 0 01-6.353 9.763c-1.919 2.308-4.058 4.441-6.202 6.548-1.185 1.165-2.582 2.114-3.882 3.161l-.337-.23-1.214-1.038-1.256-2.753a41.402 41.402 0 01-1.394-9.838l.023-.561.171-2.426c.057-.828.133-1.655.168-2.485.129-2.982.241-5.964.359-8.946z' |
| 36 | + /> |
| 37 | + <path |
| 38 | + fillRule='evenodd' |
| 39 | + clipRule='evenodd' |
| 40 | + fill='#4FAA41' |
| 41 | + d='M65.036 80.753c-.118 2.982-.23 5.964-.357 8.947-.035.83-.111 1.657-.168 2.485l-.765.289c-1.699-5.002-3.399-9.951-5.062-14.913-2.75-8.209-5.467-16.431-8.213-24.642a4498.887 4498.887 0 00-6.7-19.867c-.105-.31-.407-.552-.617-.826l4.896-9.002c.168.292.39.565.496.879a6167.476 6167.476 0 016.768 20.118c2.916 8.73 5.814 17.467 8.728 26.198.116.349.308.671.491 1.062l.67-.78-.167 10.052z' |
| 42 | + /> |
| 43 | + <path |
| 44 | + fillRule='evenodd' |
| 45 | + clipRule='evenodd' |
| 46 | + fill='#4AA73C' |
| 47 | + d='M43.155 32.227c.21.274.511.516.617.826a4498.887 4498.887 0 016.7 19.867c2.746 8.211 5.463 16.433 8.213 24.642 1.662 4.961 3.362 9.911 5.062 14.913l.765-.289-.171 2.426-.155.559c-.266 2.656-.49 5.318-.814 7.968-.163 1.328-.509 2.632-.772 3.947-.198-.287-.476-.548-.583-.866-5.467-16.297-10.918-32.6-16.376-48.9a3888.972 3888.972 0 00-5.242-15.551c-.089-.263-.34-.469-.516-.702l3.272-8.84z' |
| 48 | + /> |
| 49 | + <path |
| 50 | + fillRule='evenodd' |
| 51 | + clipRule='evenodd' |
| 52 | + fill='#57AE47' |
| 53 | + d='M65.202 70.702l-.67.78c-.183-.391-.375-.714-.491-1.062-2.913-8.731-5.812-17.468-8.728-26.198a6167.476 6167.476 0 00-6.768-20.118c-.105-.314-.327-.588-.496-.879l6.055-7.965c.191.255.463.482.562.769 1.681 4.921 3.347 9.848 5.003 14.778 1.547 4.604 3.071 9.215 4.636 13.813.105.308.47.526.714.786l.012 1.045c.058 8.082.115 16.167.171 24.251z' |
| 54 | + /> |
| 55 | + <path |
| 56 | + fillRule='evenodd' |
| 57 | + clipRule='evenodd' |
| 58 | + fill='#60B24F' |
| 59 | + d='M65.021 45.404c-.244-.26-.609-.478-.714-.786-1.565-4.598-3.089-9.209-4.636-13.813-1.656-4.93-3.322-9.856-5.003-14.778-.099-.287-.371-.514-.562-.769 1.969-1.928 3.877-3.925 5.925-5.764 1.821-1.634 3.285-3.386 3.352-5.968.003-.107.059-.214.145-.514l.519 1.306c-.013.661-.072 1.322-.029 1.979.075 1.143.259 2.28.311 3.423.096 2.127.142 4.258.185 6.388.069 3.428.132 6.856.175 10.285.067 5.478.111 10.956.18 16.434.008.861.098 1.718.152 2.577z' |
| 60 | + /> |
| 61 | + <path |
| 62 | + fillRule='evenodd' |
| 63 | + clipRule='evenodd' |
| 64 | + fill='#A9AA88' |
| 65 | + d='M62.598 107.085c.263-1.315.609-2.62.772-3.947.325-2.649.548-5.312.814-7.968l.066-.01.066.011a41.402 41.402 0 001.394 9.838c-.176.232-.425.439-.518.701-.727 2.05-1.412 4.116-2.143 6.166-.1.28-.378.498-.574.744l-.747-2.566.87-2.969z' |
| 66 | + /> |
| 67 | + <path |
| 68 | + fillRule='evenodd' |
| 69 | + clipRule='evenodd' |
| 70 | + fill='#B6B598' |
| 71 | + d='M62.476 112.621c.196-.246.475-.464.574-.744.731-2.05 1.417-4.115 2.143-6.166.093-.262.341-.469.518-.701l1.255 2.754c-.248.352-.59.669-.728 1.061l-2.404 7.059c-.099.283-.437.483-.663.722l-.695-3.985z' |
| 72 | + /> |
| 73 | + <path |
| 74 | + fillRule='evenodd' |
| 75 | + clipRule='evenodd' |
| 76 | + fill='#C2C1A7' |
| 77 | + d='M63.171 116.605c.227-.238.564-.439.663-.722l2.404-7.059c.137-.391.48-.709.728-1.061l1.215 1.037c-.587.58-.913 1.25-.717 2.097l-.369 1.208c-.168.207-.411.387-.494.624-.839 2.403-1.64 4.819-2.485 7.222-.107.305-.404.544-.614.812-.109-1.387-.22-2.771-.331-4.158z' |
| 78 | + /> |
| 79 | + <path |
| 80 | + fillRule='evenodd' |
| 81 | + clipRule='evenodd' |
| 82 | + fill='#CECDB7' |
| 83 | + d='M63.503 120.763c.209-.269.506-.508.614-.812.845-2.402 1.646-4.818 2.485-7.222.083-.236.325-.417.494-.624l-.509 5.545c-.136.157-.333.294-.398.477-.575 1.614-1.117 3.24-1.694 4.854-.119.333-.347.627-.525.938-.158-.207-.441-.407-.454-.623-.051-.841-.016-1.688-.013-2.533z' |
| 84 | + /> |
| 85 | + <path |
| 86 | + fillRule='evenodd' |
| 87 | + clipRule='evenodd' |
| 88 | + fill='#DBDAC7' |
| 89 | + d='M63.969 123.919c.178-.312.406-.606.525-.938.578-1.613 1.119-3.239 1.694-4.854.065-.183.263-.319.398-.477l.012 3.64-1.218 3.124-1.411-.495z' |
| 90 | + /> |
| 91 | + <path |
| 92 | + fillRule='evenodd' |
| 93 | + clipRule='evenodd' |
| 94 | + fill='#EBE9DC' |
| 95 | + d='M65.38 124.415l1.218-3.124.251 3.696-1.469-.572z' |
| 96 | + /> |
| 97 | + <path |
| 98 | + fillRule='evenodd' |
| 99 | + clipRule='evenodd' |
| 100 | + fill='#CECDB7' |
| 101 | + d='M67.464 110.898c-.196-.847.129-1.518.717-2.097l.337.23-1.054 1.867z' |
| 102 | + /> |
| 103 | + <path |
| 104 | + fillRule='evenodd' |
| 105 | + clipRule='evenodd' |
| 106 | + fill='#4FAA41' |
| 107 | + d='M64.316 95.172l-.066-.011-.066.01.155-.559-.023.56z' |
| 108 | + /> |
| 109 | + </svg>`} |
| 110 | +/> |
| 111 | + |
| 112 | +## Usage Instructions |
| 113 | + |
| 114 | +Connect to any MongoDB database to execute queries, manage data, and perform database operations. Supports find, insert, update, delete, and aggregation operations with secure connection handling. |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +## Tools |
| 119 | + |
| 120 | +### `mongodb_query` |
| 121 | + |
| 122 | +Execute find operation on MongoDB collection |
| 123 | + |
| 124 | +#### Input |
| 125 | + |
| 126 | +| Parameter | Type | Required | Description | |
| 127 | +| --------- | ---- | -------- | ----------- | |
| 128 | +| `host` | string | Yes | MongoDB server hostname or IP address | |
| 129 | +| `port` | number | Yes | MongoDB server port \(default: 27017\) | |
| 130 | +| `database` | string | Yes | Database name to connect to | |
| 131 | +| `username` | string | No | MongoDB username | |
| 132 | +| `password` | string | No | MongoDB password | |
| 133 | +| `authSource` | string | No | Authentication database | |
| 134 | +| `ssl` | string | No | SSL connection mode \(disabled, required, preferred\) | |
| 135 | +| `collection` | string | Yes | Collection name to query | |
| 136 | +| `query` | string | No | MongoDB query filter as JSON string | |
| 137 | +| `limit` | number | No | Maximum number of documents to return | |
| 138 | +| `sort` | string | No | Sort criteria as JSON string | |
| 139 | + |
| 140 | +#### Output |
| 141 | + |
| 142 | +| Parameter | Type | Description | |
| 143 | +| --------- | ---- | ----------- | |
| 144 | +| `message` | string | Operation status message | |
| 145 | +| `documents` | array | Array of documents returned from the query | |
| 146 | +| `documentCount` | number | Number of documents returned | |
| 147 | + |
| 148 | +### `mongodb_insert` |
| 149 | + |
| 150 | +Insert documents into MongoDB collection |
| 151 | + |
| 152 | +#### Input |
| 153 | + |
| 154 | +| Parameter | Type | Required | Description | |
| 155 | +| --------- | ---- | -------- | ----------- | |
| 156 | +| `host` | string | Yes | MongoDB server hostname or IP address | |
| 157 | +| `port` | number | Yes | MongoDB server port \(default: 27017\) | |
| 158 | +| `database` | string | Yes | Database name to connect to | |
| 159 | +| `username` | string | No | MongoDB username | |
| 160 | +| `password` | string | No | MongoDB password | |
| 161 | +| `authSource` | string | No | Authentication database | |
| 162 | +| `ssl` | string | No | SSL connection mode \(disabled, required, preferred\) | |
| 163 | +| `collection` | string | Yes | Collection name to insert into | |
| 164 | +| `documents` | array | Yes | Array of documents to insert | |
| 165 | + |
| 166 | +#### Output |
| 167 | + |
| 168 | +| Parameter | Type | Description | |
| 169 | +| --------- | ---- | ----------- | |
| 170 | +| `message` | string | Operation status message | |
| 171 | +| `documentCount` | number | Number of documents inserted | |
| 172 | +| `insertedId` | string | ID of inserted document \(single insert\) | |
| 173 | +| `insertedIds` | array | Array of inserted document IDs \(multiple insert\) | |
| 174 | + |
| 175 | +### `mongodb_update` |
| 176 | + |
| 177 | +Update documents in MongoDB collection |
| 178 | + |
| 179 | +#### Input |
| 180 | + |
| 181 | +| Parameter | Type | Required | Description | |
| 182 | +| --------- | ---- | -------- | ----------- | |
| 183 | +| `host` | string | Yes | MongoDB server hostname or IP address | |
| 184 | +| `port` | number | Yes | MongoDB server port \(default: 27017\) | |
| 185 | +| `database` | string | Yes | Database name to connect to | |
| 186 | +| `username` | string | No | MongoDB username | |
| 187 | +| `password` | string | No | MongoDB password | |
| 188 | +| `authSource` | string | No | Authentication database | |
| 189 | +| `ssl` | string | No | SSL connection mode \(disabled, required, preferred\) | |
| 190 | +| `collection` | string | Yes | Collection name to update | |
| 191 | +| `filter` | string | Yes | Filter criteria as JSON string | |
| 192 | +| `update` | string | Yes | Update operations as JSON string | |
| 193 | +| `upsert` | boolean | No | Create document if not found | |
| 194 | +| `multi` | boolean | No | Update multiple documents | |
| 195 | + |
| 196 | +#### Output |
| 197 | + |
| 198 | +| Parameter | Type | Description | |
| 199 | +| --------- | ---- | ----------- | |
| 200 | +| `message` | string | Operation status message | |
| 201 | +| `matchedCount` | number | Number of documents matched by filter | |
| 202 | +| `modifiedCount` | number | Number of documents modified | |
| 203 | +| `documentCount` | number | Total number of documents affected | |
| 204 | +| `insertedId` | string | ID of inserted document \(if upsert\) | |
| 205 | + |
| 206 | +### `mongodb_delete` |
| 207 | + |
| 208 | +Delete documents from MongoDB collection |
| 209 | + |
| 210 | +#### Input |
| 211 | + |
| 212 | +| Parameter | Type | Required | Description | |
| 213 | +| --------- | ---- | -------- | ----------- | |
| 214 | +| `host` | string | Yes | MongoDB server hostname or IP address | |
| 215 | +| `port` | number | Yes | MongoDB server port \(default: 27017\) | |
| 216 | +| `database` | string | Yes | Database name to connect to | |
| 217 | +| `username` | string | No | MongoDB username | |
| 218 | +| `password` | string | No | MongoDB password | |
| 219 | +| `authSource` | string | No | Authentication database | |
| 220 | +| `ssl` | string | No | SSL connection mode \(disabled, required, preferred\) | |
| 221 | +| `collection` | string | Yes | Collection name to delete from | |
| 222 | +| `filter` | string | Yes | Filter criteria as JSON string | |
| 223 | +| `multi` | boolean | No | Delete multiple documents | |
| 224 | + |
| 225 | +#### Output |
| 226 | + |
| 227 | +| Parameter | Type | Description | |
| 228 | +| --------- | ---- | ----------- | |
| 229 | +| `message` | string | Operation status message | |
| 230 | +| `deletedCount` | number | Number of documents deleted | |
| 231 | +| `documentCount` | number | Total number of documents affected | |
| 232 | + |
| 233 | +### `mongodb_execute` |
| 234 | + |
| 235 | +Execute MongoDB aggregation pipeline |
| 236 | + |
| 237 | +#### Input |
| 238 | + |
| 239 | +| Parameter | Type | Required | Description | |
| 240 | +| --------- | ---- | -------- | ----------- | |
| 241 | +| `host` | string | Yes | MongoDB server hostname or IP address | |
| 242 | +| `port` | number | Yes | MongoDB server port \(default: 27017\) | |
| 243 | +| `database` | string | Yes | Database name to connect to | |
| 244 | +| `username` | string | No | MongoDB username | |
| 245 | +| `password` | string | No | MongoDB password | |
| 246 | +| `authSource` | string | No | Authentication database | |
| 247 | +| `ssl` | string | No | SSL connection mode \(disabled, required, preferred\) | |
| 248 | +| `collection` | string | Yes | Collection name to execute pipeline on | |
| 249 | +| `pipeline` | string | Yes | Aggregation pipeline as JSON string | |
| 250 | + |
| 251 | +#### Output |
| 252 | + |
| 253 | +| Parameter | Type | Description | |
| 254 | +| --------- | ---- | ----------- | |
| 255 | +| `message` | string | Operation status message | |
| 256 | +| `documents` | array | Array of documents returned from aggregation | |
| 257 | +| `documentCount` | number | Number of documents returned | |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | +## Notes |
| 262 | + |
| 263 | +- Category: `tools` |
| 264 | +- Type: `mongodb` |
0 commit comments