How to use the redux-orm.oneToOne function in redux-orm

To help you get started, we’ve selected a few redux-orm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SEL-Columbia / dokomoforms / dokomoforms / static / src / admin / js / create-survey / redux / models.babel.js View on Github external
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})
github GiraffeTools / GiraffeTools / frontend / porcupine / models / parameter.js View on Github external
}
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;
github SEL-Columbia / dokomoforms / dokomoforms / static / src / admin / js / create-survey / redux / models.babel.js View on Github external
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);
github GiraffeTools / GiraffeTools / frontend / porcupine / models / parameter.js View on Github external
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;

redux-orm

Simple ORM to manage and query your state trees

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis