yessql
yessql copied to clipboard
How to get document (in separate transaction) after QueryIndex
I have an index, and I want a background job to go through each document one by one and process each in a separate transaction. Thus, Query is not useful since it would not use the transaction I want, but I can't quite see how to get DocumentId from the QueryIndex result, either. I'm trying to do something like
var query = await session.QueryIndex<JobIndex>(x => x.Pending).ListAsync();
foreach (var index in query) {
await session.BeginTransactionAsync();
var job = session.GetAsync<Job>(index.DocumentId);
// do stuff
await session.CommitAsync();
}
Is this possible? The "Id" field in the MapIndex class seems to be unrelated to the document ID.