Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log('mapping through choices', choice)
return Object.assign({}, {choice_text: choice.choice_text});
});
if (choices.length) data = Object.assign(data, {choices: choices})
}
console.log('question data', data)
delete data.id;
delete data.node;
return data;
}
}
Question.fields = {
id: attr(),
node: oneToOne('Node'),
allow_multiple: attr(),
type_constraint: attr()
};
Question.modelName = 'Question';
class Node extends CRUDModel {
denormalize() {
console.log('this', this.ref)
const sub_surveys = this.sub_surveys.toModelArray().map(sub_survey => sub_survey.denormalize())
console.log('this id', this.ref.id)
const question = this.question.denormalize();
// console.log('the question', question)
// const questionNode = Object.assign({}, question)
let data = Object.assign({}, this.ref, {node: question})
}
Parameter.modelName = 'Parameter';
Parameter.fields = {
name: attr(),
data: attr(), // leaving room for data types here
isVisible: attr(),
isEnabled: attr(),
isIterable: attr(),
code: attr(),
type: attr(),
node: fk({
to: 'Node',
as: 'nodeModel',
relatedName: 'parameters',
}),
input: oneToOne({
to: 'Port',
as: 'inputModel',
relatedName: 'inputParent',
}),
output: oneToOne({
to: 'Port',
as: 'outputModel',
relatedName: 'outputParent',
}),
value: attr(),
};
export default Parameter;
class Logic extends CRUDModel {
denormalize() {
const data = Object.assign({}, this.ref)
delete data.id
delete data.question
return data
}
};
Logic.modelName = 'Logic';
Logic.fields = {
id: attr(),
question: oneToOne('Question')
};
class Choice extends CRUDModel {};
Choice.modelName = 'Choice';
Choice.fields = {
id: attr(),
question: fk('Question', 'multiple_choices')
}
const orm = new ORM();
orm.register(Survey, Node, Question, Bucket, Logic, Choice);
isVisible: attr(),
isEnabled: attr(),
isIterable: attr(),
code: attr(),
type: attr(),
node: fk({
to: 'Node',
as: 'nodeModel',
relatedName: 'parameters',
}),
input: oneToOne({
to: 'Port',
as: 'inputModel',
relatedName: 'inputParent',
}),
output: oneToOne({
to: 'Port',
as: 'outputModel',
relatedName: 'outputParent',
}),
value: attr(),
};
export default Parameter;