Open sdg002 opened 4 years ago
$query="select c.id, c.FirstName,c.LastName from docs c"
$results=Get-CosmosDbDocument -context $cosmosDbContext -CollectionId $collnParticipants -Query $query -QueryEnableCrossPartition $true -Verbose
$documents = $results | Foreach-Object {
# Finds filter to filters out internal powershell-specific PSObject fields
$docProperties = $_ | Get-Member -MemberType NoteProperty | ForEach-Object { $_.Name }
# Applies filter, converts to json, then back to PSObject without unnecessary properties
$doc = $_ | Select-Object -Property $docProperties | ConvertTo-Json | ConvertFrom-Json
}
$documents[0]
It took me a while to discover this. https://github.com/PlagueHO/CosmosDB/issues/382
Hi @sdg002 - the Get-CosmosDbDocument
function will return an array if more than one document is returned. In your case it does look like it could return more than one document. Can you confirm if this is the case?
Issue
What works?
This query will give me all the fields in my document.
What does not work as expected?
I would like to do selective querying.
I cannot see the FistName and LastName fields in the
$results
object. However, when I do$results[0].FirstName
, I can see the value of theFirstName
field .Any ideas why this could be happening?
Thank you so much. Sau
Before submitting your issue for the CosmosDB project, please take a moment to provide the following details:
Get-Module -Name CosmosDB
)Thanks for contributing your feedback and support! You can optionally submit a Pull Request against this project, if you have a fix you'd like to share.