Comments (2)
@eidge, I'm not sure about scopes for exact date/datetime. It's something I never thought before. Imagine this scope: .created_at_exactly('12-02-2014')
. What you be the expected behaviour? All records created in the 12th of February? Or the ones created on February? Or even the ones created along the entire year (2014)?
Nevertheless, I think you can still use Season
scopes to achieve that: what about using the scope .created_at_between('12-02-2014', '13-02-2014')
? It's even easier if you have a Date
object: .created_at_between(some_date, some_date + 1.day)
. You can do this for seconds, minutes, hours, days, months and years.
What do you think?
from season.
It's a matter of completion. You have scopes for datetime_column > x
, datetime_column < x
and datetime_column > x AND datetime_column < x
but no scopes for datetime_column = x
.
The date case, well, I think it's a common case to want to find something by date (in a specific day) and not care about the exact time. For instance, you're usually interested in all users created in a specific day. I'm aware that you can still use created_at_between(date.beggining_of_day, date.end_of_day)
but it's not as idiomatic as created_at_on(date/datetime)
(the created_at_exactly is not a good name though, I'll give you that), furthermore you can have different behaviors depending on whether you're passing a date or datetime object.
How does .created_at_between('12-02-2014', '13-02-2014')
behave? It's not easy to tell either is it? is it going to return all records from 12-02-2014 00:00
to 13-02-2014 24:00
or 13-02-2014 00.00
? it's not clear just by reading the method call is it? (It's only clear if you pass it a datetime otherwise, besides it being unclear it's database/orm specific behaviour)
from season.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from season.