1
0

Move conversion of snake_case to camelCase to model to make recursive models still work

This commit is contained in:
kolaente
2020-04-14 22:46:27 +02:00
parent a77b4253cb
commit 7587821927
4 changed files with 37 additions and 37 deletions

View File

@ -1,4 +1,5 @@
import {defaults, omitBy, isNil} from 'lodash'
import {objectToCamelCase} from '../helpers/case'
export default class AbstractModel {
@ -7,6 +8,9 @@ export default class AbstractModel {
* @param data
*/
constructor(data) {
data = objectToCamelCase(data)
// Put all data in our model while overriding those with a value of null or undefined with their defaults
defaults(this, omitBy(data, isNil), this.defaults())
}

View File

@ -10,7 +10,7 @@ export default class TaskModel extends AbstractModel {
this.id = Number(this.id)
this.listId = Number(this.listId)
// Make date objects from timestamps
this.dueDate = this.dueDate ? new Date(this.dueDate) : null
this.startDate = this.startDate ? new Date(this.startDate) : null