diff --git a/docs/how-to/query-database.md b/docs/how-to/query-database.md index 6efcfe96..c4d3eaf4 100644 --- a/docs/how-to/query-database.md +++ b/docs/how-to/query-database.md @@ -19,7 +19,7 @@ $database = $notion->databases()->find($databaseId); $query = Query::create() ->changeFilter( CompoundFilter::and( - DateFilter::createdTime::pastWeek(), + DateFilter::createdTime()->pastWeek(), TextFilter::property("Name")->contains("John"), ) ) diff --git a/src/Databases/Query/DateFilter.php b/src/Databases/Query/DateFilter.php index 9034729f..1f0a4e40 100644 --- a/src/Databases/Query/DateFilter.php +++ b/src/Databases/Query/DateFilter.php @@ -93,9 +93,11 @@ public function value(): string|bool|array|stdClass public function toArray(): array { + $type = $this->propertyType === self::TYPE_PROPERTY ? "date" : $this->propertyName; + return [ $this->propertyType() => $this->propertyName, - "date" => [ + $type => [ $this->operator->value => $this->value ], ];