toMap method

Map<String, dynamic> toMap({
  1. bool forModelJson = false,
})

Convert this to a string map. Set forModelJson to exclude some keys that should not be part of the model JSON file.

Note: this is used by EntityResolver for model persistence in cache files and indirectly by CodeBuilder when generating objectbox-model.json.

Implementation

Map<String, dynamic> toMap({bool forModelJson = false}) {
  final ret = <String, dynamic>{};
  ret['id'] = id.toString();
  ret['lastPropertyId'] = lastPropertyId.toString();
  ret['name'] = name;
  if (flags != 0) ret['flags'] = flags;
  ret['properties'] =
      properties.map((p) => p.toMap(forModelJson: forModelJson)).toList();
  ret['relations'] =
      relations.map((r) => r.toMap(forModelJson: forModelJson)).toList();
  if (!forModelJson) {
    ret['backlinks'] = backlinks.map((r) => r.toMap()).toList();
    ret['constructorParams'] = constructorParams;
    ret['uidRequest'] = uidRequest;
  }
  return ret;
}