Comments (8)
This is still important. Any updates?
from bookshelf.
Yeah, I'm working on a typecasting module & hooks that will help with this. In the meantime you can filter this stuff with a custom model.format
method.
from bookshelf.
Excellent! Yes I was planning of using format
and parse
for now. Looking forward to it and validation.
from bookshelf.
Any update on this is appreciated.
from bookshelf.
@tgriesser Why are we even using datetime
and not timestamp
? Wouldn't the whole issue just vaporize, if we used a timestamp
type for those fields? (which then could just receive the value from either new Date().getTime()
or Date.now()
)
Reading the date back would of course use the timezone of the server, but would yield the correct time, in contrast to saving a string into a datetime
field, which has been converted to UTC earlier. Like this:
var d = new Date(1389166613497) // just passing in the timestamp for a consistent example
var dTS = d.getTime() // => 1389166613497
var dString = d.toJSON() // => "2014-01-08T07:36:53.497Z"
If we were able to save dString
into the database everything would be fine, since recreating a date from it would yield the correct result, like this:
// the date will be correctly converted to the local timezone
var dateLater = new Date(dString);
But since we only have a string representation like 2014-01-08 07:36:53
, recreating the date from the database will result in this:
// will specify the date in the local timezone, even though it's UTC
var dateFromDB = new Date("2014-01-08 07:36:53");
dateFromDB.toJSON() // => "2014-01-08T05:36:53.000Z" - oops
Apart from hitting a bug in 2038 - is there anything that makes this not feasible?
from bookshelf.
gotta bump this one again @tgriesser ;) Any opinion about this? Or any progress which hasn't surfaced yet?
from bookshelf.
@tgriesser - how safe/reliable is it to handle this issue via the knex config (assuming you desire everything to be stored in UTC)?
For example something like this:
module.exports = {
development: {
client: 'mysql',
connection: {
host: 'localhost',
user: 'root',
password: '',
database: 'my_database',
timezone: 'UTC'
}
}
}
from bookshelf.
The project leadership of Bookshelf recently changed. In an effort to advance the project we close all issues older than one year.
If you think this issue needs to be re-evaluated please post a comment on why this is still important and we will re-open it.
We also started an open discussion about the future of Bookshelf.js here #1600. Feel free to drop by and give us your opinion.
Let's make Bookshelf great again
from bookshelf.
Related Issues (20)
- Change primary key value
- withRelated TypeScript error HOT 1
- Bookshelf.js update query not returning expected data
- Bookshelf.js update query not returning expected data
- Enhancement: ignore extra keys in withRelated option?
- ErrorCtor [CustomError]: EmptyResponse HOT 1
- How to save a object with hasMany/hasOne relations ?
- Make has_one relation with another model with composite id, Is it possible?
- [email protected]" has incorrect peer dependency "knex@>=0.15.0 <0.22.0" HOT 23
- Unable to use method named as attributes( ) in a model.
- Doc: MSSQL support
- How to know if a transaction has been committed? HOT 1
- Typescript models do not have relationship functions HOT 1
- Loop of transactions or transactions + promise pool
- Remove freenode references HOT 1
- Bookshelf using vulnerable version of lodash
- Property 'fetchPage' does not exist on type.
- Is Bookshelf actively maintained? HOT 1
- Limited SQL Injection Vulnerability in Bookshelf.js
- Specify sub-ordinate database name to connect to through Bookshelf model
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 bookshelf.