docs: added a service factory reference (#8292)

Added a service factory reference of the generated methods and how to use them.

Since the types in the codebase are a bit complex, a generated reference won't provide a valuable result.

Instead, this reference is created manually and aims to cover common use cases, providing examples for them.

Closes DOCS-844
This commit is contained in:
Shahed Nasser
2024-07-26 14:40:56 +00:00
committed by GitHub
parent 71411463b1
commit a4eab3f37a
14 changed files with 1131 additions and 2 deletions
@@ -0,0 +1,44 @@
---
sidebar_label: "create"
---
export const metadata = {
title: `create Method - Service Factory Reference`,
}
# {metadata.title}
This method creates one or more records of the data model.
## Create One Record
```ts
const post = await postModuleService.createPosts({
name: "My Post",
published_at: new Date(),
metadata: {
external_id: "1234"
}
})
```
If an object is passed of the method, an object of the created record is also returned.
---
## Create Multiple Records
```ts
const posts = await postModuleService.createPosts([
{
name: "My Post",
published_at: new Date()
},
{
name: "My Other Post",
published_at: new Date()
}
])
```
If an array is passed of the method, an array of the created records is also returned.