[V3 Config] Update Mongo document organization to bypass doc size restriction (#2536)

* modify config to use identifier data class and update json driver

* move identifier data attributes into read only properties

* Update mongo get and set methods

* Update get/set to use UUID separately, make clear work

* Remove not implemented and fix get_raw

* Update remaining untouched get/set/clear

* Fix get_raw

* Finally fix get_raw and set_raw

* style

* This is better

* Sorry guys

* Update get behavior to handle "all" calls as expected

* style again

* Why do you do this to me

* style once more

* Update mongo schema
This commit is contained in:
Will
2019-04-03 09:04:47 -04:00
committed by GitHub
parent d6d6d14977
commit 1cd7e41f33
6 changed files with 194 additions and 77 deletions

View File

@@ -6,7 +6,7 @@ import logging
from ..json_io import JsonIO
from .red_base import BaseDriver
from .red_base import BaseDriver, IdentifierData
__all__ = ["JSON"]
@@ -93,16 +93,16 @@ class JSON(BaseDriver):
self.data = {}
self.jsonIO._save_json(self.data)
async def get(self, *identifiers: Tuple[str]):
async def get(self, identifier_data: IdentifierData):
partial = self.data
full_identifiers = (self.unique_cog_identifier, *identifiers)
full_identifiers = identifier_data.to_tuple()
for i in full_identifiers:
partial = partial[i]
return copy.deepcopy(partial)
async def set(self, *identifiers: str, value=None):
async def set(self, identifier_data: IdentifierData, value=None):
partial = self.data
full_identifiers = (self.unique_cog_identifier, *identifiers)
full_identifiers = identifier_data.to_tuple()
for i in full_identifiers[:-1]:
if i not in partial:
partial[i] = {}
@@ -111,9 +111,9 @@ class JSON(BaseDriver):
partial[full_identifiers[-1]] = copy.deepcopy(value)
await self.jsonIO._threadsafe_save_json(self.data)
async def clear(self, *identifiers: str):
async def clear(self, identifier_data: IdentifierData):
partial = self.data
full_identifiers = (self.unique_cog_identifier, *identifiers)
full_identifiers = identifier_data.to_tuple()
try:
for i in full_identifiers[:-1]:
partial = partial[i]