loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
79 stars 56 forks source link

Update attributes doesn't work for string IDs #4

Closed pulkitsinghal closed 9 years ago

pulkitsinghal commented 9 years ago

For an API URL call like: http://localhost:3000/api/StoreConfigModels/XjEuI-pbRKWeSNFNxJRQsA the id isn't passed through to the update attributes method and it fails:

{
  "error": {
    "name": "Error",
    "status": 500,
    "message": "id not set!",
    "stack": "Error: id not set!
  at [object Object].updateAttrs [as updateAttributes] (/Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/lib/esConnector.js:887:15)
  at ModelConstructor.<anonymous> (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/dao.js:1907:27)
  at ModelConstructor.trigger (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/hooks.js:65:12)
  at ModelConstructor.<anonymous> (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/dao.js:1893:14)
  at ModelConstructor.trigger (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/hooks.js:65:12)
  at /Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/dao.js:1892:12
  at ModelConstructor.<anonymous> (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/validations.js:460:11)
  at ModelConstructor.next (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/hooks.js:75:12)
  at ModelConstructor.<anonymous> (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/validations.js:457:23)
  at ModelConstructor.trigger (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/hooks.js:65:12)
  at ModelConstructor.Validatable.isValid (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/validations.js:433:8)
  at /Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/dao.js:1886:10
  at doNotify (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/model.js:595:49)
  at doNotify (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/model.js:595:49)
  at doNotify (/Users/pulkitsinghal/dev/w2/node_modules/loopback-datasource-juggler/lib/model.js:595:49)
  ..."
  }
}
pulkitsinghal commented 9 years ago

store-config-model.json:

  "idInjection": false,
  "properties": {
    "objectId": {
      "type": "string",
      "id": true,
      "generated": true
    },
pulkitsinghal commented 9 years ago

Added unit tests for string IDs and they work: https://github.com/strongloop-community/loopback-connector-elastic-search/commit/5fc90e2e7bcfcb7053b10154f33ef010038a2e9d

So then the problem I have when I try to use this module, must be on the angular side? Is there a known bug around this in angular @raymondfeng?

pulkitsinghal commented 9 years ago

I could expose the feature branch where I try to use the es connector but there are a few configuration files that need to be setup, if anyone wants to leverage my existing angular project to see this problem in action, they would have to coordinate with me over gitter a bit...

pulkitsinghal commented 9 years ago

@raymondfeng - any quick comments on this one? I'll try to reproduce it again and report back soon.

pulkitsinghal commented 9 years ago

After testing, I believe this may have been inadvertently fixed alongside issue #3 ... the test I ran is manual end-to-end test on a project where I use esConnector, so I apologize that there isn't a unit test in-place for it.