Skip to content

Instantly share code, notes, and snippets.

@timbuckley
Created December 20, 2017 16:00
Show Gist options
  • Save timbuckley/06c707256768d2bf0521c5da611baf51 to your computer and use it in GitHub Desktop.
Save timbuckley/06c707256768d2bf0521c5da611baf51 to your computer and use it in GitHub Desktop.
Example schema setup of normalizr
import { Schema, arrayOf } from 'normalizr'
let userSchema = new Schema('user', options)
let nbhdSchema = new Schema('nbhd', options)
let itemSchema = new Schema('item', options)
let commentSchema = new Schema('comment', options)
let nbhdsSchema = arrayOf(nbhdSchema)
userSchema.define({
nbhds: nbhdsSchema
})
itemSchema.define({
author: userSchema,
favoriters: arrayOf(userSchema),
participants: arrayOf(userSchema),
user_mentions: arrayOf(userSchema),
nbhds: nbhdsSchema,
comments: arrayOf(commentSchema)
})
commentSchema.define({
author: userSchema,
user_mentions: arrayOf(userSchema),
replies: arrayOf(commentSchema)
})
let newsfeedSchema = arrayOf(itemSchema)
export {
userSchema,
nbhdSchema,
nbhdsSchema,
itemSchema,
newsfeedSchema,
commentSchema,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment