mirror of
/repos/Prototyper.git
synced 2026-02-27 16:12:00 +01:00
added mongoData tests
This commit is contained in:
@@ -12,7 +12,7 @@ module.exports = function (config, db, shareModel) {
|
||||
function getMongoContent(options, callback) {
|
||||
config.debug && config.debug('getMongoContent options', options);
|
||||
if (!options.collection) {
|
||||
return callback(new Error('Data not found / missing collection'));
|
||||
return callback && callback(new Error('Data not found / missing collection'));
|
||||
}
|
||||
return db.collection(options.collection, function collection(err, col) {
|
||||
if (err) {
|
||||
@@ -20,7 +20,7 @@ module.exports = function (config, db, shareModel) {
|
||||
return callback && callback(err);
|
||||
}
|
||||
if (!options.query) {
|
||||
return callback && callback(new Error('Data not found ' + options.collection + '/ missing query'), null, col);
|
||||
return callback && callback(new Error('Data not found ' + options.collection + ' / missing query'), null, col);
|
||||
}
|
||||
if (options.query._id && !(options.query._id instanceof Object)) {
|
||||
try {
|
||||
@@ -52,11 +52,14 @@ module.exports = function (config, db, shareModel) {
|
||||
*/
|
||||
function getMongoAttribute(options, callback) {
|
||||
config.debug && config.debug('getMongoAttribute options', options);
|
||||
return getMongoContent(options, function document(err, result) {
|
||||
return getMongoContent(options, function document(err, result, col) {
|
||||
if (err) {
|
||||
config.error && config.error('ERR1 getMongoAttribute', err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
if (!options.attribute) {
|
||||
return callback && callback(new Error('Data not found / ' + options.collection + '/' + JSON.stringify(options.query) + ' missing attribute', null, col));
|
||||
}
|
||||
var attribute_options = null;
|
||||
config.debug && config.debug('getMongoAttribute result', result);
|
||||
if (result &&
|
||||
@@ -68,13 +71,13 @@ module.exports = function (config, db, shareModel) {
|
||||
};
|
||||
config.debug && config.debug('getMongoAttribute attribute_options', attribute_options);
|
||||
|
||||
getMongoContent(attribute_options, function attribute(err, attribute_result) {
|
||||
getMongoContent(attribute_options, function attribute(err, attribute_result, coll) {
|
||||
if (err) {
|
||||
config.error && config.error('ERR2 getMongoAttribute', err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
config.debug && config.debug('getMongoAttribute attribute_result', attribute_result);
|
||||
return callback && callback(err, attribute_result);
|
||||
return callback && callback(err, attribute_result, coll);
|
||||
});
|
||||
} else {
|
||||
config.debug && config.debug('getMongoAttribute try direct lookup');
|
||||
@@ -87,13 +90,13 @@ module.exports = function (config, db, shareModel) {
|
||||
};
|
||||
config.debug && config.debug('getMongoAttribute attribute_options', attribute_options);
|
||||
|
||||
return getMongoContent(attribute_options, function attribute(err, attribute_result) {
|
||||
return getMongoContent(attribute_options, function attribute(err, attribute_result, coll) {
|
||||
if (err) {
|
||||
config.error && config.error('ERR getMongoAttribute', err);
|
||||
return callback && callback(err);
|
||||
}
|
||||
config.debug && config.debug('getMongoAttribute direct attribute_result', attribute_result);
|
||||
return callback && callback(err, attribute_result);
|
||||
return callback && callback(err, attribute_result, coll);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -334,7 +337,7 @@ module.exports = function (config, db, shareModel) {
|
||||
|
||||
|
||||
/* options:
|
||||
* no_share (optional): prevent share to update itself.
|
||||
* no_share (optional): prevent share from updating itself.
|
||||
*/
|
||||
function setMongoAttribute(data, options, callback) {
|
||||
config.debug && config.debug('setMongoAttribute options', options);
|
||||
|
||||
Reference in New Issue
Block a user