{"id":13530413,"url":"https://github.com/nightroman/Mdbc","last_synced_at":"2025-04-01T18:31:43.397Z","repository":{"id":39261231,"uuid":"2360909","full_name":"nightroman/Mdbc","owner":"nightroman","description":"MongoDB Cmdlets for PowerShell","archived":false,"fork":false,"pushed_at":"2024-04-23T15:54:23.000Z","size":827,"stargazers_count":139,"open_issues_count":0,"forks_count":16,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-05-01T20:40:39.458Z","etag":null,"topics":["mongodb","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nightroman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["nightroman"]}},"created_at":"2011-09-10T13:51:00.000Z","updated_at":"2024-06-19T02:56:25.714Z","dependencies_parsed_at":"2024-01-16T20:33:30.437Z","dependency_job_id":"99dd7fb5-ad70-41ed-8dec-a6aa7d21177b","html_url":"https://github.com/nightroman/Mdbc","commit_stats":{"total_commits":171,"total_committers":1,"mean_commits":171.0,"dds":0.0,"last_synced_commit":"230787e8bc53caad88e1dcdb1efc36bba26be529"},"previous_names":[],"tags_count":96,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FMdbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FMdbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FMdbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FMdbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightroman","download_url":"https://codeload.github.com/nightroman/Mdbc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246691584,"owners_count":20818537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mongodb","powershell"],"created_at":"2024-08-01T07:00:49.473Z","updated_at":"2025-04-01T18:31:42.978Z","avatar_url":"https://github.com/nightroman.png","language":"PowerShell","funding_links":["https://github.com/sponsors/nightroman"],"categories":["Libraries"],"sub_categories":["PowerShell"],"readme":"\r\n[![PSGV](https://img.shields.io/powershellgallery/v/Mdbc)![PSGD](https://img.shields.io/powershellgallery/dt/Mdbc)](https://www.powershellgallery.com/packages/Mdbc)\r\n\r\n# Mdbc\r\n\r\nMongoDB Cmdlets for PowerShell Core 7.4\r\n\r\nThe PowerShell module based on the official [MongoDB C# driver](https://github.com/mongodb/mongo-csharp-driver)\r\n\r\n## Quick start\r\n\r\n**Step 1:** Get and install [Mdbc](https://www.powershellgallery.com/packages/Mdbc) from the PSGallery:\r\n\r\n```powershell\r\nInstall-Module Mdbc\r\n```\r\n\r\n**Step 2:** Import the module:\r\n\r\n```powershell\r\nImport-Module Mdbc\r\n```\r\n\r\n**Step 3:** See help and available commands:\r\n\r\n```powershell\r\nhelp about_Mdbc\r\nhelp Connect-Mdbc\r\nGet-Command -Module Mdbc\r\n```\r\n\r\n**Step 4:** Make sure mongod is running and try some commands:\r\n\r\n```powershell\r\n# Load the module\r\nImport-Module Mdbc\r\n\r\n# Connect the new collection test.test\r\nConnect-Mdbc . test test -NewCollection\r\n\r\n# Add two documents\r\n@{_id = 1; value = 42}, @{_id = 2; value = 3.14} | Add-MdbcData\r\n\r\n# Get documents as PS objects\r\nGet-MdbcData -As PS | Format-Table\r\n\r\n# Get the document by _id\r\nGet-MdbcData @{_id = 1}\r\n\r\n# Update the document, set 'value' to 100\r\nUpdate-MdbcData @{_id = 1} @{'$set' = @{value = 100}}\r\n\r\n# Get the document again, 'value' is 100\r\n$doc = Get-MdbcData @{_id = 1}\r\n\r\n# Remove the document\r\n$doc | Remove-MdbcData\r\n\r\n# Count documents, 1\r\nGet-MdbcData -Count\r\n```\r\n\r\n## Next Steps\r\n\r\n[Mdbc.ArgumentCompleters.ps1]: https://github.com/nightroman/Mdbc/blob/main/Scripts/Mdbc.ArgumentCompleters.ps1\r\n[Update-MongoFiles.ps1]: https://github.com/nightroman/Mdbc/blob/main/Scripts/Update-MongoFiles.ps1\r\n[HowTo.test.ps1]: https://github.com/nightroman/Mdbc/blob/main/Tests/HowTo.test.ps1\r\n[Classes.lib.ps1]: https://github.com/nightroman/Mdbc/blob/main/Tests/Classes.lib.ps1\r\n[Classes.test.ps1]: https://github.com/nightroman/Mdbc/blob/main/Tests/Classes.test.ps1\r\n[BsonFile]: https://github.com/nightroman/BsonFile\r\n\r\nRead cmdlet help topics and take a look at examples for some basic use cases.\r\n\r\nUse [Mdbc.ArgumentCompleters.ps1] for database and collection name completion and property completion.\r\nYou may install this script from the PSGallery as [Mdbc.ArgumentCompleters](https://www.powershellgallery.com/packages/Mdbc.ArgumentCompleters):\r\n\r\n```powershell\r\nInstall-Script Mdbc.ArgumentCompleters\r\n```\r\n\r\nUse [Update-MongoFiles.ps1], either for making some test data or for tracking file changes in practice.\r\n\r\nSee also tests, for example:\r\n\r\n- [HowTo.test.ps1] - assorted how-to samples\r\n- [Classes.lib.ps1] - PowerShell classes for saving and reading\r\n- [Classes.test.ps1] - tests using the above classes are how-to samples\r\n- [BsonFile] - Mdbc based script module for BSON/JSON file collections\r\n\r\n## Driver methods and module commands\r\n\r\n| Driver | Module  | Output\r\n| :----- | :-----  | :-----\r\n| **Client** | |\r\n| MongoClient | Connect-Mdbc | $Client $Database $Collection\r\n| GetDatabase | Get-MdbcDatabase | database(s)\r\n| DropDatabase | Remove-MdbcDatabase | none\r\n| Transactions | Use-MdbcTransaction | -\r\n| Watch | Watch-MdbcChange -Client | cursor\r\n| **Database** | |\r\n| RunCommand | Invoke-MdbcCommand | document\r\n| GetCollection | Get-MdbcCollection | collection(s)\r\n| CreateCollection | Add-MdbcCollection | none\r\n| RenameCollection | Rename-MdbcCollection | none\r\n| DropCollection | Remove-MdbcCollection | none\r\n| Watch | Watch-MdbcChange -Database | cursor\r\n| **Collection** | |\r\n| InsertOne | Add-MdbcData | none\r\n| InsertMany | Add-MdbcData -Many | none\r\n| Find | Get-MdbcData | documents\r\n| CountDocuments | Get-MdbcData -Count | count\r\n| Distinct | Get-MdbcData -Distinct | values\r\n| FindOneAndDelete | Get-MdbcData -Remove | old document\r\n| FindOneAndReplace | Get-MdbcData -Set | old or new document\r\n| FindOneAndUpdate | Get-MdbcData -Update | old or new document\r\n| DeleteOne | Remove-MdbcData | none or info (-Result)\r\n| DeleteMany | Remove-MdbcData -Many | none or info (-Result)\r\n| ReplaceOne | Set-MdbcData | none or info (-Result)\r\n| UpdateOne | Update-MdbcData | none or info (-Result)\r\n| UpdateMany | Update-MdbcData -Many | none or info (-Result)\r\n| Aggregate | Invoke-MdbcAggregate | documents\r\n| Watch | Watch-MdbcChange -Collection | cursor\r\n\r\n## See also\r\n\r\n- [Mdbc Release Notes](https://github.com/nightroman/Mdbc/blob/main/Release-Notes.md)\r\n- [about_Mdbc.help.txt](https://github.com/nightroman/Mdbc/blob/main/Module/en-US/about_Mdbc.help.txt)\r\n- [Ldbc, similar project for LiteDB](https://github.com/nightroman/Ldbc)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2FMdbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightroman%2FMdbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2FMdbc/lists"}