POST /api/seq/position
GET /api/seq/position/{id?}
DELETE /api/seq/position/{id?}
PUT /api/seq/position/{id}
DELETE /api/seq/positions
GET /api/seq/positions
GET /api/seq/positions/{scope}
DELETE /api/seq/positions/{scope}
Question
GET /api/seq/questions
DELETE /api/seq/questions
DELETE /api/seq/questions/{scope}
GET /api/seq/questions/{scope}
One thing is, we use { id: request.query.id } for finding by id, and you are using custom fields, questionId and positionId.
But you say the Position model's id route works! Now that's inconsistency. Do you get any errors/warnings?
Let me see if I can reproduce your problem.
This is indeed weird, hmm...
One thing is, we use `{ id: request.query.id }` for finding by `id`, and you are using custom fields, `questionId` and `positionId`.
But you say the Position model's id route works! Now that's inconsistency. Do you get any errors/warnings?
Let me see if I can reproduce your problem.
/position/1and /question/1 throws 500. /positions/1 and /questions/1 throws 400, with message "child "scope" fails because ["scope" must be one of []]".
/poisitions and /questions (without id's) works 100%.
`/position/1`and `/question/1` throws 500.
`/positions/1` and `/questions/1` throws 400, with message "**child \"scope\" fails because [\"scope\" must be one of []]**".
`/poisitions` and `/questions` (without id's) works 100%.
Okay, so it's not inconsistency, is it? You get the same routes for both models, if that's the case, your problem is with ids.
You have positions/{scope}, not positions/{id}, instead there is position/{id} (which doesn't work in your case.
If I'm correct, the problem is with custom id fields.
Okay, so it's not inconsistency, is it? You get the same routes for both models, if that's the case, your problem is with `id`s.
You have `positions/{scope}`, not `positions/{id}`, instead there is `position/{id}` (which doesn't work in your case.
If I'm correct, the problem is with custom id fields.
I think the custom id is one of the issues. I don't understand why the position entity has 8 routes defined, and the question just 4? Or, are these two questions/issues related?
I think the custom id is one of the issues. I don't understand why the `position` entity has 8 routes defined, and the `question` just 4? Or, are these two questions/issues related?
Umm, I'm not sure about that. But I think we can address the id issue here, and if you encounter any problem with the routes, we'll get to that later. What do you say?
Umm, I'm not sure about that. But I think we can address the id issue here, and if you encounter any problem with the routes, we'll get to that later. What do you say?
I think we should allow custom id fields, I'm seeing if there is a way to automatically detect ID fields (using PRIMARY KEYs, INDEXes, etc.), or we should ask the programmer to explicitly set the custom field's name.
I think we should allow custom id fields, I'm seeing if there is a way to automatically detect ID fields (using PRIMARY KEYs, INDEXes, etc.), or we should ask the programmer to explicitly set the custom field's name.
I have set primaryKey: true on both entities. Didn't make a difference.
Changing the id from positionId to id on the database table, now gets results back for /position/1.
I have set `primaryKey: true` on both entities. Didn't make a difference.
Changing the id from `positionId` to `id` on the database table, now gets results back for `/position/1`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
@mdibaiee, I'm seeing some strange behaviour with the auto route creation.
Here's an example of 2 of my entity models:
PositionQuestionAnd, the created routes:
PositionQuestionThis is indeed weird, hmm...
One thing is, we use
{ id: request.query.id }for finding byid, and you are using custom fields,questionIdandpositionId.But you say the Position model's id route works! Now that's inconsistency. Do you get any errors/warnings?
Let me see if I can reproduce your problem.
/position/1and/question/1throws 500./positions/1and/questions/1throws 400, with message "child "scope" fails because ["scope" must be one of []]"./poisitionsand/questions(without id's) works 100%.Okay, so it's not inconsistency, is it? You get the same routes for both models, if that's the case, your problem is with
ids.You have
positions/{scope}, notpositions/{id}, instead there isposition/{id}(which doesn't work in your case.If I'm correct, the problem is with custom id fields.
I think the custom id is one of the issues. I don't understand why the
positionentity has 8 routes defined, and thequestionjust 4? Or, are these two questions/issues related?@casalot: Maybe you have relations/associations defined for your
Positionmodel?Nope. Neither
PositionnorQuestionhas any relations defined.Umm, I'm not sure about that. But I think we can address the id issue here, and if you encounter any problem with the routes, we'll get to that later. What do you say?
Cool. Should I rename the custom id's to
id? Or, is there a why to alias it?I think we should allow custom id fields, I'm seeing if there is a way to automatically detect ID fields (using PRIMARY KEYs, INDEXes, etc.), or we should ask the programmer to explicitly set the custom field's name.
I have set
primaryKey: trueon both entities. Didn't make a difference.Changing the id from
positionIdtoidon the database table, now gets results back for/position/1.Okay it seems there is a way to automatically use the primary key set by programmer, I'm going to patch it right now. 👍
Published to npm
hapi-sequelize-crud@2.4.0, see if it works for you.Working perfect now!
Great! 👍