toJSON (opts) {
    const mapper = this.constructor.mapper
    if (mapper) {
      return mapper.toJSON(this, opts)
    } else {
      const json = {}
      utils.forOwn(this, (prop, key) => {
        json[key] = utils.plainCopy(prop)
      })
      return json
    }
  }
Return a plain object representation of this record. If the class from
which this record was created has a Mapper, then {@link Mapper#toJSON} will
be called with this record instead.

@example <caption>Record#toJSON</caption>
const JSData = require('js-data');
const { Container } = JSData;
console.log('Using JSData v' + JSData.version.full);
const store = new Container();
store.defineMapper('user', {
  schema: {
    properties: {
      name: { type: 'string' }
    }
  }
});

const user = store.createRecord('user', {
  name: 'John',
  $$hashKey: '1234'
});
console.log('user: ' + JSON.stringify(user.toJSON()));

@method Record#toJSON
@param {object} [opts] Configuration options.
@param {string[]} [opts.with] Array of relation names or relation fields
to include in the representation. Only available as an option if the class
from which this record was created has a Mapper and this record resides in
an instance of {@link DataStore}.
@returns {Object} Plain object representation of this record.
@since 3.0.0