Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: changed BaseService to TransactionBaseService #2046

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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