en-US/Mdbc.dll-Help.xml
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns="http://msh" schema="maml"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Connect-Mdbc</command:name> <maml:description> <maml:para>Connects a server, database, and collection.</maml:para> </maml:description> <command:verb>Connect</command:verb> <command:noun>Mdbc</command:noun> </command:details> <maml:description> <maml:para>The cmdlet connects the specified server, database, and collection and creates their reference variables in the current scope. With default names they are Server, Database, and Collection. The * used as a name tells to get all database names for a server or collection names for a database. If none of the parameters ConnectionString, DatabaseName, CollectionName is specified then they are assumed to be ., test, test respectively.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Connect-Mdbc</maml:name> <command:parameter required="false" position="1" > <maml:name>ConnectionString</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="2" > <maml:name>DatabaseName</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="3" > <maml:name>CollectionName</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CollectionVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>DatabaseVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ServerVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Timeout</maml:name> <command:parameterValue required="true">TimeSpan</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewCollection</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>ConnectionString</maml:name> <maml:description> <maml:para>Connection string (see driver manuals for details): mongodb://[username:password@]hostname[:port][/[database][?options]] "." is used for the default driver connection. Examples: mongodb://localhost:27017 mongodb://myaccount:mypass@remotehost.example.com/mydatabase</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="2" > <maml:name>DatabaseName</maml:name> <maml:description> <maml:para>Database name. * is used in order to get all database objects.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="3" > <maml:name>CollectionName</maml:name> <maml:description> <maml:para>Collection name. * is used in order to get all collection objects.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CollectionVariable</maml:name> <maml:description> <maml:para>Name of a new variable in the current scope with the connected collection. The default variable name is Collection. The default variable is used implicitly by cmdlets operating on collection data.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>DatabaseVariable</maml:name> <maml:description> <maml:para>Name of a new variable in the current scope with the connected database. The default variable name is Database.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewCollection</maml:name> <maml:description> <maml:para>Tells to remove an existing collection if any and connect a new one.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ServerVariable</maml:name> <maml:description> <maml:para>Name of a new variable in the current scope with the connected server. The default variable name is Server.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Timeout</maml:name> <maml:description> <maml:para>Determines the maximum time to wait before timing out.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>None or database or collection names.</maml:name> </dev:type> </command:returnValue> </command:returnValues> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Connect to a new collection (drop existing) Import-Module Mdbc Connect-Mdbc . test test -NewCollection</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># Connect to the database Import-Module Mdbc Connect-Mdbc . test # Then get collections $collection1 = $Database.GetCollection('test') $collection2 = $Database.GetCollection('process')</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title> <dev:code># Connect to the server Import-Module Mdbc Connect-Mdbc mongodb://localhost # Then get the database $Database = $Server.GetDatabase('test')</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title> <dev:code># Connect to the default server and get all databases Import-Module Mdbc Connect-Mdbc . *</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 5 --------------------------</maml:title> <dev:code># Connect to the database 'test' and get all collections Import-Module Mdbc Connect-Mdbc . test *</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Add-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>MongoDB</maml:linkText> <maml:uri>http://www.mongodb.org</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>New-MdbcData</command:name> <maml:description> <maml:para>Creates data documents and some other driver types.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>This command is used to create one or more documents (input objects come from the pipeline or as the first parameter InputObject) or a single BsonValue (by the named parameter Value). Created documents are used by Add-MdbcData and Export-MdbcData. These cmdlets also have parameters Id, NewId, Convert, Property for making documents from input objects. Thus, in some cases intermediate use of New-MdbcData is not needed. Mdbc.Dictionary Result documents are returned as Mdbc.Dictionary objects. Mdbc.Dictionary holds an underlying BsonDocument (Document()) and implements IDictionary. It works as a hashtable where keys are case sensitive strings and input and output values are convenient .NET types instead of underlying BsonValues. Main features: Useful members: $dictionary.Count $dictionary.Contains('key') $dictionary.Add('key', 'value') $dictionary.Remove('key') $dictionary.Clear() Setting values: $dictionary['key'] = ... $dictionary.key = ... Getting values: .. = $dictionary['key'] .. = $dictionary.key NOTE: On getting values the form "$dictionary.key" fails in strict mode (see Set-StrictMode) if the "key" is missing. The form "$dictionary['key'] is safe, it returns null for a missing key. Use Contains() in order to check existence of a key for sure.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-MdbcData</maml:name> <command:parameter required="false" position="named" > <maml:name>Value</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>InputObject</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <command:parameterValue required="true">ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" pipelineInput="true (ByValue)" position="1" > <maml:name>InputObject</maml:name> <maml:description> <maml:para>.NET object to be converted to Mdbc.Dictionary, PowerShell friendly wrapper of BsonDocument. Objects suitable for conversion are dictionaries, custom objects, and complex .NET types, normally not collections.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <maml:description> <maml:para>A script called on exceptions during conversion of unknown data to BsonValue. The variable $_ is the problem object to be converted. The script returns a single value to be tried instead or nothing for nulls. Examples: {} converts unknown data to nulls. {"$_"} converts data to strings, it is useful for preserving as much information as possible on dumping objects for later analysis. Converters should be used sparingly, normally with unknown or varying data. Consider to use Property for selecting standard and converting not standard known data.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <maml:description> <maml:para>The document _id value to be assigned or a script block returning this value for the input object represented by the variable $_. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> <maml:description> <maml:para>Tells to generate and assign a new document _id as MongoDB.Bson.ObjectId. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <maml:description> <maml:para>Specifies properties or keys which values are to be included into documents or defines calculated fields. Missing input properties and keys are ignored. Arguments are defined in three ways: 1. Strings define property or key names and the corresponding result document field names. 2. Hashtables @{Key=Value} define renamed and calculated fields. The key is a new document field name. The value is either a string (input object property name) or a script block (field value calculated from the input object $_). 3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but use the same convention as the parameter Property of Select-Object. See New-MdbcData examples.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Value</maml:name> <maml:description> <maml:para>An object to be converted to a BsonValue. Cmdlets and helper types do not need BsonValue's, they convert everything themselves. But BsonValue's may be needed for calling driver methods directly. Containers: [IDictionary] is converted to BsonDocument. [IEnumerable] is converted to BsonArray. Primitives: [bool] is converted to BsonBoolean. [DateTime] is converted to BsonDateTime. [double] is converted to BsonDouble. [Guid] is converted to BsonBinaryData (and retrieved back as [Guid]). [int] is converted to BsonInt32. [long] is converted to BsonInt64. [string] is converted to BsonString. If a primitive type is known than it is much more effective to create it directly than by this cmdlet, e.g. for a string: [MongoDB.Bson.BsonString]'Some text'</maml:para> </maml:description> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>$null</maml:name> </dev:type> <maml:description> <maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets. The native driver document [MongoDB.Bson.BsonDocument] can be used as well but normally it should not be used directly. Its wrapper [Mdbc.Dictionary] is more suitable in PowerShell.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[IDictionary]</maml:name> </dev:type> <maml:description> <maml:para>Dictionaries are converted to new documents. Keys are strings used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[PSObject]</maml:name> </dev:type> <maml:description> <maml:para>Objects are converted to new documents. Property names are used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>BsonDocument wrapper created from InputObject.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>[MongoDB.Bson.BsonValue]</maml:name> </dev:type> <maml:description> <maml:para>BsonValue objects created from Value.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Connect to the collection Import-Module Mdbc Connect-Mdbc . test test -NewCollection # Create a new document, set some data $data = New-MdbcData -Id 12345 $data.Text = 'Hello world' $data.Date = Get-Date # Add the document to the database $data | Add-MdbcData # Query the document from the database $result = Get-MdbcData (New-MdbcQuery _id 12345) $result</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># Connect to the collection Import-Module Mdbc Connect-Mdbc . test test -NewCollection # Create data from input objects and add to the database Get-Process mongod | New-MdbcData -Id {$_.Id} -Property Name, WorkingSet, StartTime | Add-MdbcData # Query the data $result = Get-MdbcData $result</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title> <dev:code># Example of various forms of property expressions. # Note that ExitCode throws, so that Code will be null. New-MdbcData (Get-Process -Id $Pid) -Property ` Name, # existing property name Missing, # missing property name is ignored @{WS1 = 'WS'}, # @{name = old name} - renamed property @{WS2 = {$_.WS}}, # @{name = scriptblock} - calculated field @{Ignored = 'Missing'}, # renaming of a missing property is ignored @{n = '_id'; e = 'Id'}, # @{name=...; expression=...} like Select-Object does @{l = 'Code'; e = 'ExitCode'} # @{label=...; expression=...} another like Select-Object</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Add-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Export-MdbcData</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>New-MdbcQuery</command:name> <maml:description> <maml:para>Creates a query expression for other commands.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>MdbcQuery</command:noun> </command:details> <maml:description> <maml:para>The cmdlet creates a query expression used by Get-MdbcData, Remove-MdbcData, Update-MdbcData. Parameters are named after the driver query builder methods. Most of queries have their alternative JSON-like forms, see parameter help.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="true" position="named" > <maml:name>And</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="true" position="named" > <maml:name>Not</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="true" position="named" > <maml:name>Or</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="true" position="named" > <maml:name>Where</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>All</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>ElemMatch</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="2" > <maml:name>EQ</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Exists</maml:name> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>GT</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>GTE</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>IEQ</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>In</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>INE</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>LT</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>LTE</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Matches</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Mod</maml:name> <command:parameterValue required="true">Int64[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NE</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NotExists</maml:name> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NotIn</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Size</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Type</maml:name> <command:parameterValue required="true">BsonType</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>New-MdbcQuery</maml:name> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>TypeAlias</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Name</maml:name> <maml:description> <maml:para>Field name for a field value test.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="2" > <maml:name>EQ</maml:name> <maml:description> <maml:para>Equality test. Parameter name is optional. JSON-like form: @{name = value}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>All</maml:name> <maml:description> <maml:para>Checks if the array contains all the specified values. JSON-like form: @{name = @{'$all' = @(value1, value2, ...)}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>And</maml:name> <maml:description> <maml:para>Logical And, normally on two or more query expressions. JSON-like form: @{'$and' = @(query-expression1, query-expression2, ...)}</maml:para> <maml:para>One argument can be used as well. For a previously created query it creates the same query. But it can be used for creating a query from other supported input types like hashtables.</maml:para> <maml:para>The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>ElemMatch</maml:name> <maml:description> <maml:para>Checks if an element in an array matches all the specified query expressions. JSON-like form: @{name = @{'$elemMatch' = @(expression1, expression2, ...)}}</maml:para> <maml:para>It is needed only when more than one field must be matched in an array element.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Exists</maml:name> <maml:description> <maml:para>Checks if the field exists. JSON-like form: @{name = @{'$exists' = $true}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>GT</maml:name> <maml:description> <maml:para>Greater than test. JSON-like form: @{name = @{'$gt' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>GTE</maml:name> <maml:description> <maml:para>Greater or equal test. JSON-like form: @{name = @{'$gte' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>IEQ</maml:name> <maml:description> <maml:para>Ignore case equality test for strings. JSON-like form is not available.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>In</maml:name> <maml:description> <maml:para>Checks if the field value equals or matches to one of the specified values or regular expressions. JSON-like form: @{name = @{'$in' = @(value1, value2, ...)}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>INE</maml:name> <maml:description> <maml:para>Ignore case inequality test for strings. JSON-like form is not available.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>LT</maml:name> <maml:description> <maml:para>Less than test. JSON-like form: @{name = @{'$lt' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>LTE</maml:name> <maml:description> <maml:para>Less or equal test. JSON-like form: @{name = @{'$lte' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Matches</maml:name> <maml:description> <maml:para>Regular expression test. JSON-like form: @{name = @{'$regex' = pattern; '$options' = 'i|m|x|s'}}</maml:para> <maml:para>The argument is one or two items. A single item is either a regular expression string pattern or a regular expression object. Two items are both strings: a regular expression pattern and options, combination of characters 'i', 'm', 'x', 's'.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Mod</maml:name> <maml:description> <maml:para>Modulo test. JSON-like form: @{name = @{'$mod' = @(divisor, remainder)}}</maml:para> <maml:para>The argument is an array of two items: the modulus and the result value to be tested.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NE</maml:name> <maml:description> <maml:para>Inequality test. JSON-like form: @{name = @{'$ne' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Not</maml:name> <maml:description> <maml:para>Tells to negate the query expression. JSON-like form: @{name = @{'$not' = operator-expression}</maml:para> <maml:para>The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NotExists</maml:name> <maml:description> <maml:para>Checks if the field is missing. JSON-like form: @{name = @{'$exists' = $false}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>NotIn</maml:name> <maml:description> <maml:para>Checks if the field is missing or its value does not equal or match to any of the specified values or regular expressions. JSON-like form: @{name = @{'$nin' = @(value1, value2, ...)}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Or</maml:name> <maml:description> <maml:para>Logical Or, normally on two or more query expressions. JSON-like form: @{'$or' = @(query-expression1, query-expression2, ...)}</maml:para> <maml:para>One argument can be used as well. For a previously created query it creates the same query. But it can be used for creating a query from other supported input types like hashtables.</maml:para> <maml:para>The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Size</maml:name> <maml:description> <maml:para>Array item count test. JSON-like form: @{name = @{'$size' = value}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Type</maml:name> <maml:description> <maml:para>Element type test. JSON-like form: @{name = @{'$type' = type}}</maml:para> <maml:para>Values : EndOfDocument, Double, String, Document, Array, Binary, Undefined, ObjectId, Boolean, DateTime, Null, RegularExpression, JavaScript, Symbol, JavaScriptWithScope, Int32, Timestamp, Int64, MaxKey, MinKey</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>TypeAlias</maml:name> <maml:description> <maml:para>Element type test with an alias. JSON-like form: @{name = @{'$type' = 'type'}}</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Where</maml:name> <maml:description> <maml:para>JavaScript Boolean expression test. JSON-like form: @{'$where' = code}</maml:para> <maml:para>The database evaluates the expression for each object scanned. JavaScript executes more slowly than native operators but is very flexible. See the server-side processing page for more information (official site).</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[MongoDB.Driver.IMongoQuery]</maml:name> </dev:type> <maml:description> <maml:para>Used by Get-MdbcData, Remove-MdbcData, Update-MdbcData, ...</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Get-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>MongoDB</maml:linkText> <maml:uri>http://www.mongodb.org</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>New-MdbcUpdate</command:name> <maml:description> <maml:para>Creates an update expression for Update-MdbcData.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>MdbcUpdate</command:noun> </command:details> <maml:description> <maml:para>This cmdlet creates update expressions used by Update-MdbcData. Parameters are named after driver update builder methods. They can be combined in order to create complex updates in a single call. Some parameters (Unset, PopFirst, PopLast) require only field names (String[]). Example: New-MdbcUpdate -Unset field1 -PopLast field2, field3 Other parameters require field names and associated arguments. Such parameters accept one or more hashtables (IDictionary). Each hashtable defines field names as keys and arguments as their values. The following commands are essentially the same: # Two hashtables with single entries New-MdbcUpdate -Set @{field1 = value1}, @{field2 = value2} # One hashtable with two entries New-MdbcUpdate -Set @{ field1 = value1 field2 = value2 }</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-MdbcUpdate</maml:name> <command:parameter required="false" position="1" > <maml:name>Set</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AddToSet</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AddToSetEach</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseAnd</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseOr</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseXor</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CurrentDate</maml:name> <command:parameterValue required="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Inc</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Max</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Min</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Mul</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PopFirst</maml:name> <command:parameterValue required="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PopLast</maml:name> <command:parameterValue required="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Pull</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PullAll</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Push</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PushAll</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Rename</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SetOnInsert</maml:name> <command:parameterValue required="true">PSObject[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Unset</maml:name> <command:parameterValue required="true">String[]</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Set</maml:name> <maml:description> <maml:para>Sets a field value. This parameter name can be omitted in a command, i.e. these commands are the same: New-MdbcUpdate @{field = value} New-MdbcUpdate -Set @{field = value} Mongo: { $set: { field1: <value1>, ... } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AddToSet</maml:name> <maml:description> <maml:para>Adds a value to an array only if the value is not in the array already. If a field argument is a collection then it is treated as a single value to add. Use AddToSetEach in order to add each value. Mongo: { $addToSet: { field: <addition> }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AddToSetEach</maml:name> <maml:description> <maml:para>Adds values to an array only if the values are not in the array already. Mongo: { $addToSet: { field: { $each: [ <value1>, <value2> ... ] } } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseAnd</maml:name> <maml:description> <maml:para>Performs bitwise AND update of integer values (int or long). Mongo: { $bit: { field: { and: NumberInt(5) } } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseOr</maml:name> <maml:description> <maml:para>Performs bitwise OR update of integer values (int or long). Mongo: { $bit: { field: { or: NumberInt(5) } } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BitwiseXor</maml:name> <maml:description> <maml:para>Performs bitwise XOR update of integer values (int or long). Mongo: { $bit: { field: { xor: NumberInt(5) } } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CurrentDate</maml:name> <maml:description> <maml:para>The $currentDate operator sets the value of a field to the current date. Mongo: { $currentDate: { field: true } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Inc</maml:name> <maml:description> <maml:para>Increments a field by a specified number. If a field does not exist, it adds the field and sets it to the specified value. It accepts positive and negative values (int, long, or double). Mongo: { $inc: { field: <number> } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Max</maml:name> <maml:description> <maml:para>The $max operator updates the value of the field to a specified value if the specified value is greater than the current value of the field. If the field does not exists, the $max operator sets the field to the specified value. The $max operator can compare values of different types, using the BSON comparison order. Mongo: { $max: { field: <value> } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Min</maml:name> <maml:description> <maml:para>The $min updates the value of the field to a specified value if the specified value is less than the current value of the field. If the field does not exists, the $min operator sets the field to the specified value. The $min operator can compare values of different types, using the BSON comparison order. Mongo: { $min: { field: <value> } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Mul</maml:name> <maml:description> <maml:para>Multiplies a field by a specified number. The field to update must contain a numeric value. If the field does not exist, it creates the field and sets the value to zero of the same numeric type as the multiplier. Mongo: { $mul: { field: <number> } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PopFirst</maml:name> <maml:description> <maml:para>Removes the first element in an array. It fails if a field is not an array. When it removes the last remaining item a field holds an empty array. Mongo: { $pop: { field: -1 } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PopLast</maml:name> <maml:description> <maml:para>Removes the last element in an array. It fails if a field is not an array. When it removes the last remaining item a field holds an empty array. Mongo: { $pop: { field: 1 } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Pull</maml:name> <maml:description> <maml:para>Removes matching values from a field if it is an array. It fails if a field is present but it is not an array. If a field argument is a collection then it is treated as a single value to pull. Use PullAll in order to remove each value. If a field argument is a query expression than items matching the expression are removed. The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries. Mongo: { $pull: { field: <value>|<query> } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PullAll</maml:name> <maml:description> <maml:para>Removes multiple values from an existing array. PullAll provides the inverse operation of the PushAll operator. Mongo: { $pullAll: { field: [ value1, value2, ... ] } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Push</maml:name> <maml:description> <maml:para>Appends a value to a field if it is an existing array, otherwise sets a field to an array with one value. It fails if a field is present but it is not an array. If a field argument is a collection then it is treated as a single value to push. Use PushAll in order to push all values. Mongo: { $push: { field: <value> }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>PushAll</maml:name> <maml:description> <maml:para>Appends all values to an array. Mongo: { $push: { field: { $each: [ value1, valu2 ... ] } } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Rename</maml:name> <maml:description> <maml:para>Renames a field. A field argument is a new field name. Mongo: { $rename: { <old name1>: <new name1> }, ... }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SetOnInsert</maml:name> <maml:description> <maml:para>Sets a field value on adding a new document during update. It has no effect on updates that modify existing documents. Mongo: { $setOnInsert: { field1: <value1>, ... } }</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Unset</maml:name> <maml:description> <maml:para>Tells to remove a field from an existing document. Mongo: { $unset: { field1: "", ... } }</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[MongoDB.Driver.IMongoUpdate]</maml:name> </dev:type> <maml:description> <maml:para>Update expression used by Update-MdbcData.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Update-MdbcData</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Add-MdbcData</command:name> <maml:description> <maml:para>Adds new documents to the database collection or updates existing.</maml:para> </maml:description> <command:verb>Add</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>Adds new documents to the database collection or updates existing.</maml:para> <maml:para>In order to output command result objects from a server use the switch Result. Depending on operations some server exceptions are caught and written as not terminating errors, i.e. processing of remaining pipelined objects continues. Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Add-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>InputObject</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <command:parameterValue required="true">ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <command:parameterValue required="true">WriteConcern</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Update</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" pipelineInput="true (ByValue)" position="1" > <maml:name>InputObject</maml:name> <maml:description> <maml:para>Document or a similar object, see INPUTS.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <maml:description> <maml:para>A script called on exceptions during conversion of unknown data to BsonValue. The variable $_ is the problem object to be converted. The script returns a single value to be tried instead or nothing for nulls. Examples: {} converts unknown data to nulls. {"$_"} converts data to strings, it is useful for preserving as much information as possible on dumping objects for later analysis. Converters should be used sparingly, normally with unknown or varying data. Consider to use Property for selecting standard and converting not standard known data.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <maml:description> <maml:para>The document _id value to be assigned or a script block returning this value for the input object represented by the variable $_. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> <maml:description> <maml:para>Tells to generate and assign a new document _id as MongoDB.Bson.ObjectId. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <maml:description> <maml:para>Specifies properties or keys which values are to be included into documents or defines calculated fields. Missing input properties and keys are ignored. Arguments are defined in three ways: 1. Strings define property or key names and the corresponding result document field names. 2. Hashtables @{Key=Value} define renamed and calculated fields. The key is a new document field name. The value is either a string (input object property name) or a script block (field value calculated from the input object $_). 3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but use the same convention as the parameter Property of Select-Object. See New-MdbcData examples.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> <maml:description> <maml:para>Tells to output an object returned by the driver.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Update</maml:name> <maml:description> <maml:para>Tells to update existing documents with the same _id or add new documents otherwise.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <maml:description> <maml:para>Write concern options.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>$null</maml:name> </dev:type> <maml:description> <maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets. The native driver document [MongoDB.Bson.BsonDocument] can be used as well but normally it should not be used directly. Its wrapper [Mdbc.Dictionary] is more suitable in PowerShell.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[IDictionary]</maml:name> </dev:type> <maml:description> <maml:para>Dictionaries are converted to new documents. Keys are strings used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[PSObject]</maml:name> </dev:type> <maml:description> <maml:para>Objects are converted to new documents. Property names are used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[MongoDB.Driver.WriteConcernResult]</maml:name> </dev:type> <maml:description> <maml:para>Result object from the driver is written if the switch Result is present.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>New-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Select-Object</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Get-MdbcData</command:name> <maml:description> <maml:para>Gets documents or information from a database collection.</maml:para> </maml:description> <command:verb>Get</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>This cmdlets invokes queries for the specified or default collection and outputs result documents or other data according to the parameters.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Get-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Distinct</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Remove</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Modes</maml:name> <command:parameterValue required="true">QueryFlags</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Count</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>First</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Last</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Modes</maml:name> <command:parameterValue required="true">QueryFlags</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Skip</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>First</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Last</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Modes</maml:name> <command:parameterValue required="true">QueryFlags</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Skip</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>Get-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Update</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Modes</maml:name> <command:parameterValue required="true">QueryFlags</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ResultVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Add</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>New</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies documents to be processed. The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Add</maml:name> <maml:description> <maml:para>Tells to add new documents on Update if old documents do not exist.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <maml:description> <maml:para>Specifies the representation of output documents. The argument is either a required type or a shortcut enum value for special types. A type specifies the output type literally. Type properties must match the document fields or the custom type serialization must be registered. Shortcuts, either enum values or strings: Default Default output, Mdbc.Dictionary with underlying BsonDocument. Lazy Mdbc.LazyDictionary with underlying LazyBsonDocument. Call Dispose() after use. Raw Mdbc.RawDictionary with underlying RawBsonDocument. Read only. Call Dispose() after use. PS PowerShell custom object. By default result documents are represented by Mdbc.Dictionary with underlying BsonDocument. See New-MdbcData for details. Use of its Lazy or Raw form may improve performance in some cases. In some scenarios other output types may be suitable like native .NET types (-As ([Type])) and PowerShell custom objects (-As PS). On choosing an output type keep in mind that Mdbc.Dictionary (BsonDocument) field names are case sensitive unlike object properties in PowerShell.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Count</maml:name> <maml:description> <maml:para>Tells to return the number of all documents or matching the Query. The First and Skip values are taken into account.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Distinct</maml:name> <maml:description> <maml:para>Specifies the field name and tells to return its distinct values for all documents or documents matching the Query.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>First</maml:name> <maml:description> <maml:para>Specifies the number of first documents to be returned. Non positive values are ignored.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Last</maml:name> <maml:description> <maml:para>Specifies the number of last documents to be returned. Non positive values are ignored.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Modes</maml:name> <maml:description> <maml:para>Additional query options. See the driver manual.</maml:para> <maml:para>Values : None, TailableCursor, SlaveOk, NoCursorTimeout, AwaitData, Exhaust, Partial</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>New</maml:name> <maml:description> <maml:para>Tells to return new documents on Update. By default old documents are returned.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <maml:description> <maml:para>Subset of fields to be retrieved. Note that the field _id is always included unless it is explicitly excluded. The argument is either strings specifying fields to be included or a single IMongoFields object which provides more options on selection of fields and their data (Include, Exclude, Slice, ElemMatch).</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Remove</maml:name> <maml:description> <maml:para>Tells to remove and get the first document specified by Query and SortBy.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ResultVariable</maml:name> <maml:description> <maml:para>Tells to store the update result as a variable with the specified name. The result object properties: DocumentsAffected (long), UpdatedExisting (bool).</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Skip</maml:name> <maml:description> <maml:para>Specifies the number of documents to skip from the beginning or from the end if Last is specified. Skipping is applied to results before taking First or Last. Non positive values are ignored.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <maml:description> <maml:para>Specifies sorting field names and directions. Values are either field names or hashtables with single entries @{Field = <Boolean>}. $true and $false or their equivalents are for ascending and descending sorting.</maml:para> </maml:description> </command:parameter> <command:parameter required="true" position="named" > <maml:name>Update</maml:name> <maml:description> <maml:para>Specifies an update expression and tells to update and get the first document specified by Query and SortBy (FindAndModify method).</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Int64</maml:name> </dev:type> <maml:description> <maml:para>If Count or Size is requested.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>object</maml:name> </dev:type> <maml:description> <maml:para>If the Distinct field name is specified.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>Mdbc.Dictionary or custom objects</maml:name> </dev:type> <maml:description> <maml:para>Documents, see New-MdbcData about Mdbc.Dictionary.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Connect-Mdbc</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-MdbcQuery</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Remove-MdbcData</command:name> <maml:description> <maml:para>Removes specified documents from the collection.</maml:para> </maml:description> <command:verb>Remove</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>Removes specified documents from the collection.</maml:para> <maml:para>In order to output command result objects from a server use the switch Result. Depending on operations some server exceptions are caught and written as not terminating errors, i.e. processing of remaining pipelined objects continues. Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Remove-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <command:parameterValue required="true">WriteConcern</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>One</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" pipelineInput="true (ByValue)" position="1" > <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies documents to be processed. The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> <maml:para>The parameter is mandatory and does not accept nulls. In order to specify all documents use an empty query, e.g. @{}. Note that an empty string implies @{_id=''}, not @{}.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>One</maml:name> <maml:description> <maml:para>Tells to remove one document. By default the command removes all matching documents. Note that this is different to default Update-MdbcData and the difference is kept in order to follow the driver API.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> <maml:description> <maml:para>Tells to output an object returned by the driver.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <maml:description> <maml:para>Write concern options.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>[MongoDB.Driver.IMongoQuery]</maml:name> </dev:type> <maml:description> <maml:para>Query expression. See New-MdbcQuery (query).</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>A document which _id is used for identification. Documents are created by New-MdbcData or obtained by Get-MdbcData.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[object]</maml:name> </dev:type> <maml:description> <maml:para>Other values are treated as requested _id values.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[MongoDB.Driver.WriteConcernResult]</maml:name> </dev:type> <maml:description> <maml:para>Result object from the driver is written if the switch Result is present.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Connect-Mdbc</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-MdbcQuery</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Update-MdbcData</command:name> <maml:description> <maml:para>Updates the specified documents.</maml:para> </maml:description> <command:verb>Update</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>Applies the specified update to documents matching the specified query.</maml:para> <maml:para>In order to output command result objects from a server use the switch Result. Depending on operations some server exceptions are caught and written as not terminating errors, i.e. processing of remaining pipelined objects continues. Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Update-MdbcData</maml:name> <command:parameter required="false" position="1" > <maml:name>Update</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="2" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <command:parameterValue required="true">WriteConcern</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Add</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>All</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Update</maml:name> <maml:description> <maml:para>One or more update expressions either created by New-MdbcUpdate or hashtables representing JSON-like updates. Two and more expression are combined together internally. The parameter is mandatory and does not accept nulls.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" pipelineInput="true (ByValue)" position="2" > <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies documents to be processed. The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> <maml:para>The parameter is mandatory and does not accept nulls. In order to specify all documents use an empty query, e.g. @{}. Note that an empty string implies @{_id=''}, not @{}.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Add</maml:name> <maml:description> <maml:para>Tells to add a document based on the update and query if nothing was updated.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>All</maml:name> <maml:description> <maml:para>Tells to update all matching documents. By default one is updated. Note that this is different to default Remove-MdbcData and the difference is kept in order to follow the driver API.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Result</maml:name> <maml:description> <maml:para>Tells to output an object returned by the driver.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>WriteConcern</maml:name> <maml:description> <maml:para>Write concern options.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>[MongoDB.Driver.IMongoQuery]</maml:name> </dev:type> <maml:description> <maml:para>Query expression. See New-MdbcQuery (query).</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>A document which _id is used for identification. Documents are created by New-MdbcData or obtained by Get-MdbcData.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[object]</maml:name> </dev:type> <maml:description> <maml:para>Other values are treated as requested _id values.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[MongoDB.Driver.WriteConcernResult]</maml:name> </dev:type> <maml:description> <maml:para>Result object from the driver is written if the switch Result is present.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Connect-Mdbc</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>New-MdbcUpdate</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Add-MdbcCollection</command:name> <maml:description> <maml:para>Creates a new collection in a database.</maml:para> </maml:description> <command:verb>Add</command:verb> <command:noun>MdbcCollection</command:noun> </command:details> <maml:description> <maml:para>This cmdlet is needed only for creation of collections with extra options, like capped collections. Ordinary collections do not have to be added explicitly.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Add-MdbcCollection</maml:name> <command:parameter required="true" position="1" > <maml:name>Name</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AutoIndexId</maml:name> <command:parameterValue required="true">Boolean</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Database</maml:name> <command:parameterValue required="true">MongoDatabase</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxDocuments</maml:name> <command:parameterValue required="true">Int64</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxSize</maml:name> <command:parameterValue required="true">Int64</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Name</maml:name> <maml:description> <maml:para>The name of a new collection.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AutoIndexId</maml:name> <maml:description> <maml:para>It may be set to true or false to explicitly enable or disable automatic creation of a unique key index on the _id field.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Database</maml:name> <maml:description> <maml:para>The database instance. If it is not specified then the variable Database is used: it is defined by Connect-Mdbc or assigned explicitly before the call.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxDocuments</maml:name> <maml:description> <maml:para>Sets the max number of documents in a capped collection in addition to MaxSize.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxSize</maml:name> <maml:description> <maml:para>Sets the max size of a capped collection.</maml:para> </maml:description> </command:parameter> </command:parameters> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Invoke-MdbcCommand</command:name> <maml:description> <maml:para>Invokes a command for a database.</maml:para> </maml:description> <command:verb>Invoke</command:verb> <command:noun>MdbcCommand</command:noun> </command:details> <maml:description> <maml:para>This cmdlet is normally used in order to invoke commands not covered by the driver or the module. See MongoDB manuals for available commands and their parameters.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-MdbcCommand</maml:name> <command:parameter required="true" position="1" > <maml:name>Command</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="2" > <maml:name>Value</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Database</maml:name> <command:parameterValue required="true">MongoDatabase</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Command</maml:name> <maml:description> <maml:para>Either the name of a command with no arguments or one argument or a JSON-like hashtable that defines a more complex command, for example: Invoke-MdbcCommand @{create='test'; capped=$true; size=1kb; max=5 } If the element order in a command is important then hashtables may not work. Use Mdbc.Dictionary instead: $c = New-MdbcData $c.create = 'test' $c.capped = $true $c.size = 1kb $c.max = 5 Invoke-MdbcCommand $c</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="2" > <maml:name>Value</maml:name> <maml:description> <maml:para>The argument value required by a command with one argument.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Database</maml:name> <maml:description> <maml:para>The database instance. If it is not specified then the variable Database is used: it is defined by Connect-Mdbc or assigned explicitly before the call.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Mdbc.Dictionary</maml:name> </dev:type> <maml:description> <maml:para>The response document wrapped by Mdbc.Dictionary.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Invoke the command `serverStatus` just by name. Connect-Mdbc . test Invoke-MdbcCommand serverStatus</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># Connect to the database `test` and invoke the command with a # single parameter `global` with the `admin` database specified # explicitly (because the current is `test` and the command is # admin-only) Connect-Mdbc . test Invoke-MdbcCommand getLog global -Database $Server['admin']</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title> <dev:code># The example command creates a capped collection with maximum # set to 5 documents, adds 10 documents, then gets all back (5 # documents are expected). Connect-Mdbc . test test -NewCollection $c = New-MdbcData $c.create = 'test' $c.capped = $true $c.size = 1kb $c.max = 5 $null = Invoke-MdbcCommand $c # set the default collection $Collection = $Database['test'] # add 10 documents 1..10 | .{process{ @{_id = $_} }} | Add-MdbcData # get 5 documents Get-MdbcData</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>MongoDB</maml:linkText> <maml:uri>http://www.mongodb.org</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Invoke-MdbcAggregate</command:name> <maml:description> <maml:para>Invokes aggregate operations and outputs result documents.</maml:para> </maml:description> <command:verb>Invoke</command:verb> <command:noun>MdbcAggregate</command:noun> </command:details> <maml:description> <maml:para>The driver currently provides just a raw API for aggregate operations. So does this cmdlet. When the API change the cmdlet will be redesigned.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-MdbcAggregate</maml:name> <command:parameter required="true" position="1" > <maml:name>Pipeline</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BatchSize</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxTime</maml:name> <command:parameterValue required="true">TimeSpan</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AllowDiskUse</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Pipeline</maml:name> <maml:description> <maml:para>One or more aggregation pipeline operations represented by JSON-like hashtables.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>AllowDiskUse</maml:name> <maml:description> <maml:para>Tells to allow disk use.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>BatchSize</maml:name> <maml:description> <maml:para>Specifies the size of a batch when using a cursor.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>MaxTime</maml:name> <maml:description> <maml:para>Specifies the max time the server should spend on the aggregation command.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>Result documents.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Data: current process names and memory working sets Connect-Mdbc . test test -NewCollection Get-Process | Add-MdbcData -Property Name, WorkingSet # Group by names, count, sum memory, get top 3 Invoke-MdbcAggregate @( @{ '$group' = @{ _id = '$Name' Count = @{ '$sum' = 1 } Memory = @{ '$sum' = '$WorkingSet' } }} @{ '$sort' = @{Memory = -1} } @{ '$limit' = 3 } )</dev:code> </command:example> </command:examples> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Invoke-MdbcMapReduce</command:name> <maml:description> <maml:para>Invokes a Map/Reduce command.</maml:para> </maml:description> <command:verb>Invoke</command:verb> <command:noun>MdbcMapReduce</command:noun> </command:details> <maml:description> <maml:para>Invokes a Map/Reduce command.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Invoke-MdbcMapReduce</maml:name> <command:parameter required="true" position="1" > <maml:name>Function</maml:name> <command:parameterValue required="true">String[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="2" > <maml:name>Query</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>First</maml:name> <command:parameterValue required="true">Int32</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutCollection</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutDatabase</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutMode</maml:name> <command:parameterValue required="true">MapReduceOutputMode</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ResultVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Scope</maml:name> <command:parameterValue required="true">IDictionary</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>JSMode</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Function</maml:name> <maml:description> <maml:para>Two (Map and Reduce) or three (Map, Reduce, Finalize) JavaScript snippets which define the functions. Use Scope in order to set variables that can be used in the functions.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="2" > <maml:name>Query</maml:name> <maml:description> <maml:para>Specifies documents to be processed. The following types are used as or converted to queries: IMongoQuery (created by New-MdbcQuery), Mdbc.Dictionary, BsonDocument, JSON-like hashtables. Other values are treated as _id and converted to _id queries.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <maml:description> <maml:para>Specifies the representation of output documents. The argument is either a required type or a shortcut enum value for special types. A type specifies the output type literally. Type properties must match the document fields or the custom type serialization must be registered. Shortcuts, either enum values or strings: Default Default output, Mdbc.Dictionary with underlying BsonDocument. Lazy Mdbc.LazyDictionary with underlying LazyBsonDocument. Call Dispose() after use. Raw Mdbc.RawDictionary with underlying RawBsonDocument. Read only. Call Dispose() after use. PS PowerShell custom object. By default result documents are represented by Mdbc.Dictionary with underlying BsonDocument. See New-MdbcData for details. Use of its Lazy or Raw form may improve performance in some cases. In some scenarios other output types may be suitable like native .NET types (-As ([Type])) and PowerShell custom objects (-As PS). On choosing an output type keep in mind that Mdbc.Dictionary (BsonDocument) field names are case sensitive unlike object properties in PowerShell.</maml:para> <maml:para>This parameter is used with inline output.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object. It is obtained by Connect-Mdbc, Open-MdbcFile, or using the driver methods, for example from a database instance. If it is not specified then the variable Collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>First</maml:name> <maml:description> <maml:para>The maximum number of input documents. It is used together with Query and normally with SortBy.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>JSMode</maml:name> <maml:description> <maml:para>Tells to use JS mode which avoids some conversions BSON <-> JS. The execution time may be significantly reduced. Note that this mode is limited by JS heap size and a maximum of 500k unique keys.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutCollection</maml:name> <maml:description> <maml:para>Name of the output collection. If it is omitted then inline output mode is used, result documents are written to the output directly.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutDatabase</maml:name> <maml:description> <maml:para>Name of the output database, used together with Collection. By default the database of the input collection is used.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>OutMode</maml:name> <maml:description> <maml:para>Specifies the output mode, used together with Collection. The default value is Replace (all the existing data are replaced with new). Other valid values are Merge and Reduce. Merge: new data are either added or replace existing data with the same keys. Reduce: the Reduce function is applied.</maml:para> <maml:para>Values : Inline, Replace, Merge, Reduce</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>ResultVariable</maml:name> <maml:description> <maml:para>Tells to get the result object as a variable with the specified name. The result object type is MapReduceResult. Some properties: Ok, ErrorMessage, InputCount, EmitCount, OutputCount, Duration.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Scope</maml:name> <maml:description> <maml:para>Specifies the variables that can be used by Map, Reduce, and Finalize functions.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>SortBy</maml:name> <maml:description> <maml:para>Specifies sorting field names and directions. Values are either field names or hashtables with single entries @{Field = <Boolean>}. $true and $false or their equivalents are for ascending and descending sorting.</maml:para> <maml:para>This parameter is used together with Query.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Mdbc.Dictionary or custom objects</maml:name> </dev:type> <maml:description> <maml:para>Result documents of Map/Reduce on inline output.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>MongoDB</maml:linkText> <maml:uri>http://www.mongodb.org</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Export-MdbcData</command:name> <maml:description> <maml:para>Exports objects to a BSON file.</maml:para> </maml:description> <command:verb>Export</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>The cmdlet writes BSON representation of input objects to the specified file. The output file has the same format as .bson files produced by mongodump.exe. Cmdlets Export-MdbcData and Import-MdbcData do not need any database connection or even MongoDB installed. They are used for file based object persistence on their own. Files created by Export-MdbcData may be opened as collections by Open-MdbcFile with some caveats. Documents should not contain invalid names *.* and $*. If documents do not have unique _id's then the switch Simple should be used.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Export-MdbcData</maml:name> <command:parameter required="true" position="1" > <maml:name>Path</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="2" > <maml:name>InputObject</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <command:parameterValue required="true">ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <command:parameterValue required="true">FileFormat</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <command:parameterValue required="true">Object[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Retry</maml:name> <command:parameterValue required="true">TimeSpan[]</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Append</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path to the file where BSON representation of objects will be stored.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" pipelineInput="true (ByValue)" position="2" > <maml:name>InputObject</maml:name> <maml:description> <maml:para>Document or a similar object, see INPUTS.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Append</maml:name> <maml:description> <maml:para>Tells to append data to the file if it exists.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Convert</maml:name> <maml:description> <maml:para>A script called on exceptions during conversion of unknown data to BsonValue. The variable $_ is the problem object to be converted. The script returns a single value to be tried instead or nothing for nulls. Examples: {} converts unknown data to nulls. {"$_"} converts data to strings, it is useful for preserving as much information as possible on dumping objects for later analysis. Converters should be used sparingly, normally with unknown or varying data. Consider to use Property for selecting standard and converting not standard known data.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <maml:description> <maml:para>Specifies the data file format: Bson BSON format Json JSON format Auto (default) The format is defined by the file extension: ".json" is for JSON, other extensions are for BSON. Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines.</maml:para> <maml:para>Values : Auto, Bson, Json</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Id</maml:name> <maml:description> <maml:para>The document _id value to be assigned or a script block returning this value for the input object represented by the variable $_. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewId</maml:name> <maml:description> <maml:para>Tells to generate and assign a new document _id as MongoDB.Bson.ObjectId. _id must not exist in input objects or be specified again by Property.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Property</maml:name> <maml:description> <maml:para>Specifies properties or keys which values are to be included into documents or defines calculated fields. Missing input properties and keys are ignored. Arguments are defined in three ways: 1. Strings define property or key names and the corresponding result document field names. 2. Hashtables @{Key=Value} define renamed and calculated fields. The key is a new document field name. The value is either a string (input object property name) or a script block (field value calculated from the input object $_). 3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but use the same convention as the parameter Property of Select-Object. See New-MdbcData examples.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Retry</maml:name> <maml:description> <maml:para>Tells to retry on failures to open the file and specifies one or two arguments. The first is the retry timeout. The second is the retry interval, the default is 50 milliseconds.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <maml:name>$null</maml:name> </dev:type> <maml:description> <maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets. The native driver document [MongoDB.Bson.BsonDocument] can be used as well but normally it should not be used directly. Its wrapper [Mdbc.Dictionary] is more suitable in PowerShell.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[IDictionary]</maml:name> </dev:type> <maml:description> <maml:para>Dictionaries are converted to new documents. Keys are strings used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> <command:inputType> <dev:type> <maml:name>[PSObject]</maml:name> </dev:type> <maml:description> <maml:para>Objects are converted to new documents. Property names are used as new field names. Collection, dictionary, and custom object values are converted to BSON container types recursively. Other values are converted to BsonValue.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code>@{ p1 = 'Name1'; p2 = 42 }, @{ p1 = 'Name2'; p2 = 3.14 } | Export-MdbcData test.bson Import-MdbcData test.bson -As PS</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># "Safe" logging by several writers $data | Export-MdbcData $file -Append -Retry ([TimeSpan]::FromSeconds(10))</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Import-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Open-MdbcFile</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Save-MdbcFile</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Import-MdbcData</command:name> <maml:description> <maml:para>Imports data from a file.</maml:para> </maml:description> <command:verb>Import</command:verb> <command:noun>MdbcData</command:noun> </command:details> <maml:description> <maml:para>The cmdlet reads data from a BSON file. Such files are produced, for example, by the cmdlet Export-MdbcData or by the utility mongodump.exe. Cmdlets Export-MdbcData and Import-MdbcData do not need any database connection or even MongoDB installed. They are used for file based object persistence on their own.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Import-MdbcData</maml:name> <command:parameter required="true" position="1" > <maml:name>Path</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <command:parameterValue required="true">PSObject</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <command:parameterValue required="true">FileFormat</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="true" position="1" > <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the path to the BSON file where objects will be restored from.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>As</maml:name> <maml:description> <maml:para>Specifies the representation of output documents. The argument is either a required type or a shortcut enum value for special types. A type specifies the output type literally. Type properties must match the document fields or the custom type serialization must be registered. Shortcuts, either enum values or strings: Default Default output, Mdbc.Dictionary with underlying BsonDocument. Lazy Mdbc.LazyDictionary with underlying LazyBsonDocument. Call Dispose() after use. Raw Mdbc.RawDictionary with underlying RawBsonDocument. Read only. Call Dispose() after use. PS PowerShell custom object. By default result documents are represented by Mdbc.Dictionary with underlying BsonDocument. See New-MdbcData for details. Use of its Lazy or Raw form may improve performance in some cases. In some scenarios other output types may be suitable like native .NET types (-As ([Type])) and PowerShell custom objects (-As PS). On choosing an output type keep in mind that Mdbc.Dictionary (BsonDocument) field names are case sensitive unlike object properties in PowerShell.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <maml:description> <maml:para>Specifies the data file format: Bson BSON format Json JSON format Auto (default) The format is defined by the file extension: ".json" is for JSON, other extensions are for BSON. Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines.</maml:para> <maml:para>Values : Auto, Bson, Json</maml:para> </maml:description> </command:parameter> </command:parameters> <command:returnValues> <command:returnValue> <dev:type> <maml:name>[Mdbc.Dictionary]</maml:name> </dev:type> <maml:description> <maml:para>Default, Lazy, or Raw form depending on the parameter As.</maml:para> </maml:description> </command:returnValue> <command:returnValue> <dev:type> <maml:name>[object]</maml:name> </dev:type> <maml:description> <maml:para>Custom objects specified by the parameter As.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code>@{ p1 = 'Name1'; p2 = 42 }, @{ p1 = 'Name2'; p2 = 3.14 } | Export-MdbcData test.bson Import-MdbcData test.bson -As PS</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># Import data produced by ConvertTo-Json (PowerShell V3) Get-Process | ConvertTo-Json | Set-Content process.json Import-MdbcData process.json</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Export-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Open-MdbcFile</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Save-MdbcFile</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Open-MdbcFile</command:name> <maml:description> <maml:para>Opens a bson file as a collection.</maml:para> </maml:description> <command:verb>Open</command:verb> <command:noun>MdbcFile</command:noun> </command:details> <maml:description> <maml:para>This cmdlet opens a bson file as a collection for operations Get-MdbcData, Add-MdbcData, Remove-MdbcData, and Update-MdbcData. Save-MdbcFile is used in order to save data to the source file or another file. Such scenarios do not require MongoDB running or even installed. NORMAL AND SIMPLE DATA In the normal mode which is the default documents in a file must have unique _id's. If new documents have no _id's then they are generated on insertions. The simple mode is specified by the switch Simple. Presence and uniqueness of document _id's is not maintained. Operations like Add-MdbcData -Update are not supported. INVALID ELEMENT NAMES Document element names like *.* and $* are invalid in collections because query and update expressions use the dot notation for nested items and special names $* for operators. Nevertheless Open-MdbcFile does not perform name checks on reading assuming that the file was created and maintained only by cmdlets listed above and it contains valid names. Remember that files created in a different way, for example by Export-MdbcData, may contain problematic names for using them as collections with Open-MdbcFile.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Open-MdbcFile</maml:name> <command:parameter required="false" position="1" > <maml:name>Path</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CollectionVariable</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <command:parameterValue required="true">FileFormat</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewCollection</maml:name> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Simple</maml:name> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the bson file path. If the file does not exists then the collection is empty and the file is not created until it is saved. If the path is omitted or empty then the collection is empty and Save-MdbcFile will require a path.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>CollectionVariable</maml:name> <maml:description> <maml:para>Name of a new variable in the current scope with the connected collection. The default variable name is Collection. The default variable is used implicitly by cmdlets operating on collection data.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <maml:description> <maml:para>Specifies the data file format: Bson BSON format Json JSON format Auto (default) The format is defined by the file extension: ".json" is for JSON, other extensions are for BSON. Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines.</maml:para> <maml:para>Values : Auto, Bson, Json</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>NewCollection</maml:name> <maml:description> <maml:para>Tells to open an empty collection. If the source file path is specified then it is simply stored for saving, the source file is not touched at this moment.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Simple</maml:name> <maml:description> <maml:para>Tells to operate on simple data, i.e. do not maintain presence and uniqueness of document _id's. Some operations like Add-MdbcData -Update are not supported.</maml:para> </maml:description> </command:parameter> </command:parameters> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Open existing or new bson file collection Open-MdbcFile data.bson # Use Get-MdbcData, Add-MdbcData, Remove-MdbcData, Update-MdbcData # ... # Save data Save-MdbcFile</dev:code> </command:example> <command:example> <maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title> <dev:code># Open and query data produced by ConvertTo-Json (PowerShell V3) Get-Process | ConvertTo-Json -Depth 1 | Set-Content process.json Open-MdbcFile process.json -Simple Get-MdbcData @{Name='mongod'}</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Save-MdbcFile</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Add-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-MdbcData</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name>Save-MdbcFile</command:name> <maml:description> <maml:para>Saves data to a bson file.</maml:para> </maml:description> <command:verb>Save</command:verb> <command:noun>MdbcFile</command:noun> </command:details> <maml:description> <maml:para>This cmdlet saves the collection data to the specified or the original file.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Save-MdbcFile</maml:name> <command:parameter required="false" position="1" > <maml:name>Path</maml:name> <command:parameterValue required="true">String</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <command:parameterValue required="true">Object</command:parameterValue> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <command:parameterValue required="true">FileFormat</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" position="1" > <maml:name>Path</maml:name> <maml:description> <maml:para>Specifies the bson file path for saving data. If it is omitted or empty then the path used on opening is assumed. If it was not provided as well then an error is thrown.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>Collection</maml:name> <maml:description> <maml:para>Collection object created by Open-MdbcFile. If it is omitted then the variable Collection is used which is assumed to be created by Open-MdbcFile by default. It is not an error to call this cmdlet for a native driver collection. Such a call is simply ignored.</maml:para> </maml:description> </command:parameter> <command:parameter required="false" position="named" > <maml:name>FileFormat</maml:name> <maml:description> <maml:para>Specifies the data file format: Bson BSON format Json JSON format Auto (default) The format is defined by the file extension: ".json" is for JSON, other extensions are for BSON. Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines.</maml:para> <maml:para>This parameter is ignored if the path is omitted or empty.</maml:para> <maml:para>Values : Auto, Bson, Json</maml:para> </maml:description> </command:parameter> </command:parameters> <command:examples> <command:example> <maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title> <dev:code># Open existing or new bson file collection Open-MdbcFile data.bson # Use Get-MdbcData, Add-MdbcData, Remove-MdbcData, Update-MdbcData # ... # Save data Save-MdbcFile</dev:code> </command:example> </command:examples> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Open-MdbcFile</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Add-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Remove-MdbcData</maml:linkText> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Update-MdbcData</maml:linkText> </maml:navigationLink> </maml:relatedLinks> </command:command> </helpItems> |