🙆
DrupalのJSON:APIでcreatedやchangedに対するフィルタを適用する
概要
DrupalのJSON:APIでcreatedやchangedに対するフィルタを適用する方法の備忘録です。
背景
以下を参考にしました。
例えば、6/2以降に更新されたものだけをフィルタリングしようとした際、以下のクエリでは適切に動作しませんでした。
?filter[a-label][condition][path]=changed&filter[a-label][condition][operator]=%3E%3D&filter[a-label][condition][value]=2025-06-02
正しい方法
以下の記事が参考になりました。
Note that timestamp fields (like created or changed) currently must use a timestamp for filtering:
タイムスタンプフィールド(createdやchangedなど)は現在、フィルタリングにタイムスタンプを使用する必要があります。
例えば、2025/6/2のタイムスタンプ1748790000
を用いて、以下のようなクエリを使用することで、正しくフィルタリングできました。
?filter[a-label][condition][path]=changed&filter[a-label][condition][operator]=%3E%3D&filter[a-label][condition][value]=1748790000
まとめ
DrupalのJSON:APIで、createdやchangedに対するフィルタを適用する際にお役に立てば幸いです。
Discussion