io2015-codelabs icon indicating copy to clipboard operation
io2015-codelabs copied to clipboard

cloud-nodejs user query uses a two-argument filter()

Open dbs opened this issue 9 years ago • 0 comments
trafficstars

To implement the Display a user's books query, the getUserBooks() function is updated to include the following line:

var query = dataset.createQuery(['Book']).filter('userId =', userId);

The filter() method is called with only two arguments. The result is that the user's books are never shown; the query always returns null results.

Per the docs at https://cloud.google.com/datastore/docs/concepts/queries#filters, filter() should be called with three arguments: a property, comparison operator, and value.

The correct, working code is:

var query = dataset.createQuery(['Book']).filter('userId', '=', userId);

I'll create a pull request for the code samples. Unfortunately it's not clear where the text in the codelab is supposed to be fixed.

dbs avatar Mar 22 '16 04:03 dbs