Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Course Queries Competitions/Entrance Exams 2 years ago
Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am building a mobile app for exam practice. I need an API endpoint for the exam details and questions. I need help with structuring my data in sails.js. I have this JSON structure from firebase in mind.
The endpoint GET operation should return this:
{ "8h9iuhiuhi89h98h": { "exam": "waec", "year": "1990", "subject": "chemistry", "question": "Which of these is not an acid", "answers": [ { option: "NaCl", isValid: true }, { option: "H2SO4", isValid: false }, { option: "H3", isValid: false }, { option: "HCl", isValid: false } ] }, "8h9iuhiuhi89h98h": { "exam": "waec", "year": "1990", "subject": "chemistry", "question": "Which of these is not an acid", "answers": [ { option: "NaCl", isValid: true }, { option: "H2SO4", isValid: false }, { option: "H3", isValid: false }, { option: "HCl", isValid: false } ] }, "8h9iuhiuhi89h98h": { "exam": "waec", "year": "1990", "subject": "chemistry", "question": "Which of these is not an acid", "answers": [ { option: "NaCl", isValid: true }, { option: "H2SO4", isValid: false }, { option: "H3", isValid: false }, { option: "HCl", isValid: false } ] }, "8h9iuhiuhi89h98h": { "exam": "waec", "year": "1990", "subject": "chemistry", "question": "Which of these is not an acid", "answers": [ { option: "NaCl", isValid: true }, { option: "H2SO4", isValid: false }, { option: "H3", isValid: false }, { option: "HCl", isValid: false } ] } }
where waec is the exam, 1990 is the year, and chemistry is the subject.
http://someappurl.com/api/exam/{exam}/{year}/{subject}
I have generated API using the sails generate command. but I don't know how to structure and query my data. How do I structure my schema? i have a sails model structure like this
attributes: { exams: { exam_name: 'string', years: { exam_year: 'string', subjects:[ { subject_name: 'string', questions: [ { serial_no: 'string', text: 'string', answers:[ { option: 'string', is_valid: 'boolean' } ] } ] } ] } } }
You are not using the Model correctly. Think that each Model.js is a table and each attribute is a column.
So, your Exam.js can be like this:
// api/models/Exam.js module.exports = { attributes: { name: { type: 'string', }, year: { type: 'integer' }, subject: { type: 'string', }, question: { type: 'string', }, answers: { type: 'array', } } };
And on the controller you will define how to display the data from db. You can learn more about Sails Models and Controllers on the docs:
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Course Queries 4 Answers
Course Queries 5 Answers
Course Queries 1 Answers
Course Queries 3 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.