Closed nasushkov closed 7 years ago
@koskimas yes I saw this issue. But it's about legacy Node versions (I run 7.2.0) and ES5 inheritance. I use ES6 syntax:
export default class BaseModel extends Model {
$formatDatabaseJson(json) {
json = super.$formatDatabaseJson(json)
return mapKeys(json, (value, key) => snakeCase(key))
}
$parseDatabaseJson(json) {
json = mapKeys(json, (value, key) => camelCase(key))
return super.$parseDatabaseJson(json)
}
}
export default class Company extends BaseModel {
static tableName = 'company'
static jsonSchema = {
type: 'object',
required: ['id', 'name'],
properties: {
id: {type: 'integer'},
name: {type: 'string', maxLength: 200}
}
}
static relationMappings = {
residentialComplexes: {
relation: Model.HasManyRelation,
modelClass: path.join(MODELS_PATH, 'residentialComplex'),
join: {
from: 'company.id',
to: 'residential_complex.company_id'
}
}
}
}
You use babel. Please read the whole issue.
I'm trying to use this package with the latest Objection js version. Unfortunately, I've got the following error while building my schema:
Here is my stack trace:
It looks like the problem is in this row:
output = func(output, field, propName, modelClass.propertyNameToColumnName(propName));