Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaelvilleneuve committed Dec 11, 2023
1 parent 5c1995f commit 6e44251
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Expand Up @@ -72,7 +72,6 @@ User.create(name: "John Doe")
UsersCreated.value
# => 1


# You can also get the count for a specific month
UsersCreated.value(month: Time.now)

Expand All @@ -87,6 +86,23 @@ UsersCreated.values_grouped_by_month(stop_at: Time.now.last_month.end_of_month,
# }
```

If you prefer you can also `include Statisfy::Model` in your model and define the counter directly on the model.

```ruby
class User < ApplicationRecord
include Statisfy::Model

count every: :user_created, as: :number_of_users_created
end

User.create(name: "John Doe")

# And then get the count like this:
User.number_of_users_created.value
# => 1
```


### Scoped counter

Imagine you have a `User` model that belongs to an `Organisation` and you want to count the number of users created per organisation.
Expand Down

0 comments on commit 6e44251

Please sign in to comment.