-
Notifications
You must be signed in to change notification settings - Fork 10
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
Would be nice to have session.fetch(...).asPromise() #7
Comments
Yeah, that should be OK. I'll work it into the next release. |
Sorry, I was too quick to respond. Because of the way operations on the session are queued up this is actually a bigger change than I thought. I'm going to have to think about this one. I'll leave the issue open. In the meantime, you can chain
|
Thanks for the prompt responses. The issue I am facing is getting a hold of the I can't use |
The call to |
Would it then be desirable to have an |
Yeah, whatever I do for |
That sounds great! Thanks. |
There is a problem with returning a Promise when the callback is not provided. Some background: Currently, the callback is already optional on some operations. This is because all operations on the Session are queued. The queue is then processed based on the type of operation. For example multiple If a callback is not passed to an operation, and an error occurs, the error is passed to the next call on the Session with a callback. If none are queued then the error is raised as an event on the Session. In order to return a promise when a callback is not provided, a Promise-wrapped callback would have to be passed to the queue. This would break the current error handling. I'll continue to look into this. |
Maybe a solution would be to update the tracked references after flush is called? I don't know how exactly the tracking is implemented in this library, but coming from a C# background, I have noticed that Entity Framework (ORM for .NET) injects the database-generated fields into the tracked model upon calling I think an elegant solution would be to keep the current implementation that you have, and implement something similar to what Entity Framework does. Example for clarity:
What do you think? |
That's pretty much how it works now. The issue is each of those steps is async and the current way the Session handles errors doesn't exactly mesh with returning Promises, but I have a few ideas. I'll update this thread when I have more. |
Sorry to press you, I'm very keen to be able to use this functionality - have you had any further progress with it? 😄 |
Doing this will require a breaking change to the API. I haven't put it in place yet. |
No problem - thank you for the quick reply, I look forward to the update :) |
Hey there, I've been using this library for a bit now and I love the way every query can be promisified so I can use
await
on them. However, thefetch
function onSession
does not have anasPromise
function. I would like to have something like the following:Is it possible to do something like this?
Thanks!
The text was updated successfully, but these errors were encountered: