def METHOD_NAME(self):
    """Serialize database into file."""
    data = {}
    for name, locator in self.locators.items():
        data[name] = locator.to_dict()
    for name, fields in self._invalid.items():
        if name not in data:
            data[name] = fields
    with open_stream(self.path, "w") as fd:
        json.dump(data, fd, sort_keys=True, indent=4)