PROFESSIONAL-CLOUD-DEVELOPER · Question #83
Your teammate has asked you to review the code below. Its purpose is to query account entities in Cloud Datastore for those with a balance greater than 10000 and an age less than 4. Which…
The correct answer is D. Send two queries-one for balances over 10000, and another for ages less than 4-and compute. A is not correct because the stated goal doesn't require an ancestor query. B is not correct because no data is being written, so a transaction isn't necessary. C is not correct because it wouldn't affect the results. D is correct because two inequality comparisons aren't…
Question
Your teammate has asked you to review the code below. Its purpose is to query account entities in Cloud Datastore for those with a balance greater than 10000 and an age less than 4. Which improvement should you suggest your teammate make? Captionless Image
Options
- AThe query needs to have an ancestor query.
- BThe query should be performed in a transaction.
- CChange the argument to OrderBy.desc to be "balance" instead of "age."
- DSend two queries-one for balances over 10000, and another for ages less than 4-and compute
How the community answered
(42 responses)- A14% (6)
- B2% (1)
- C7% (3)
- D76% (32)
Explanation
A is not correct because the stated goal doesn't require an ancestor query. B is not correct because no data is being written, so a transaction isn't necessary. C is not correct because it wouldn't affect the results. D is correct because two inequality comparisons aren't permitted in a Datastore query and it requires two queries to be merged.
Topics
Community Discussion
No community discussion yet for this question.