Comments (5)
Yes! Thank you so much. Keep up the good work!
from tayr.
You're welcome! And thank you too for your report and your encouragement!
Don't hesitate to contribute
from tayr.
Hey Man! (apologies for the late reply)
Glad that you like it.
You can update the module to the latest version "0.3.2" and keep just the code below, it will do all the work you want:
let userGroup = new T.tayr('userGroup', {
dateCreated: new Date()
})
let user = new T.tayr('user', {
firstName: 'Default',
lastName: 'User'
})
user.setParent(userGroup).then(function () {
console.log('User: ' + user.id + ' belongs to group: ' + userGroup.id)
})
If that doesn't fix your problem, let me know what error do you get
from tayr.
You switched to promises! That's awesome.
I'm still getting an error on the dateCreated
field. When I console.log(query.sql)
out of mysql
module's Connection.prototype.query()
I get:
...
CREATE TABLE IF NOT EXISTS userGroup ( id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY )
...
ALTER TABLE userGroup ADD dateCreated INT
...
INSERT INTO userGroup SET dateCreated = 1469547666197 ON DUPLICATE KEY UPDATE dateCreated = 1469547666197
Then I get the error:
Error: ER_WARN_DATA_OUT_OF_RANGE: Out of range value for column 'dateCreated' at row 1
So this is because a javascript Date()
won't fit in an INT
field, but from looking at your code, it seems like getDataType()
should catch the Date
object (with typeof
and instanceof
) and return a field data type of BIGINT
.
In getDataType(v)
, if I console.log
v
along with the corresponding data type, I get:
2016-07-26T16:03:18.906Z 'BIGINT'
1469548998906 'INT'
So it appears getDataType
is being called twice. The first time dateCreated
is recognized as a Date
object, the second time as a Number
.
I notice mendValue
has this line: if (v instanceof Date) return v.getTime()
which could have the effect of converting a Date
object to a Number
. Do you think this is where the issue might be?
from tayr.
I Added this line in getDataType:
if (v > 2147483647) return "BIGINT";
does this solve the problem ?
from tayr.
Related Issues (6)
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 tayr.