< Back

Get-MdbcData

Sat Jan 18, 2020 11:32 am

NAME Get-MdbcData



SYNOPSIS

Gets data from database collections.





SYNTAX

Get-MdbcData [[-Filter] <Object>] [-As <Object>] [-Collection <IMongoCollection`1>] [-First <Int64>] [-Last

<Int64>] [-Project <Object>] [-Session <IClientSessionHandle>] [-Skip <Int64>] [-Sort <Object>]

[<CommonParameters>]



Get-MdbcData [[-Filter] <Object>] -Distinct <String> [-Collection <IMongoCollection`1>] [-Session

<IClientSessionHandle>] [<CommonParameters>]



Get-MdbcData [[-Filter] <Object>] -Count [-Collection <IMongoCollection`1>] [-First <Int64>] [-Session

<IClientSessionHandle>] [-Skip <Int64>] [<CommonParameters>]



Get-MdbcData [[-Filter] <Object>] -Remove [-As <Object>] [-Collection <IMongoCollection`1>] [-Project <Object>]

[-Session <IClientSessionHandle>] [-Sort <Object>] [<CommonParameters>]



Get-MdbcData [[-Filter] <Object>] -Set <Object> [-As <Object>] [-Collection <IMongoCollection`1>] [-Project

<Object>] [-Session <IClientSessionHandle>] [-Sort <Object>] [-Add] [-New] [<CommonParameters>]



Get-MdbcData [[-Filter] <Object>] -Update <Object> [-As <Object>] [-Collection <IMongoCollection`1>] [-Project

<Object>] [-Session <IClientSessionHandle>] [-Sort <Object>] [-Add] [-New] [<CommonParameters>]





DESCRIPTION

This cmdlet queries the specified or default collection.





PARAMETERS

-Filter

Specifies the document(s) to be processed. The argument is either JSON or similar dictionary.



Required? false

Position? 0

Default value

Accept pipeline input?

Accept wildcard characters?



-Add

Tells to add new documents on Replace and Update if old documents do not exist.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-As

Specifies the type of output objects. The argument is either the type or full name or a special alias.



Key based types:

- [Mdbc.Dictionary] (alias "Default"), wrapper of BsonDocument

- [Hashtable] or other dictionaries, PowerShell native

- [Object], same as [System.Dynamic.ExpandoObject]

- [MongoDB.Bson.BsonDocument], driver native



Property based types:

- [PSObject] (alias "PS"), same as [PSCustomObject]

- Classes defined in PowerShell or .NET assemblies



Key based types and PSObject are schema free, they accept any result fields. Classes should match the result

fields, literally or according to the custom serialization.



Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all

property based types in PowerShell.



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?



-Count

Tells to return the number of documents matching the Filter. Note that the optional First and Skip are taken

into account. For example `-Count -First 1` may be used as effective "exists".



Required? true

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Distinct

Specifies the field name and tells to return its distinct values from documents matching the Filter.



Required? true

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-First

Specifies the number of first documents to be returned. Non positive values are ignored.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Last

Specifies the number of last documents to be returned. Non positive values are ignored.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-New

Tells to return new documents on Replace and Update. By default old documents are returned if they exist.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Project

Specifies the projection expression, i.e. fields to be retrieved. The field _id is always included unless it

is explicitly excluded.



The special value `*` used together with `-As <type>` tells to infer projected fields from the type.



Otherwise, the argument is either JSON or similar dictionary.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Remove

Tells to remove and get the first document specified by Filter and Sort.



Required? true

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?



-Set

Specifies the document which replaces the first document specified by Filter and Sort. The returned document

depends on New and Project.



Required? true

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Skip

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.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Sort

Specifies the sorting expression, field names and directions. The argument is either JSON or similar

dictionary.



If two or more fields are specified then mind the order. Use JSON or ordered dictionaries, e.g.

`[ordered]@{..}`.



Required? false

Position? named

Default value

Accept pipeline input?

Accept wildcard characters?



-Update

Specifies the update expression. The argument is JSON, similar dictionary, or array for aggregate expressions.



This parameter tells to update the first document specified by Filter and Sort. The returned document depends

on New and Project.



Required? true

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

[Int64]

Number of documents, if Count is requested.



[object]

Field values, if Distinct is specified.



[Mdbc.Dictionary] or other types depending on As.

Documents, see New-MdbcData about Mdbc.Dictionary.







RELATED LINKS

Connect-Mdbc