Changeset View
Changeset View
Standalone View
Standalone View
lib/subject/subject-types/single-resource-subject.js
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | .then(function(resource_data) { | ||||
resource_representation | resource_representation | ||||
); | ); | ||||
}) | }) | ||||
.then(function() { | .then(function() { | ||||
return collection.validate_field_values( | return collection.validate_field_values( | ||||
context, | context, | ||||
delete_empty_values, | delete_empty_values, | ||||
values_to_patch, | values_to_patch, | ||||
resource_representation.body | resource_representation | ||||
); | ); | ||||
}) | }) | ||||
.then(function() { | .then(function() { | ||||
return collection.encode_field_values( | return collection.encode_field_values( | ||||
context, | context, | ||||
values_to_patch, | values_to_patch, | ||||
resource_representation.body | resource_representation | ||||
); | ); | ||||
}) | }) | ||||
.then(function(encoded_values) { | .then(function(encoded_values) { | ||||
const query = {}; | const query = { _metadata: resource_representation._metadata }; | ||||
query.last_modified_context = context; | query._metadata.last_modified_context = context; | ||||
for (const field_name in encoded_values) { | for (const field_name in encoded_values) { | ||||
query[`body.${field_name}`] = encoded_values[field_name]; | query[field_name] = encoded_values[field_name]; | ||||
} | } | ||||
return datastore.update( | return datastore.update( | ||||
collection.name, | collection.name, | ||||
{ sealious_id: resource_id }, | { sealious_id: resource_id }, | ||||
{ $set: query } | { $set: query } | ||||
); | ); | ||||
}) | }) | ||||
.then(function(patch_result) { | .then(function(patch_result) { | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |