Skip to content

Commit 405a537

Browse files
committed
Strip time on date columns
1 parent 3729cae commit 405a537

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/adapters/common.js

+16
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ exports.create = function (record, data, options) {
6363
_.forEach(data.properties, function (property, name) {
6464
var fieldName = property.field || name
6565
record[name] = inserted[fieldName]
66+
if (property.type === 'date') {
67+
if (_.isDate(record[name])) {
68+
record[name] = record[name].toISOString()
69+
}
70+
if (typeof record[name] === 'string') {
71+
record[name] = record[name].slice(0, 10)
72+
}
73+
}
6674
if (property.mapper?.read) {
6775
record[name] = property.mapper.read(record[name], record)
6876
}
@@ -162,6 +170,14 @@ exports.update = function (record, data, options) {
162170
_.forEach(data.properties, function (property, name) {
163171
var fieldName = property.field || name
164172
record[name] = updated[fieldName]
173+
if (property.type === 'date') {
174+
if (_.isDate(record[name])) {
175+
record[name] = record[name].toISOString()
176+
}
177+
if (typeof record[name] === 'string') {
178+
record[name] = record[name].slice(0, 10)
179+
}
180+
}
165181
if (property.mapper?.read) {
166182
record[name] = property.mapper.read(record[name], record)
167183
}

0 commit comments

Comments
 (0)