-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query Async #40
Comments
Hi, There is no async support for querying. AsQueryable and Find-methods may be slow as those convert collection of JObjects to correct classes, but after conversion is done all objects are in the memory so querying is fast. Data is in Lazy-object: AsQueryable and Find-methods use data in Lazy-obejct: We can implement async versions for Find-methods and for AsQueryable if you think those would be useful? |
For concurrency it would be preferable -- that lock could be async which would help with thread resources. But I don't personally need it for my usage at this time. Was just curious if I missing something :) Again, thanks for this useful library! |
Thanks for the feedback! Have to think how async query-operations would be best to implement. Will write more specifications here when I come up with something. |
Maybe this should be implemented with async streams? Syntax might be a little nicer than with Task<IEnumerable>. Internally both would function in a same way, as first whole JObject would be converted to correct classes. So in the end this is only about syntax. IDocumentCollection.cs: Task<IEnumerable<T>> AsQueryableAsync();
Task<IEnumerable<T>> FindAsync(Predicate<T> query); var itemDynamic = (await store.GetCollection("user")
.AsQueryableAsync())
.Single(p => p.name == "Phil");
var itemDynamic2 = (await store.GetCollection("user")
.FindAsync(p => p.name == "Phil"))
.First();
foreach(var item in await store.GetCollection("user").AsQueryableAsync())
{
// TODO
} This seems much better option IDocumentCollection.cs: IAsyncEnumerable<T> AsQueryableAsync();
IAsyncEnumerable<T> FindAsync(Predicate<T> query); var itemDynamic = await store.GetCollection("user")
.AsQueryableAsync()
.Single(p => p.name == "Phil");
await foreach(var item in store.GetCollection("user").AsQueryableAsync())
{
// TODO
} |
First of all, thanks for this library.
Quick question: is there support for async querying?
The text was updated successfully, but these errors were encountered: