Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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);
}
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);
}
}
static get fields() {
return {
id: attr(),
title: attr(),
body: attr(),
createdAt: attr(),
updatedAt: attr(),
commentNumber: attr(),
labels: many('Label', 'posts'),
user: fk('User', 'posts'),
};
}
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 => {
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})
};
}
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(),
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,
}),
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);
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: