Skip to content

Commit

Permalink
docs: changed BaseService to TransactionBaseService
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Aug 15, 2022
1 parent 0703dd9 commit 5cdee89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/content/advanced/backend/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, here’s a service that lists all posts:

```tsx
import { TransactionBaseService } from "medusa-interfaces";
import { TransactionBaseService } from '@medusajs/medusa';

class PostService extends TransactionBaseService {
constructor({ postRepository, manager }) {
Expand Down
8 changes: 4 additions & 4 deletions docs/content/advanced/backend/services/create-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Services in Medusa represent bundled helper methods that you want to use across

For example, you can use Medusa’s `productService` to get the list of products, as well as perform other functionalities related to products. There’s 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.

Expand All @@ -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!`
}
Expand All @@ -42,7 +42,7 @@ export default HelloService

## Service Constructor

As the service extends the `BaseService` class, all services in Medusa’s core, as well as all your custom services, will be available in your service’s constructor using dependency injection.
As the service extends the `TransactionBaseService` class, all services in Medusa’s core, as well as all your custom services, will be available in your service’s constructor using dependency injection.

So, if you want your service to use another service, simply add it as part of your constructor’s dependencies and set it to a field inside your service’s class:

Expand Down

0 comments on commit 5cdee89

Please sign in to comment.