Closed rbw closed 3 years ago
Adds support for any level of nesting and fixes bugs related to fetching of nested objects and how they are merged with the main document.
Model declaration
class ProductCatalogItem(ModelSchema): sys_id = aiosnow.fields.String() no_order_now = aiosnow.fields.Boolean() delivery_time = aiosnow.fields.DateTime() sys_name = aiosnow.fields.String() class HardwareModel(ModelSchema): sys_id = aiosnow.fields.String() name = aiosnow.fields.String() manufacturer = aiosnow.fields.StringMap() model_number = aiosnow.fields.String() barcode = aiosnow.fields.String() power_consumption = aiosnow.fields.Integer() rack_units = aiosnow.fields.Integer() product_catalog_item = ProductCatalogItem class Hardware(aiosnow.TableModel): sys_id = aiosnow.fields.String(is_primary=True) asset_tag = aiosnow.fields.String() install_status = aiosnow.fields.StringMap() location = aiosnow.fields.String(pluck=Pluck.DISPLAY_VALUE) company = aiosnow.fields.StringMap() ci = aiosnow.fields.String(pluck=Pluck.DISPLAY_VALUE) serial_number = aiosnow.fields.String() model = HardwareModel sys_class_name = aiosnow.fields.String(pluck=Pluck.DISPLAY_VALUE) product_catalog_item = ProductCatalogItem
Response data
[ { 'asset_tag': 'P1000479', 'ci': 'MacBook Pro 15"', 'company': <StringMapping [key=81fdf9ebac1d55eb4cb89f136a082555, value=ACME China]>, 'install_status': <StringMapping [key=1, value=In use]>, 'location': '2500 West Daming Road, Shanghai', 'model': { 'barcode': 'MD318LL/A', 'manufacturer': <StringMapping [key=b7e9e843c0a80169009a5a485bb2a2b5, value=Apple]>, 'model_number': 'MD318LL/A', 'name': 'MacBook Pro 15"', 'power_consumption': None, 'product_catalog_item': { 'delivery_time': datetime.datetime(1970, 1, 3, 0, 0), 'no_order_now': False, 'sys_id': '2ab7077237153000158bbfc8bcbe5da9', 'sys_name': 'Apple MacBook Pro 15"'}, 'rack_units': 1, 'sys_id': 'd501454f1b1310002502fbcd2c071334'}, 'product_catalog_item': { 'delivery_time': datetime.datetime(1970, 1, 3, 0, 0), 'no_order_now': False, 'sys_id': '2ab7077237153000158bbfc8bcbe5da9', 'sys_name': 'Apple MacBook Pro 15"'}, 'serial_number': 'BQP-854-D33246-GH', 'sys_class_name': 'Hardware', 'sys_id': 'd501454f1b1310002502fbcd2c071334'}]
Adds support for any level of nesting and fixes bugs related to fetching of nested objects and how they are merged with the main document.
Model declaration
Response data