Skip to content

Instantly share code, notes, and snippets.

@lokhmakov
Created October 21, 2018 10:37
Show Gist options
  • Save lokhmakov/bd79b34c47151334c432cee23d9dda96 to your computer and use it in GitHub Desktop.
Save lokhmakov/bd79b34c47151334c432cee23d9dda96 to your computer and use it in GitHub Desktop.
core/entity/api/generate/listAdd.js
import { builders as b } from 'ast-types'
import generateField from './field'
export default ({
name,
fields = [],
}) => {
return b.expressionStatement(
b.callExpression(
b.memberExpression(
b.identifier(name),
b.identifier('add'),
false
),
[
b.objectExpression(
fields.map(generateField)
)
]
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment