Changeset View
Changeset View
Standalone View
Standalone View
lib/chip-types/collection.js
Show First 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | for (const field_name in formatted_values) { | ||||
); | ); | ||||
} | } | ||||
return Promise.props(formatted_values); | return Promise.props(formatted_values); | ||||
}, | }, | ||||
_get_body: async function(fields, context, db_document, format) { | _get_body: async function(fields, context, db_document, format) { | ||||
const decoded_values = await Collection.pure.decode_values( | const decoded_values = await Collection.pure.decode_values( | ||||
fields, | fields, | ||||
context, | context, | ||||
db_document.body | db_document | ||||
); | ); | ||||
return Collection.pure.format_decoded_values( | return Collection.pure.format_decoded_values( | ||||
fields, | fields, | ||||
context, | context, | ||||
decoded_values, | decoded_values, | ||||
format || {} | format || {} | ||||
); | ); | ||||
}, | }, | ||||
Show All 11 Lines | for (const field_name in calculated_fields) { | ||||
context, | context, | ||||
representation, | representation, | ||||
raw_db_entry | raw_db_entry | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
return Promise.props(ret); | return Promise.props(ret); | ||||
}, | }, | ||||
get_resource_representation: function( | get_resource_representation: async function( | ||||
fields, | fields, | ||||
field_type_name, | field_type_name, | ||||
context, | context, | ||||
db_document, | db_document, | ||||
format, | format, | ||||
calculated_fields, | calculated_fields, | ||||
calculate | calculate | ||||
) { | ) { | ||||
if (calculate === undefined) calculate = true; | if (calculate === undefined) calculate = true; | ||||
const representation = {}; | const representation = await Collection.pure._get_body( | ||||
representation.created_context = db_document.created_context; | |||||
representation.last_modified_context = | |||||
db_document.last_modified_context; | |||||
representation.id = db_document.sealious_id; | |||||
representation.collection_name = field_type_name; | |||||
representation.body = Collection.pure._get_body( | |||||
fields, | fields, | ||||
context, | context, | ||||
db_document, | db_document, | ||||
format | format | ||||
); | ); | ||||
representation.id = db_document.sealious_id; | |||||
representation._metadata = db_document._metadata; | |||||
representation._metadata.collection_name = field_type_name; | |||||
if (calculate) { | if (calculate) { | ||||
representation.calculated_fields = Collection.pure._get_calculated_fields( | representation.calculated_fields = await Collection.pure._get_calculated_fields( | ||||
context, | context, | ||||
calculated_fields, | calculated_fields, | ||||
representation, | representation, | ||||
db_document, | db_document, | ||||
calculate | calculate | ||||
); | ); | ||||
} | } | ||||
return Promise.props(representation); | return representation; | ||||
}, | }, | ||||
check_if_action_is_allowed: function( | check_if_action_is_allowed: function( | ||||
access_strategy_map, | access_strategy_map, | ||||
context, | context, | ||||
action_name, | action_name, | ||||
resource_representation | resource_representation | ||||
) { | ) { | ||||
const access_strategy = Collection.pure.get_access_strategy( | const access_strategy = Collection.pure.get_access_strategy( | ||||
▲ Show 20 Lines • Show All 190 Lines • Show Last 20 Lines |