Thank you very much in advance.
I am developing a quiz application that has two types of answer forms
one with multiple choice options
and another open question input, then in the realm schema I made the following configuration
const OptionSchema = {
name: 'Option',
primaryKey: 'id',
properties: {
id: {type: 'int', indexed: true},
description: 'string?',
imageSound: 'string?',
correct: 'bool',
marked: 'bool?',
play: 'bool?',
},
};
export default OptionSchema;
const QuestionSchema = {
name: 'Question',
primaryKey: 'id',
properties: {
id: {type: 'int', indexed: true},
questionForm: 'string',
optionForm: 'string',
typeAnswer: 'string',
description: 'string',
correctAnswerDescription: 'string?',
correctAnswerDescriptionId: 'string?',
imageSound: 'string?',
options: 'Option?[]',
},
};
export default QuestionSchema;
I was wondering how do I leave the options
property: 'Option []'
optiocinal in schema because it is not getting
reading the documentation there are the following cases:
for properties
displayName: 'string?', // optional property
birthday: {type: 'date', optional: true}, // optional property
for list
testScores: 'double?[]'
trying both ways in my case
first try
options: {type: 'Option[]', optional: true},
second try
options:'Option?[]'
in neither case did it work would you have a solution?
An option that does not solve the problem but may help temporarily would be:
add a null record and all registration that is not registered you point null as a child. example
const OptionSchema = {
name: 'Option',
primaryKey: 'id',
properties: {
id: {type: 'int', indexed: true, optional: true},
description: {type: 'string', optional: true},
imageSound: {type: 'string', optional: true},
correct: {type: 'bool', optional: true},
marked: {type: 'bool', optional: true},
play: {type: 'bool', optional: true},
},
};
export default OptionSchema;
const QuestionSchema = {
name: 'Question',
primaryKey: 'id',
properties: {
id: {type: 'int', indexed: true},
questionForm: 'string',
optionForm: 'string',
typeAnswer: 'string',
description: 'string',
correctAnswerDescription: {type: 'string', optional: true},
correctAnswerDescriptionId: {type: 'int', optional: true},
imageSound: {type: 'string', optional: true},
options: 'Option[]',
},
};
export default QuestionSchema;
thank you all I hope I helped until the problem has a solution.