How to use the normalizr.schema.Entity function in normalizr

To help you get started, we’ve selected a few normalizr 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 influxdata / influxdb / ui / src / schemas / index.ts View on Github external
}
  cells: {
    [uuid: string]: NCell
  }
  labels: {
    [uuid: string]: Label
  }
  views: {
    [uuid: string]: View
  }
}

const views = new schema.Entity('views')

// Define cell schema
const cells = new schema.Entity(
  'cells',
  {
    views: [views],
  },
  {
    // add dashboardID to cell
    processStrategy: (entity, parent) => ({...entity, dashboardID: parent.id}),
  }
)

// Define label schema
export const labels = new schema.Entity('labels')

// Define dashboard schema
export const dashboards = new schema.Entity('dashboards', {
  cells: [cells],
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / normalizers.ts View on Github external
public constructor() {
        this.idOption = { idAttribute: 'uid' };

        // run schemas
        this.job = new schema.Entity('jobs', {}, this.idOption);
        this.task = new schema.Entity('tasks', {}, this.idOption);
        this.provider_task = new schema.Entity('provider_tasks', { tasks: new schema.Array(this.task) }, this.idOption);
        this.provider_tasks = new schema.Array(this.provider_task);
        this.run = new schema.Entity('runs', { job: this.job, provider_tasks: this.provider_tasks }, this.idOption);
        this.runs = new schema.Array(this.run);
    }
github gpbl / denormalizr / test / immutable.js View on Github external
describe('parsing an array of entities and collections', () => {
    const articleSchema = new Schema.Entity('articles');
    const userSchema = new Schema.Entity('users');
    const collectionSchema = new Schema.Entity('collections');

    articleSchema.define({
      author: userSchema,
      collections: new Schema.Array(collectionSchema),
    });

    collectionSchema.define({
      curator: userSchema,
    });

    const article1 = {
      id: 1,
      title: 'Some Article',
      author: {
        id: 1,
        name: 'Dan',
github gpbl / denormalizr / test / immutable.js View on Github external
describe('parsing entities and collections', () => {
    const articleSchema = new Schema.Entity('articles');
    const userSchema = new Schema.Entity('users');
    const collectionSchema = new Schema.Entity('collections');

    articleSchema.define({
      author: userSchema,
      collections: new Schema.Array(collectionSchema),
    });

    collectionSchema.define({
      curator: userSchema,
    });

    const article1 = {
      id: 1,
      title: 'Some Article',
      author: {
github malerba118 / react-use-database / src / testHelpers / index.js View on Github external
import users from './users'
import cloneDeep from 'lodash/cloneDeep'

export {
  users
}

const UserSchema = new schema.Entity(
  'User',
  {},
  {
    idAttribute: 'id'
  }
)

const PostSchema = new schema.Entity(
  'Post',
  {
    author: UserSchema
  },
  {
    idAttribute: 'id'
  }
)

export const models = {
  PostSchema: PostSchema,
  UserSchema: UserSchema
}

export const getAppData = (app) => JSON.parse(app.find('#data').text())
github osmlab / maproulette3 / src / services / User / User.js View on Github external
export const userDenormalizationSchema = function() {
  return new schema.Entity('users', {
    savedChallenges: [ challengeSchema() ],
    topChallenges: [ challengeSchema() ],
    savedTasks: [ taskDenormalizationSchema() ],
  })
}
github webkom / lego-webapp / app / reducers / index.ts View on Github external
export const gallerySchema = new schema.Entity('galleries');

export const quoteSchema = new schema.Entity('quotes', {
  comments: [commentSchema]
});

export const pollSchema = new schema.Entity('polls');

export const podcastSchema = new schema.Entity('podcasts');

export const pageSchema = new schema.Entity(
  'pages',
  {},
  { idAttribute: 'slug' }
);
export const companySemesterSchema = new schema.Entity('companySemesters');
export const companyInterestSchema = new schema.Entity('companyInterest', {
  semesters: [companySemesterSchema]
});
export const companySchema = new schema.Entity('companies', {
  studentContact: userSchema,
  comments: [commentSchema]
});
export const joblistingsSchema = new schema.Entity('joblistings');
export const announcementsSchema = new schema.Entity('announcements');
export const feedActivitySchema = new schema.Entity('feedActivities');
export const oauth2ApplicationSchema = new schema.Entity('oauth2Application');
export const oauth2GrantSchema = new schema.Entity('oauth2Grant');
export const membershipSchema = new schema.Entity('memberships', {
  user: userSchema
});
export const meetingInvitationSchema = new schema.Entity(
github osmlab / maproulette3 / src / services / Task / Task.js View on Github external
export const taskBundleSchema = function() {
  return new schema.Entity('taskBundles', {tasks: [ taskSchema() ]})
}
github webkom / lego-webapp / app / reducers / index.ts View on Github external
export const podcastSchema = new schema.Entity('podcasts');

export const pageSchema = new schema.Entity(
  'pages',
  {},
  { idAttribute: 'slug' }
);
export const companySemesterSchema = new schema.Entity('companySemesters');
export const companyInterestSchema = new schema.Entity('companyInterest', {
  semesters: [companySemesterSchema]
});
export const companySchema = new schema.Entity('companies', {
  studentContact: userSchema,
  comments: [commentSchema]
});
export const joblistingsSchema = new schema.Entity('joblistings');
export const announcementsSchema = new schema.Entity('announcements');
export const feedActivitySchema = new schema.Entity('feedActivities');
export const oauth2ApplicationSchema = new schema.Entity('oauth2Application');
export const oauth2GrantSchema = new schema.Entity('oauth2Grant');
export const membershipSchema = new schema.Entity('memberships', {
  user: userSchema
});
export const meetingInvitationSchema = new schema.Entity(
  'meetingInvitations',
  {
    user: userSchema
  },
  {
    idAttribute: invite =>
      getMeetingInvitationId(invite.meeting, invite.user.username)
  }
github totorototo / strava / app / store / services / athlete.js View on Github external
response => {
      const athlete = response.data;
      const shoes = new schema.Entity("shoes", {}, { idAttribute: "id" });
      const bikes = new schema.Entity("bikes", {}, { idAttribute: "id" });
      const clubs = new schema.Entity("clubs", {}, { idAttribute: "id" });
      const athleteSchema = new schema.Entity(
        "athletes",
        {
          shoes: [shoes],
          bikes: [bikes],
          clubs: [clubs]
        },
        {
          idAttribute: "id",
          processStrategy: entity =>
            pick(entity, [
              "firstname",
              "lastname",
              "profile",