Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MongoDB Cmdlets for PowerShell

License

NotificationsYou must be signed in to change notification settings

nightroman/Mdbc

Repository files navigation

PSGVPSGD

Mdbc

MongoDB Cmdlets for PowerShell Core 7.4

The PowerShell module based on the officialMongoDB C# driver

Quick start

Step 1: Get and installMdbc from the PSGallery:

Install-Module Mdbc

Step 2: Import the module:

Import-Module Mdbc

Step 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

Next Steps

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.ArgumentCompleters

UseUpdate-MongoFiles.ps1, either for making some test data or for tracking file changes in practice.

See also tests, for example:

Driver methods and module commands

DriverModuleOutput
Client
MongoClientConnect-Mdbc$Client $Database $Collection
GetDatabaseGet-MdbcDatabasedatabase(s)
DropDatabaseRemove-MdbcDatabasenone
TransactionsUse-MdbcTransaction-
WatchWatch-MdbcChange -Clientcursor
Database
RunCommandInvoke-MdbcCommanddocument
GetCollectionGet-MdbcCollectioncollection(s)
CreateCollectionAdd-MdbcCollectionnone
RenameCollectionRename-MdbcCollectionnone
DropCollectionRemove-MdbcCollectionnone
WatchWatch-MdbcChange -Databasecursor
Collection
InsertOneAdd-MdbcDatanone
InsertManyAdd-MdbcData -Manynone
FindGet-MdbcDatadocuments
CountDocumentsGet-MdbcData -Countcount
DistinctGet-MdbcData -Distinctvalues
FindOneAndDeleteGet-MdbcData -Removeold document
FindOneAndReplaceGet-MdbcData -Setold or new document
FindOneAndUpdateGet-MdbcData -Updateold or new document
DeleteOneRemove-MdbcDatanone or info (-Result)
DeleteManyRemove-MdbcData -Manynone or info (-Result)
ReplaceOneSet-MdbcDatanone or info (-Result)
UpdateOneUpdate-MdbcDatanone or info (-Result)
UpdateManyUpdate-MdbcData -Manynone or info (-Result)
AggregateInvoke-MdbcAggregatedocuments
WatchWatch-MdbcChange -Collectioncursor

See also

About

MongoDB Cmdlets for PowerShell

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

[8]ページ先頭

©2009-2025 Movatter.jp