How to use the redux-orm.many 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 GiraffeTools / GiraffeTools / frontend / porcupine / models / language.js View on Github external
name: nodeLanguage,
                nodes: [payload.id],
              });
            }
          });
        break;
    }
    return undefined;
  }
}
Language.modelName = 'Language';
Language.fields = {
  name: attr(),
  numberInEditor: attr(),
  // languages
  nodes: many({
    to: 'Node',
    as: 'nodes',
    relatedName: 'languages',
  }),
};

export default Language;
github markerikson / project-minimek / src / features / unitInfo / Unit.js View on Github external
import {Model, many, fk, attr} from "redux-orm";


export default class Unit extends Model {
    static modelName = "Unit";

    static fields = {
        id : attr(),
        name : attr(),
        affiliation : fk("Faction"),
        color : attr(),
        lances : many("Lance"),
        pilots : many("Pilot"),
        mechs : many("Mech")
    };

    static parse(unitData) {
        const {Pilot, Mech, Lance} = this.session;

        const parsedData = {
            ...unitData,
            lances : unitData.lances.map(lanceEntry => Lance.parse(lanceEntry)),
            pilots : unitData.pilots.map(pilotEntry => Pilot.parse(pilotEntry)),
            mechs : unitData.mechs.map(mechEntry => Mech.parse(mechEntry)),
        };

        return this.upsert(parsedData);
    }
github markerikson / project-minimek / src / features / unitInfo / Lance.js View on Github external
import {Model, many, attr} from "redux-orm";


export default class Lance extends Model {
    static modelName = "Lance";
    
    static fields = {
        id : attr(),
        name : attr(),
        pilots : many("Pilot")
    };

    static parse(lanceData) {
        return this.upsert(lanceData);
    }

}
github ksco / reblog / src / models / Post.js View on Github external
static get fields() {
    return {
      id: attr(),
      title: attr(),
      body: attr(),
      createdAt: attr(),
      updatedAt: attr(),
      commentNumber: attr(),
      labels: many('Label', 'posts'),
      user: fk('User', 'posts'),
    };
  }
github tommikaikkonen / redux-orm-example / app / models.js View on Github external
const hasAuthors = publisher.authors.length > 0;

        if (hasName && hasPublisher && hasGenres && hasAuthors) {
            return true;
        }
        return false;
    }

    toString() {
        return `Book: ${this.name}`;
    }
}
Book.modelName = 'Book';

Book.fields = {
    authors: many('Author'),
    publisher: fk('Publisher'),
    genres: many('Genre'),
};

class Author extends CRUDModel {
    static validate(props) {
        if (props.name && props.name.length > 0) {
            return true;
        }
        return false;
    }

    writesGenres() {
        const authorBooks = this.bookSet;
        const allGenres = [];
        authorBooks.forEach(book => {
github N3TC4T / Nearby-Live / src / redux / core / conversations / models.js View on Github external
static get fields() {
        return {
            id: attr(),
            messages: many('Message'),
            gold: attr(),
            img: attr(),
            last: attr(),
            lastid: attr(),
            msg: attr(),
            name: attr(),
            new: attr(),
            staff: attr(),
            total: attr(),
            initialized: attr({getDefault: false})
        };
    }
github N3TC4T / Nearby-Live / src / redux / core / stream / models.js View on Github external
static get fields() {
        return {
            id: attr({getDefault: uuid.v4}),
            comments: many('Comment'),
            section: attr({getDefault: () => []}),
            cc: attr(),
            d: attr(),
            date: attr(),
            featured: attr(),
            gp: attr(),
            gr: attr(),
            grId: attr(),
            img: attr(),
            lc: attr(),
            lcid: attr(),
            loc: attr(),
            name: attr(),
            new: attr(),
            pImg: attr(),
            pc: attr(),
github tommikaikkonen / redux-orm-primer / app / models.js View on Github external
break;
        case DELETE_TODO:
            Todo.withId(payload).delete();
            break;
        case ADD_TAG_TO_TODO:
            Todo.withId(payload.todo).tags.add(payload.tag);
            break;
        case REMOVE_TAG_FROM_TODO:
            Todo.withId(payload.todo).tags.remove(payload.tag);
            break;
        }
    }
}
Todo.modelName = 'Todo';
Todo.fields = {
    tags: many('Tag', 'todos'),
    user: fk('User', 'todos'),
};
Todo.propTypes = {
    text: PropTypes.string.isRequired,
    done: PropTypes.bool.isRequired,
    user: PropTypes.oneOfType([
        PropTypes.instanceOf(User),
        PropTypes.number,
    ]).isRequired,
    tags: PropTypes.arrayOf(PropTypes.oneOfType([
        PropTypes.instanceOf(Tag),
        PropTypes.string,
    ])).isRequired,
};
Todo.defaultProps = {
    done: false,
github meltyshev / planka / client / src / models / Card.js View on Github external
}),
    isAllActionsFetched: attr({
      getDefault: () => false,
    }),
    listId: fk({
      to: 'List',
      as: 'list',
      relatedName: 'cards',
    }),
    boardId: fk({
      to: 'Board',
      as: 'board',
      relatedName: 'cards',
    }),
    users: many('User', 'cards'),
    labels: many('Label', 'cards'),
  };

  static reducer({ type, payload }, Card) {
    switch (type) {
      case ActionTypes.USER_TO_CARD_ADD: {
        const cardModel = Card.withId(payload.cardId);
        cardModel.users.add(payload.id);

        if (payload.isCurrent) {
          cardModel.isSubscribed = true;
        }

        break;
      }
      case ActionTypes.USER_FROM_CARD_REMOVE:
        Card.withId(payload.cardId).users.remove(payload.id);
github meltyshev / planka / client / src / models / Card.js View on Github external
getDefault: () => false,
    }),
    isAllActionsFetched: attr({
      getDefault: () => false,
    }),
    listId: fk({
      to: 'List',
      as: 'list',
      relatedName: 'cards',
    }),
    boardId: fk({
      to: 'Board',
      as: 'board',
      relatedName: 'cards',
    }),
    users: many('User', 'cards'),
    labels: many('Label', 'cards'),
  };

  static reducer({ type, payload }, Card) {
    switch (type) {
      case ActionTypes.USER_TO_CARD_ADD: {
        const cardModel = Card.withId(payload.cardId);
        cardModel.users.add(payload.id);

        if (payload.isCurrent) {
          cardModel.isSubscribed = true;
        }

        break;
      }
      case ActionTypes.USER_FROM_CARD_REMOVE:

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