create Method - Service Factory Reference

This method creates one or more records of the data model.

Create One Record#

Code
1const post = await postModuleService.createPosts({2  name: "My Post",3  published_at: new Date(),4  metadata: {5     external_id: "1234",6  },7})

If an object is passed of the method, an object of the created record is also returned.


Create Multiple Records#

Code
1const posts = await postModuleService.createPosts([2  {3    name: "My Post",4    published_at: new Date(),5  },6  {7    name: "My Other Post",8    published_at: new Date(),9  },10])

If an array is passed of the method, an array of the created records is also returned.

Was this page helpful?
Edit this page