< Back
Set-MdbcData
Post
NAME Set-MdbcData
SYNOPSIS
Replaces documents in collections.
SYNTAX
Set-MdbcData [[-Filter] <Object>] [[-Set] <Object>] [-Collection <IMongoCollection`1>] [-Options <ReplaceOptions>]
[-Session <IClientSessionHandle>] [-Add] [-Result] [<CommonParameters>]
DESCRIPTION
This cmdlet replaces old documents with new documents.
With pipeline input, old documents are found by input document _id's and replaced with input documents, without
using parameters Filter and Set:
... | Set-MdbcData
Otherwise, one old document is specified by Filter and the new document by Set:
Set-MdbcData [-Filter] <filter> [-Set] <new-document>
In order to output the result info use the switch Result.
Depending on operations and settings some server exceptions are caught and written as not terminating errors, i.e.
processing continues.
Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help
about_CommonParameters and about_Preference_Variables.
PARAMETERS
-Filter
Specifies the documents to be replaced. The argument is either JSON or similar dictionary. The parameter is
mandatory unless documents with _id come from the pipeline. It does not accept nulls.
Required? false
Position? 0
Default value
Accept pipeline input?
Accept wildcard characters?
-Set
Specifies the new document which replaces the old matching Filter. The parameter is not used if the documents
come from the pipeline.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters?
-Add
Tells to add the new document if the old does not exist.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Collection
Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc,
Get-MdbcCollection, or using the driver API.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Options
Extra options, see MongoDB.Driver.ReplaceOptions
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Result
Tells to output the operation result info.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Session
Specifies the client session which invokes the command.
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction
session created by Use-MdbcTransaction.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
[MongoDB.Driver.ReplaceOneResult]
Returned if Result is specified. Useful members: MatchedCount, ModifiedCount, UpsertedId.
RELATED LINKS
Connect-Mdbc
Update-MdbcData
SYNOPSIS
Replaces documents in collections.
SYNTAX
Set-MdbcData [[-Filter] <Object>] [[-Set] <Object>] [-Collection <IMongoCollection`1>] [-Options <ReplaceOptions>]
[-Session <IClientSessionHandle>] [-Add] [-Result] [<CommonParameters>]
DESCRIPTION
This cmdlet replaces old documents with new documents.
With pipeline input, old documents are found by input document _id's and replaced with input documents, without
using parameters Filter and Set:
... | Set-MdbcData
Otherwise, one old document is specified by Filter and the new document by Set:
Set-MdbcData [-Filter] <filter> [-Set] <new-document>
In order to output the result info use the switch Result.
Depending on operations and settings some server exceptions are caught and written as not terminating errors, i.e.
processing continues.
Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help
about_CommonParameters and about_Preference_Variables.
PARAMETERS
-Filter
Specifies the documents to be replaced. The argument is either JSON or similar dictionary. The parameter is
mandatory unless documents with _id come from the pipeline. It does not accept nulls.
Required? false
Position? 0
Default value
Accept pipeline input?
Accept wildcard characters?
-Set
Specifies the new document which replaces the old matching Filter. The parameter is not used if the documents
come from the pipeline.
Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters?
-Add
Tells to add the new document if the old does not exist.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Collection
Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc,
Get-MdbcCollection, or using the driver API.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Options
Extra options, see MongoDB.Driver.ReplaceOptions
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Result
Tells to output the operation result info.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
-Session
Specifies the client session which invokes the command.
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction
session created by Use-MdbcTransaction.
Required? false
Position? named
Default value
Accept pipeline input?
Accept wildcard characters?
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
[MongoDB.Driver.ReplaceOneResult]
Returned if Result is specified. Useful members: MatchedCount, ModifiedCount, UpsertedId.
RELATED LINKS
Connect-Mdbc
Update-MdbcData