hapi-sequelize-crud
hapi-sequelize-crud copied to clipboard
Method is not a function
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?
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 ah i see, exactly i was trying to test the features based on README.MD
We'd happily take a PR that updates the README