Skip to content

Commit

Permalink
fix(database): allow DateFilter to filter created_time and last_edite…
Browse files Browse the repository at this point in the history
…d_time
  • Loading branch information
samzzi authored Dec 14, 2023
1 parent 2ded3b4 commit ae9dba6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/how-to/query-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
)
Expand Down
4 changes: 3 additions & 1 deletion src/Databases/Query/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
];
Expand Down

0 comments on commit ae9dba6

Please sign in to comment.