Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ).result(
//
var fetch;
if (userSpec.contributorId) {
fetch = self.documents.read(
'com.marklogic.samplestack.domain.Contributor/' +
userSpec.contributorId +
'.json'
);
}
else {
fetch = self.documents.query(
qb.where(
qb.directory('com.marklogic.samplestack.domain.Contributor/'),
qb.value('userName', userSpec.uid)
)
);
}
fetch.result(
function (response) {
if (response.length !== 1) {
return reject({
error: 'cardinalityViolation',
userSpec: userSpec,
count: response.length
});
}
var obj = response[0].content[
Object.keys(response[0].content)[0]
];
// TODO: how do we handle this now?
return _.map(spec, function (property, name) {
return qb.value(name, property);
});
},