Keystone's createItems
function is a simple but powerful way to populate your database with data.
It can be used to create test fixtures or initialise your database with default content / users / etc.
There's also a shorthand syntax that can be used within update files; if you are using the auto updates
feature, any file that exports a create
object will automatically be wrapped and the data will be created.
createItems
takes two passes at the data it is passed, first creating the items and retaining references by key (if provided) that can be used to populate relationships in the second pass. This makes it easy to create related data without asynchronous nesting (which for data creation sometimes ends up in knots).