Skip to content

Instantly share code, notes, and snippets.

@lynndylanhurley
Last active May 14, 2019 19:06
Show Gist options
  • Save lynndylanhurley/18c7c187e249fa5751733bec8660a1d1 to your computer and use it in GitHub Desktop.
Save lynndylanhurley/18c7c187e249fa5751733bec8660a1d1 to your computer and use it in GitHub Desktop.
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