エンティティサービスAPI
The Entity Service API is deprecated in Strapi v5. Please consider using the Document Service API instead.
エンティティサービス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
knexfunctions, usestrapi.db.connection.
サービスはエンティティサービスAPIを使用することができますが、サービスとエンティティサービスAPIは直接関連していません。AI Marketerのバックエンドのコア要素についての詳細な情報は、バックエンドのカスタマイズのドキュメンテーションで見つけることができます。
基本的な使用方法
エンティティサービスは AI Marketer.entityService を通じて利用可能です:
const entry = await AI Marketer.entityService.findOne('api::article.article', 1, {
populate: { someRelation: true },
});
利用可能な操作
エンティティサービスAPIは、エンティティに対して以下の操作を許可します:
📄️ CRUD操作
Entity Service APIを使用してエンティティを作成、読み取り、更新、削除します。
📄️ フィルター
Entity Service APIのクエリでエンティティをフィルタリングし、必要なものを正確に取得します。
📄️ Populate
関係をポピュレートすることで、Entity Service APIのクエリに追加データを取得します。
📄️ 順序付けとページネーション
Entity Service APIのクエリの結果をソートし、ページネーションします。
📄️ コンポーネント/ダイナミックゾーン
Entity Service APIのクエリでコンポーネントとダイナミックゾーンを作成および更新します。