Closed acerov closed 8 years ago
I don't think query()
accepts a filter
.
Try this:
self.get('store').query('localDocumentDetail', { documentId: localDocument.get("id") }).then(function(localDocumentDetails) {
console.log("Document details bellow:");
console.log(localDocumentDetails);
localDocumentDetails.forEach(function(localDocumentDetail){
console.log(localDocumentDetail);
});
}
Tried:
self.get('store').query('localDocumentDetail', { documentId: localDocument.get("id") }).then(function(localDocumentDetails) {
console.log("Document details bellow:");
console.log(localDocumentDetails);
localDocumentDetails.forEach(function(localDocumentDetail){
console.log(localDocumentDetail);
});
}, function(reason) {
console.log("localDocumentDetail query failed");
console.log(reason);
});
strange but now it does not hit
console.log("Document details bellow:");
nor
console.log("localDocumentDetail query failed");
before it was hiting
console.log("Document details bellow:");
if I comment this lines:
//if (results.get('length')) {
// results = this.loadRelationshipsForMany(store, type, results);
//}
in addon/adapters/localforage.js it works. I did not analyze much loadRelationshipsForMany function but I saw that in version 2.0.0 these lines does not exist.
There is a blocking promise in loadRelationships()
which leave the query()
promise pending when non embedded relationships can't be satisfied, instead of rejecting it (or resolving it without the missing records).
I'll push a PR as soon as the branch 1.13 will be created by @frederikbosch.
In the meantime, you should check your data, you probably have at least one unsatisfied relationship in the localDocumentDetail
you request (i.e. with an id pointing to nowhere).
@sebweaver The branch is there, feel free to create the PR. What are you planning? Issue a warning message in console? Throw an exception? I do not know the behaviour of other adapter when referencing non-existing relationships.
@sebweaver Yes, unsatisfied relationship happens when I am offline and I don't have access to data on rest server, because offline data references online data, probably I should cache referenced data locally.
@frederikbosch What is good behaviour for adapter in these situation, probably warning because findAll returns all records and query without filter none, they should behave the same I think.
@acerov I understand the behaviour now. So rather than a non-existing relationships, this problem is related to a non-fetched relationship.
If we act on this, there are two scenarios possible. First the completely offline scenario: in this case there is erroneous data. In the second case the data within localforage is incomplete. Maybe both scenarios require different solutions.
@frederikbosch I think it is ok to return records (with warnings) regardless of non-fetched relationships because these records actually exist (in IndexedDB in my case), findAll behaves this way.
What was confusing to me, previous than finding out what is going on, is that findAll returned records and query (with filter that I know have a match) did not.
Alright, we will wait for @sebweaver with a PR. Nice to hear that things are already sorted out for you.
@sebweaver @frederikbosch thank you both for help :+1: , waiting @sebweaver for a PR
It's in progress and will be released ASAP. :sweat_smile:
Done!
Tagged and published!
Hi,
this is my environment: ember-data 1.13.13, ember-localforage-adapter 1.13.1 I am unable to query records, it returns empty array, my code is bellow:
Thanks