Closed marcolong closed 4 years ago
As stated in the Breaking Changes:
Query function names have been capitalized (Select, Where, OrderBy, Limit, Offset, Range).
This change was to avoid conflicts with Firestore Typing documentation.
Sorry, I pasted the old code, but It doesn't also work with the new one:
const firestore = FirestoreApp.getFirestore(email, key, projectId);
firestore.query('carts').OrderBy('lastUpdate', 'desc').Limit(10000).Execute();
const firestore = FirestoreApp.getFirestore(email, key, projectId); firestore.query('carts').OrderBy('lastUpdate', 'desc').Limit(10000).Execute();
I tested this in Unit Tests, and it works fine with:
const path = 'Test Collection';
const test = this.db.query(path).OrderBy('boolean value', 'desc').Limit(10000).Execute();
Returns 3 objects as expected, and .obj
targets each of them to reveal the full object.
Are you sure your data is correct? You will get 0 results back if you don't have a collection named "carts" or if there are no documents in that collection with the field name "lastUpdate".
With a standard object it works fine also for me. I have a result that contains an object with a nested array of maps and it crashes. Try to complicate your object in your test, with a field array of maps or something similar.
Try to complicate your object in your test, with a field array of maps or something similar.
@marcolong, Can you provide an example data set? The REST API can't perform OrderBy
on a non-comparable field type (Array, Map, Geopoint, Reference).
You can OrderBy
a nested field (if it exists). I created the following document:
{
"map (nested object)": { "foo": 123 }
}
And I was able to retreive it using this.db.query(path).OrderBy('map (nested object).foo', 'desc').Limit(10000).Execute();
@marcolong I see the issue. I misunderstood the problem. I got thrown off because you were using the .query
functionality. But it was all about unwrapping a nested object. I'll work on this.
It appears with the new version, 30 (I guess starting from 27). It depends on the doc returned, if it contains array of maps or other particular nested structure, it crashes. With a "standard" doc, so without nested object, it works. Works fine until version 26.
Minimal code to reproduce the problem
Expected Behavior
documents[0].obj; // This returns raw object.
Actual Results
Library Version:
30