Move conversion of snake_case to camelCase to model to make recursive models still work
This commit is contained in:
@ -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())
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user