Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork15
MongoDB Cmdlets for PowerShell
License
nightroman/Mdbc
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MongoDB Cmdlets for PowerShell Core 7.4
The PowerShell module based on the officialMongoDB C# driver
Step 1: Get and installMdbc from the PSGallery:
Install-Module MdbcStep 2: Import the module:
Import-Module MdbcStep 3: See help and available commands:
help about_MdbchelpConnect-MdbcGet-Command-Module Mdbc
Step 4: Make sure mongod is running and try some commands:
# Load the moduleImport-Module Mdbc# Connect the new collection test.testConnect-Mdbc. test test-NewCollection# Add two documents@{_id=1;value=42},@{_id=2;value=3.14}|Add-MdbcData# Get documents as PS objectsGet-MdbcData-As PS|Format-Table# Get the document by _idGet-MdbcData@{_id=1}# Update the document, set 'value' to 100Update-MdbcData@{_id=1}@{'$set'=@{value=100}}# Get the document again, 'value' is 100$doc=Get-MdbcData@{_id=1}# Remove the document$doc|Remove-MdbcData# Count documents, 1Get-MdbcData-Count
Read cmdlet help topics and take a look at examples for some basic use cases.
UseMdbc.ArgumentCompleters.ps1 for database and collection name completion and property completion.You may install this script from the PSGallery asMdbc.ArgumentCompleters:
Install-Script Mdbc.ArgumentCompletersUseUpdate-MongoFiles.ps1, either for making some test data or for tracking file changes in practice.
See also tests, for example:
- HowTo.test.ps1 - assorted how-to samples
- Classes.lib.ps1 - PowerShell classes for saving and reading
- Classes.test.ps1 - tests using the above classes are how-to samples
- BsonFile - Mdbc based script module for BSON/JSON file collections
| Driver | Module | Output |
|---|---|---|
| Client | ||
| MongoClient | Connect-Mdbc | $Client $Database $Collection |
| GetDatabase | Get-MdbcDatabase | database(s) |
| DropDatabase | Remove-MdbcDatabase | none |
| Transactions | Use-MdbcTransaction | - |
| Watch | Watch-MdbcChange -Client | cursor |
| Database | ||
| RunCommand | Invoke-MdbcCommand | document |
| GetCollection | Get-MdbcCollection | collection(s) |
| CreateCollection | Add-MdbcCollection | none |
| RenameCollection | Rename-MdbcCollection | none |
| DropCollection | Remove-MdbcCollection | none |
| Watch | Watch-MdbcChange -Database | cursor |
| Collection | ||
| InsertOne | Add-MdbcData | none |
| InsertMany | Add-MdbcData -Many | none |
| Find | Get-MdbcData | documents |
| CountDocuments | Get-MdbcData -Count | count |
| Distinct | Get-MdbcData -Distinct | values |
| FindOneAndDelete | Get-MdbcData -Remove | old document |
| FindOneAndReplace | Get-MdbcData -Set | old or new document |
| FindOneAndUpdate | Get-MdbcData -Update | old or new document |
| DeleteOne | Remove-MdbcData | none or info (-Result) |
| DeleteMany | Remove-MdbcData -Many | none or info (-Result) |
| ReplaceOne | Set-MdbcData | none or info (-Result) |
| UpdateOne | Update-MdbcData | none or info (-Result) |
| UpdateMany | Update-MdbcData -Many | none or info (-Result) |
| Aggregate | Invoke-MdbcAggregate | documents |
| Watch | Watch-MdbcChange -Collection | cursor |
About
MongoDB Cmdlets for PowerShell
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.