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
empty result instead of timeout #31
Comments
@ro70 Agreed. @mihaidma @mirceaalexandru @geek Thoughts on this? |
I think that we should return error because we should signal that there is setup issue, not just that there is not a matching entity in DB. We should also check what is the behavior of the drivers we are using for each DB engine, as one can return error, others can return {}, so might not have a consistent API across our stores. This problem do not exist for MongoDb as it will just create the collection if necessary, but for Postgres/Mysql there is another case, there should be created manually - but I don't know the response from their drivers for this scenario. |
@ro70 I understood that this problem appear when the table do not exists yes? |
The spec for this case is this: https://github.com/senecajs/seneca-store-test/blob/master/store-test.js#L111 @mirceaalexandru let's open a discussion about returned value for list and load when nothing matches. |
@mirceaalexandru , @mihaidma The table does exist. Imagine the following use case: There's a table 'PlayersPoints' with the fields 'id', 'player_id' and 'points'. As long as a player has zero points, there's no entity with its player_id. If I'd like to know how many points a specific player has, I do playerEntity.load$({player_id: id}...). The resulting set may be empty (or null if you want). It even is alright to throw a (nothing found) error in this case, but waiting for a timeout is not the best solution in my opinion. |
@ro70 , sorry I understood that table do not exists, my comment was for that scenario. In this case the result should be null in my opinion, and timeout is a bug that needs to be fixed. |
A load$ query to a non-existing entity ends up in a timeout. It should better return an empty object {}, shouldn't it?
The text was updated successfully, but these errors were encountered: