hapi-sequelize-crud icon indicating copy to clipboard operation
hapi-sequelize-crud copied to clipboard

Method is not a function

Open labibramadhan opened this issue 9 years ago • 3 comments
trafficstars

I have 3 models:

  • product with 1 field: name
  • category with 1 field: name
  • price with 1 field: price

Associations are:

  • product belongsTo category
  • product hasMany price
  • price belongsTo product

The problems are: /api/v1/product/1/category route with { "name": "Category 1" } POST JSON data and /api/v1/product/1/price route with { "price": 10000 } POST JSON data creates method is not a function error

Maybe the getMethod function inside src/utils.js called from inside create function inside src/associations/one-to-one.js cannot find the correct method, so its returns false.

Or maybe i missed something on my setup?

labibramadhan avatar Nov 03 '16 06:11 labibramadhan

Hi @labibramadhan If I understand you correctly, you're trying to create a new category that belongs to product with id=1. That's not currently something we support. But I would be happy to look at a pull request that adds that functionality.

In the meantime, you can always do:

POST /api/v1/category {"name": "Category 1", "productId": 1}

joeybaker avatar Nov 03 '16 17:11 joeybaker

@joeybaker ah i see, exactly i was trying to test the features based on README.MD

labibramadhan avatar Nov 04 '16 03:11 labibramadhan

We'd happily take a PR that updates the README

joeybaker avatar Nov 04 '16 03:11 joeybaker