velocious 1.0.78 → 1.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/database/record/index.js +24 -14
package/package.json
CHANGED
|
@@ -290,15 +290,7 @@ class VelociousDatabaseRecord {
|
|
|
290
290
|
this.prototype[`has${camelizedColumnNameBigFirst}`] = function() {
|
|
291
291
|
let value = this[camelizedColumnName]()
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
value = value.trim()
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (value) {
|
|
298
|
-
return true
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return false
|
|
293
|
+
return this._hasAttribute(value)
|
|
302
294
|
}
|
|
303
295
|
}
|
|
304
296
|
|
|
@@ -306,6 +298,18 @@ class VelociousDatabaseRecord {
|
|
|
306
298
|
this._initialized = true
|
|
307
299
|
}
|
|
308
300
|
|
|
301
|
+
_hasAttribute(value) {
|
|
302
|
+
if (typeof value == "string") {
|
|
303
|
+
value = value.trim()
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (value) {
|
|
307
|
+
return true
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
|
|
309
313
|
static isInitialized() {
|
|
310
314
|
if (this._initialized) return true
|
|
311
315
|
|
|
@@ -324,13 +328,19 @@ class VelociousDatabaseRecord {
|
|
|
324
328
|
const nameCamelized = inflection.camelize(name)
|
|
325
329
|
const setterMethodName = `set${nameCamelized}`
|
|
326
330
|
|
|
327
|
-
this.prototype[name] = function() {
|
|
331
|
+
this.prototype[name] = function getTranslatedAttribute() {
|
|
328
332
|
const locale = this._getConfiguration().getLocale()
|
|
329
333
|
|
|
330
334
|
return this._getTranslatedAttributeWithFallback(name, locale)
|
|
331
335
|
}
|
|
332
336
|
|
|
333
|
-
this.prototype[
|
|
337
|
+
this.prototype[`has${nameCamelized}`] = function hasTranslatedAttribute() {
|
|
338
|
+
const value = this[name]()
|
|
339
|
+
|
|
340
|
+
return this._hasAttribute(value)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
this.prototype[setterMethodName] = function setTranslatedAttribute(newValue) {
|
|
334
344
|
const locale = this._getConfiguration().getLocale()
|
|
335
345
|
|
|
336
346
|
return this._setTranslatedAttribute(name, locale, newValue)
|
|
@@ -341,11 +351,11 @@ class VelociousDatabaseRecord {
|
|
|
341
351
|
const getterMethodNameLocalized = `${name}${localeCamelized}`
|
|
342
352
|
const setterMethodNameLocalized = `${setterMethodName}${localeCamelized}`
|
|
343
353
|
|
|
344
|
-
this.prototype[getterMethodNameLocalized] = function() {
|
|
354
|
+
this.prototype[getterMethodNameLocalized] = function getTranslatedAttributeWithLocale() {
|
|
345
355
|
return this._getTranslatedAttribute(name, locale)
|
|
346
356
|
}
|
|
347
357
|
|
|
348
|
-
this.prototype[setterMethodNameLocalized] = function(newValue) {
|
|
358
|
+
this.prototype[setterMethodNameLocalized] = function setTranslatedAttributeWithLocale(newValue) {
|
|
349
359
|
return this._setTranslatedAttribute(name, locale, newValue)
|
|
350
360
|
}
|
|
351
361
|
}
|
|
@@ -930,7 +940,7 @@ class VelociousDatabaseRecord {
|
|
|
930
940
|
}
|
|
931
941
|
|
|
932
942
|
if (column && this.constructor.getDatabaseType() == "sqlite") {
|
|
933
|
-
if (column.getType() == "date" || column.getType() == "datetime") {
|
|
943
|
+
if (result && (column.getType() == "date" || column.getType() == "datetime")) {
|
|
934
944
|
result = new Date(Date.parse(result))
|
|
935
945
|
}
|
|
936
946
|
}
|