Created
December 20, 2017 16:00
-
-
Save timbuckley/06c707256768d2bf0521c5da611baf51 to your computer and use it in GitHub Desktop.
Example schema setup of normalizr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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