docs: changed BaseService to TransactionBaseService (#2046)

This commit is contained in:
Shahed Nasser
2022-08-15 12:29:02 +03:00
committed by GitHub
parent 0703dd94e8
commit 4a89961fd4
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ npm run build
You can access your custom entity data in the database in services or subscribers using the repository. For example, heres a service that lists all posts:
```tsx
import { TransactionBaseService } from "medusa-interfaces";
import { TransactionBaseService } from '@medusajs/medusa';
class PostService extends TransactionBaseService {
constructor({ postRepository, manager }) {
@@ -12,7 +12,7 @@ Services in Medusa represent bundled helper methods that you want to use across
For example, you can use Medusas `productService` to get the list of products, as well as perform other functionalities related to products. Theres also an `authService` that provides functionalities like authenticating customers and users.
Custom services reside in the `src/services` directory of your Medusa Server installation. Each service should be a class that extends the `BaseService` class from `medusa-interfaces`.
Custom services reside in the `src/services` directory of your Medusa Server installation. Each service should be a class that extends the `TransactionBaseService` class from the core Medusa package `@medusajs/medusa`.
Each file you create in `src/services` should hold one service and export it.
@@ -29,9 +29,9 @@ To create a service, you should create a JavaScript file in `src/services` to ho
For example, if you want to create a service `helloService`, create the file `hello.js` in `src/services` with the following content:
```js
import { BaseService } from "medusa-interfaces"
import { TransactionBaseService } from '@medusajs/medusa';
class HelloService extends BaseService {
class HelloService extends TransactionBaseService {
getMessage() {
return `Welcome to My Store!`
}
@@ -42,7 +42,7 @@ export default HelloService
## Service Constructor
As the service extends the `BaseService` class, all services in Medusas core, as well as all your custom services, will be available in your services constructor using dependency injection.
As the service extends the `TransactionBaseService` class, all services in Medusas core, as well as all your custom services, will be available in your services constructor using dependency injection.
So, if you want your service to use another service, simply add it as part of your constructors dependencies and set it to a field inside your services class: