Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

220 lines (145 sloc) 8.029 kb

Mdbc Release Notes


New cmdlet Invoke-MdbcCommand for invoking any MongoDB commands including not covered by Mdbc or C# driver helpers. Mdbc becomes an interactive MongoDB shell on PowerShell steroids. NOTE: The parameters are not perhaps stabilized, they may depend on the feedback and suggestions.

Interactive profile Mdbc.ps1

  • New global function Get-MdbcHelp gets help for MongoDB commands.
  • New aliases imc ~ Invoke-MdbcCommand, gmh ~ Get-MdbcHelp.


New concept of the default server, database, and collection

In many cases the same collection variable is used in commands repeatedly. In order to avoid this redundancy this version introduces semi-automatic variables $Server, $Database, and $Collection and changes the role of Collection and Database parameters.

This change is breaking but easy to adopt. In scripts dealing with a single collection the collection argument should be simply removed, the default $Collection is used automatically. Alternatively, any collection can be specified explicitly with the named parameter Collection.

Cmdlet Connect-Mdbc

  • Renamed parameters Database -> DatabaseName, Collection -> CollectionName.
  • Instead of returning a server, database, or collection object the cmdlet creates their variables in the current scope. By default they are $Server, $Database, $Collection.
  • New parameters ServerVariable, DatabaseVariable, CollectionVariable can be used when several servers, databases, or collections are used in the same scope.

Cmdlets *-MdbcData

  • The parameter Collection changed from positional (0) to named. It should be specified explicitly or not used at all. In the latter case the current variable $Collection is used.

Cmdlet Add-MdbcCollection

  • The parameter Database changed from positional (0) to named. It should be specified explicitly or not used at all. In the latter case the current variable $Database is used.

Changed safe mode output

Cmdlets Add-MdbcData, Update-MdbcData, and Remove-MdbcData do not write safe mode results to output unless the new switch Result is used. In other words, without Result they do not output anything regardless of the safe mode.

If a safe mode result indicates an error then these cmdlets write an error. The result object is attached to the error record. As usual, to fail or not to fail depends on the current error action settings.

Other changes

Cmdlet New-MdbcData

  • Renamed parameters DocumentId -> Id, NewDocumentId -> NewId. The old names came from the C# driver where they were recently declared obsolete.

Cmdlet Invoke-MdbcMapReduce

  • Renamed parameter Result -> ResultVariable for consistency. The old name Result still works as partial but it is recommended to use the new name.


New cmdlet Invoke-MdbcMapReduce. The parameters are not yet stabilized and may change. NOTE: the SortBy requires an index though this is not documented well (or it might be a bug).

Removed obsolete parameter aliases: Limit and Select of Get-MdbcData (use First and Property) and Select of New-MdbcData (use Property).

Custom objects with the property _id can be used where a query is expected. For example, objects from Get-MdbcData -AsCustomObject can be passed in Remove-MdbcData, Update-MdbcData, and Get-MdbcData as queries.

New-MdbcQuery -And|Or|Nor - in addition to query objects arguments can be any expressions convertible to queries (e.g. @{Length = @{'$gt' = 1gb}}, @{..}).


  • The parameter DatabaseName accepts wildcards. If it is not resolved to an existing database name then the script prints all database names and exits.
  • New operator helpers $name = '$name' for query and update operators may reduce typing and typos and make expressions to look more like JSON.


Obsolete parameters: The following parameters were renamed or removed in order to follow PS guidelines; renamed still work but they will be removed in vNext:

  • Update-MdbcData - removed obsolete Updates, use Update.
  • Get-MdbcData - renamed Limit -> First, Select -> Property;
  • New-MdbcData - renamed Select -> Property.

Cmdlet Get-MdbcData

  • New switch AsCustomObject tells to get documents represented by PS objects. They are more convenient in some use cases, especially interactive.
  • New parameter Last. There is no analogue in the driver but in PowerShell it seems to be useful, especially in interactive sessions.

Removed the module script Mdbc.psm1 with its functions Convert-MdbcData (redundant, Get-MdbcData can now do this much more effectively) and Convert-MdbcJson (not really useful in PowerShell).

Demo helper Mdbc.ps1: renamed aliases for conformance with PS guidelines.


Cmdlet New-MdbcQuery

  • Breaking change. Revised parameters And, Nor, and Or. And cannot be omitted now. Nor and Or are not switches but, just as And, arrays of query expressions. This design is simpler and reduces chances of misuse.

Cmdlet Update-MdbcData

  • Obsolete parameter name. The parameter Updates was renamed to Update. The old name still works as an alias but it will be removed in vNext.

Cmdlet Get-MdbcData

  • New parameter As for getting strongly typed data (existing or added on-the-fly ad-hoc types, see Test-Get-As.ps1).
  • New parameters Remove, Update, New, Add. They provide FindAndRemove and FindAndModify capabilities.
  • New parameters Distinct and SortBy. The latter is used for standard queries and new Update and Remove modes.
  • Removed redundant switch Size. The switch Count does exactly the same job when used together with Limit and Skip.
  • Introduced parameter sets which prevent abuse of parameters. CAUTION: This change is potentially breaking, existing calls with meaningless parameter combinations will fail.

New helper script Mdbc.ps1 adds helpers for interactive use. Use it only as the example and base for your own interactive helpers. This script reflects personal preferences, its features may not be suitable for all scenarios and they may change at any time.

Added tests covering new features. Adapted scripts and tests to changes.


New cmdlet Add-MdbcCollection, mostly for creation of capped collections.

Update-MongoFiles.ps1 - amended removal of unknown and orphan data.


C# driver 1.4.2 (official).

Avoided use of deprecated API.

"." as the connection string uses the driver default instead of duplicating.

Breaking change (easy to fix): removed aliases query and update. Replace them with New-MdbcQuery and New-MdbcUpdate or use your own aliases. The reasons: a) aliases are mostly for interactive use, up to a user; b) query conflicts with query.exe (the alias wins but...); c) these two particular aliases used to cause subtle PowerShell issues on module updates.


C# driver


C# driver v1.4.1 patched for CSHARP-447.

Adapted for CSHARP-446.

Amended tests.

v1.0.6, v1.0.7

Fixed weird silent PS errors on exporting module aliases.


C# driver v1.4.0.

Amended conversion of null and BsonNull.

Update-MongoFiles.ps1 - updated for the latest version of Split-Pipeline.


Bug: Update-MongoFiles.ps1 -Split does not remove missing file records. Fixed.


New switch Split in the script Update-MongoFiles.ps1 tells to perform parallel data processing and improve performance for large directories or entire drives. It requires the PowerShell module SplitPipeline (it is not needed if Split is not used). SplitPipeline may be useful for other database related tasks, too, because processing of large data sets is typical.


C# driver v1.3.1.


C# driver v1.3.

Minor changes in tests and project infrastructure.

Jump to Line
Something went wrong with that request. Please try again.