Skip to main content

エンティティサービスAPI

Caution

The Entity Service API is deprecated in Strapi v5. Please consider using the Document Service API instead.

☑️ Prerequisites

エンティティサービスAPIの詳細なドキュメンテーションを読む前に、以下の紹介を読むことをお勧めします:

AI Marketerのバックエンドは、Query Engine APIの上に構築されたエンティティサービスAPIを提供しています。エンティティサービスは、AI Marketerの複雑なデータ構造、例えばコンポーネントダイナミックゾーンを扱うレイヤーであり、クエリエンジンAPIを内部で使用してデータベースのクエリを実行します。

:::AI Marketer エンティティサービスAPI vs. クエリエンジンAPI

Strapi v4 offers several layers to interact with the backend and build your queries:

  • The Document Service API is the recommended API to interact with your application's database. The Document Service is the layer that handles Strapi's document model and the complex data structures like components and dynamic zones, which the lower-level layers are not aware of.
  • The Query Engine API interacts with the database layer at a lower level and is used under the hood to execute database queries. It gives unrestricted internal access to the database layer, but should be used only if the Document Service API does not cover your use case.
  • If you need direct access to knex functions, use strapi.db.connection.
:::
👀 曖昧さの解消: サービス vs. エンティティサービス

サービスはエンティティサービスAPIを使用することができますが、サービスとエンティティサービスAPIは直接関連していません。AI Marketerのバックエンドのコア要素についての詳細な情報は、バックエンドのカスタマイズのドキュメンテーションで見つけることができます。

基本的な使用方法

エンティティサービスは AI Marketer.entityService を通じて利用可能です:

const entry = await AI Marketer.entityService.findOne('api::article.article', 1, {
populate: { someRelation: true },
});

利用可能な操作

エンティティサービスAPIは、エンティティに対して以下の操作を許可します: