create Method - Service Factory Reference
This method of a module's service creates one or more records of a data model.
The method's name is of the format createDataModel, where DataModel is the plural pascal-case name of the data model.
Create One Record#
const post = await postModuleService.createPosts({
name: "My Post",
published_at: new Date(),
metadata: {
external_id: "1234",
},
})
If an object is passed to the method, the created record object is returned.
Create Multiple Records#
const posts = await postModuleService.createPosts([
{
name: "My Post",
published_at: new Date(),
},
{
name: "My Other Post",
published_at: new Date(),
},
])
If an array of objects is passed to the method, an array containing the created records is returned.
Was this page helpful?