Efficient way to look up an item by Id?
See original GitHub issueIs your feature request related to a problem? Please describe. I’d like to look up an item as efficiently as possible when only the Id of the item is available.
I had assumed that the ReadItemAsync
method would support this, but it appears to require a PartitionKey
. To be clear, a key is defined in the collection, I just don’t know it at certain times.
Describe the solution you’d like
An efficient way of querying a document by Id when the PartitiondKey
is unknown
Describe alternatives you’ve considered The best idea I have:
var feedIterator = _container.GetItemQueryIterator<TDataType>($"SELECT TOP 1 * FROM c WHERE c.id = '{documentId}'");
if (feedIterator.HasMoreResults)
{
var document = await feedIterator.ReadNextAsync();
return document.FirstOrDefault();
}
Additional context I just feel as though there must be a better way!
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
javascript - Faster way to select an element with a given id
The fastest way is: document.getElementById("foo");. Setting this to a variable for reuse will prevent the need to find it over and over ...
Read more >Document: getElementById() method - Web APIs | MDN
The getElementById() method of the Document interface returns an Element object representing the element whose id property matches the ...
Read more >Searching: getElement*, querySelector*
The method getElementById can be called only on document object. It looks for the given id in the whole document. querySelectorAll. By far,...
Read more >Best Practices for finding Items by Item ID
Hey guys, how do you quickly find podio items from the Podio Item ID without always going through single items? (I do not...
Read more >REST - how to get item ID and document name while ...
I am trying to query a document library via REST and get the item ID and the document name. The query needs to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Your code is not draining the query and dealing with empty pages.
Closing due to in-activity, pease feel free to re-open.