Skip to content

Allow Query.select to accept a single string? #595

Description

@jgeewax

I figured if I wanted to select only one field, I could call .select('name') -- but got a scary error:

/usr/lib/node_modules/gcloud/lib/datastore/entity.js:520
  query.projection = q.selectVal.map(function(v) {
                                 ^
TypeError: undefined is not a function
    at Object.queryToQueryProto (/usr/lib/node_modules/gcloud/lib/datastore/entity.js:520:34)
    at Dataset.DatastoreRequest.runQuery (/usr/lib/node_modules/gcloud/lib/datastore/request.js:422:19)
    at Object.<anonymous> (/usr/local/google/home/jjg/datastore-playground.js:12:9)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Could we make the following snippet run happily?

// Note not an array being passed in!
var query = dataset.createQuery('MyKind').select('name');
dataset.runQuery(query);

// AND still:

var query = dataset.createQuery('MyKind').select(['name']);
dataset.runQuery(query);

Activity

  1. added this to the Datastore Future milestone on May 13, 2015
  2. 9 remaining items

  3. added a commit that references this issue on Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions