Last active
May 14, 2019 19:06
-
-
Save lynndylanhurley/18c7c187e249fa5751733bec8660a1d1 to your computer and use it in GitHub Desktop.
This file contains 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
1. start with these initial values: | |
get `tempId` method: | |
import { tempId } from 'json-api-client'; | |
use like: | |
fields.push({ | |
type: 'specifications', | |
id: tempId('specifications'), | |
attributes: { name: 'spec name' } | |
}) | |
2. these are the objects that we should be creating: | |
// Specifications | |
[ | |
{ | |
id: '[spec1]', | |
type: 'specifications', | |
attributes: { | |
name: 'Material' | |
} | |
}, | |
{ | |
id: '[spec2]', | |
type: 'specifications', | |
attributes: { | |
name: 'Dimensions' | |
} | |
} | |
] | |
// SpecificationValues | |
[ | |
{ | |
id: '3', | |
type: 'specificationValues', | |
attributes: { | |
name: 'Plastic', | |
// use the tempId for the associated specification | |
specificationId: '[spec1]' | |
} | |
}, | |
{ | |
id: '4', | |
type: 'specificationValues', | |
attributes: { | |
name: 'Wood', | |
specificationId: '[spec1]' | |
} | |
}, | |
{ | |
id: '5', | |
type: 'specificationValues', | |
attributes: { | |
name: '12x12', | |
specificationId: '[spec2]' | |
} | |
}, | |
{ | |
id: '6', | |
type: 'specificationValues', | |
attributes: { | |
name: '12x12', | |
specificationId: '[spec2]' | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment