From d6c4d26e8f29950787c20ad34d0fc9509b75cc93 Mon Sep 17 00:00:00 2001 From: Adrian Salceanu Date: Tue, 7 Jun 2022 22:45:38 +0200 Subject: [PATCH] `count` refactoring --- Project.toml | 2 +- src/SearchLight.jl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 07a4398..9e1c3ac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SearchLight" uuid = "340e8cb6-72eb-11e8-37ce-c97ebeb32050" authors = ["Adrian Salceanu "] -version = "2.3" +version = "2.3.1" [deps] DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" diff --git a/src/SearchLight.jl b/src/SearchLight.jl index 4c35622..298a3f6 100644 --- a/src/SearchLight.jl +++ b/src/SearchLight.jl @@ -28,7 +28,7 @@ include("Callbacks.jl") export find, findone export rand, randone -export all, count # min, max, mean, median +export all # min, max, mean, median export findone_or_create, createwith, updateby_or_create, update_or_create export save, save!, save!!, updatewith!, updatewith!! export deleteall, delete @@ -193,6 +193,8 @@ function Base.last(m::Type{T}; order = SQLOrder(pk(m), :desc))::Union{Nothing,T} find(m, SQLQuery(order = order, limit = 1)) |> onereduce end +function count end + function Base.count(m::Type{T}; where_conditions...)::Int where {T<:AbstractModel} SearchLight.count(m, SQLQuery(where = [SQLWhereExpression("$(SQLColumn(x)) = ?", y) for (x,y) in where_conditions])) end