Home Manual Reference Source Test

lib/attributes/attribute-boolean.js

import Attribute from './attribute';

/**
The value of this attribute is always a boolean. Null values are coerced to false.

String attributes can be queries using `equal` and `not`. Matching on
`greaterThan` and `lessThan` is not supported.
*/
export default class AttributeBoolean extends Attribute {
  toJSON(val) {
    return val;
  }
  fromJSON(val) {
    return ((val === 'true') || (val === true)) || false;
  }
  columnSQL() {
    return `${this.jsonKey} INTEGER`;
  }
}