我对 REST 相当陌生,我一直在努力为 mySQL 数据库中的外键相关的对象映射 RESTful 请求。
我有以下对象,它们的关系呈线性顺序:
Quiz_course [1]
Quiz_meta_block [2]
Quiz_block [3]
Quiz_question [4]
到目前为止,我提出了以下GET
要求:
// Retrieve all quiz_course(s)
api/quiz_course/
// Retrieve quiz_course by id
api/quiz_course/{id}
// Retrieve all quiz_meta_blocks related to a quiz_course id
api/quiz_course/{id}/quiz_meta_block
// Retrieve a quiz_meta_block that is related to a quiz_course_id
api/quiz_course/{id}/quiz_meta_block/{id}
但是后来我在尝试获取 quiz_questions 时碰壁了:
// Retrieve all quiz_questions that is related to a quiz_course_id
api/quiz_course/{id}/quiz_meta_block/quiz_block/quiz_question/
我的陈述准确吗?