Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot call method 'map' of undefined #424

Closed
wingedrhino opened this issue Mar 4, 2015 · 3 comments
Closed

TypeError: Cannot call method 'map' of undefined #424

wingedrhino opened this issue Mar 4, 2015 · 3 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wingedrhino
Copy link

I setup an instance of type f1-micro in us-central1-f data center (machine type Ivy Bridge) running CentOS 7 to test some of my queries on as I plan to use google datastore as the backend db for a project.

The other details are that I enabled datastore service both for the project and for the instance while creating it.

Ran the following commands to update the system and get node running:

sudo yum install epel-release
sudo yum install vim git nodejs npm screen
sudo yum update
npm install gcloud
vim app.js

Dumped the following code into app.js:

'use strict';                                                                   
console.log('Entered app');                                                     
var gcloud = require('gcloud');                                                 
console.log('Imported gcloud');                                                 
var db = gcloud.datastore.dataset({                                        
  projectId: "<my actual project ID>"                                                
});                                                                             
var phone = '000000';                                                    
var userExistenceCheckQuery = {                                                 
  kinds: [{name: 'User'}],                                                      
  filter: {                                                                     
    propertyFilter: {                                                           
      property: {name: 'phone'},                                                
      operator: 'EQUAL',                                                        
      value: {stringValue: phone}                                               
    }                                                                           
  }                                                                             
};                                                                              
db.runQuery({                                                            
    query: userExistenceCheckQuery,                                             
  }).execute(function(err, result) {                                            
    if(err) {console.log(JSON.stringify(err, null, '  '));}                     
    else {console.log(JSON.stringify(result, null, '  '));}                     
  });

Output:

Entered app
Imported gcloud

/home/gautham/node_modules/gcloud/lib/datastore/entity.js:542
  query.projection = q.selectVal.map(function(v) {
                                 ^
TypeError: Cannot call method 'map' of undefined
    at Object.queryToQueryProto (/home/gautham/node_modules/gcloud/lib/datastore/entity.js:542:34)
    at Dataset.DatastoreRequest.runQuery (/home/gautham/node_modules/gcloud/lib/datastore/request.js:375:19)
    at Object.<anonymous> (/home/gautham/app.js:19:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Other relevant information:

node.js version is v0.10.33

Is there something I am doing wrong or is this a bug in the library ?

@stephenplusplus
Copy link
Contributor

This looks like code that the google-apis library expects (@ryanseys?)

This same thing in our library should look something like:

'use strict';
console.log('Entered app');
var gcloud = require('gcloud');
console.log('Imported gcloud');
var db = gcloud.datastore.dataset({
  projectId: "<my actual project ID>"
});
var phone = '000000';
var userExistenceCheckQuery = db
  .createQuery('User')
  .filter('phone =', phone);

db.runQuery(userExistenceCheckQuery, function(err, result) {
  if(err) {console.log(JSON.stringify(err, null, '  '));}
  else {console.log(JSON.stringify(result, null, '  '));}
});

@stephenplusplus
Copy link
Contributor

Feel free to re-open if you have any issues with our API. (Docs here: https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.12.0/datastore/query)

@ryanseys
Copy link
Contributor

ryanseys commented Mar 5, 2015

Yeah the generic library (google-api-nodejs-client) accepts this more generic form of a query object. Within gcloud-node we try to maintain a more idiomatic approach which is the reason for the more simplified and understandable api. Hope you find you like it more than the generic library! :)

@jgeewax jgeewax added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: datastore Issues related to the Datastore API. labels May 14, 2015
@jgeewax jgeewax added this to the Datastore Future milestone May 14, 2015
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
sofisl pushed a commit that referenced this issue Sep 15, 2022
…#424)

This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/7b446397-88f3-4463-9e7d-d2ce7069989d/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@5936421
sofisl pushed a commit that referenced this issue Sep 27, 2022
sofisl pushed a commit that referenced this issue Nov 9, 2022
sofisl pushed a commit that referenced this issue Nov 11, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/5f7f9c6d-c75a-4c60-8bb8-0026a14cead7/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 325949033
Source-Link: googleapis/googleapis@94006b3
sofisl pushed a commit that referenced this issue Nov 11, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/910b6b4c-44a8-42e1-939c-9018f9008df4/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@363fe30
sofisl pushed a commit that referenced this issue Nov 11, 2022
* chore(deps): upgrade gapic-generator-java to 2.4.1

PiperOrigin-RevId: 422607515

Source-Link: googleapis/googleapis@ba2ffd6

Source-Link: googleapis/googleapis-gen@73ba4ad
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzNiYTRhZGQyMzlhNjE5ZGE1NjdmZmJkNGU1NzMwZmRkNmRlMDRkMyJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Ace Nassri <anassri@google.com>
sofisl pushed a commit that referenced this issue Nov 17, 2022
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.0.0](https://www.github.com/googleapis/nodejs-compute/compare/v1.2.0...v2.0.0) (2020-05-08)


### ⚠ BREAKING CHANGES

* update to latest version of gts and typescript (#433)
* require node 10 in engines field (#431)

### Features

* require node 10 in engines field ([#431](https://www.github.com/googleapis/nodejs-compute/issues/431)) ([fe2897f](https://www.github.com/googleapis/nodejs-compute/commit/fe2897fd1d625df0ccf5b910ec850e761c2ed6d3))


### Bug Fixes

* apache license URL ([#468](https://www.github.com/googleapis/nodejs-compute/issues/468)) ([#427](https://www.github.com/googleapis/nodejs-compute/issues/427)) ([02d63ed](https://www.github.com/googleapis/nodejs-compute/commit/02d63ed5a5a3559be0b5e49ed4c771b3661518a1))
* **deps:** update dependency @google-cloud/common to v3 ([#421](https://www.github.com/googleapis/nodejs-compute/issues/421)) ([d4469b6](https://www.github.com/googleapis/nodejs-compute/commit/d4469b693745df5a8a36b6988b7dba98f7d55142))
* **deps:** update dependency @google-cloud/paginator to v3 ([#419](https://www.github.com/googleapis/nodejs-compute/issues/419)) ([e667aee](https://www.github.com/googleapis/nodejs-compute/commit/e667aeecf7b9f51875c06cb6a885040828dc1181))
* **deps:** update dependency @google-cloud/projectify to v2 ([#418](https://www.github.com/googleapis/nodejs-compute/issues/418)) ([b861540](https://www.github.com/googleapis/nodejs-compute/commit/b861540aa17118a7508c7c970d84864a9028f588))
* **deps:** update dependency @google-cloud/promisify to v2 ([#417](https://www.github.com/googleapis/nodejs-compute/issues/417)) ([eedce75](https://www.github.com/googleapis/nodejs-compute/commit/eedce75e0d3f10dfed8151f12150d38d032f6a27))
* **deps:** update dependency @sendgrid/mail to v7 ([#424](https://www.github.com/googleapis/nodejs-compute/issues/424)) ([17af0f4](https://www.github.com/googleapis/nodejs-compute/commit/17af0f425354b261f9afc8ab30e16e66b7193fec))


### Build System

* update to latest version of gts and typescript ([#433](https://www.github.com/googleapis/nodejs-compute/issues/433)) ([a4fa8cc](https://www.github.com/googleapis/nodejs-compute/commit/a4fa8cc21df7a894486832b05449fa7afc02b7ee))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants