mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
store parsed category description removed mongo _key from returns dont get category teaser for parent
37 lines
722 B
JavaScript
37 lines
722 B
JavaScript
"use strict";
|
|
|
|
var helpers = {};
|
|
|
|
helpers.toMap = function(data) {
|
|
var map = {};
|
|
for (var i = 0; i<data.length; ++i) {
|
|
map[data[i]._key] = data[i];
|
|
data[i]._key = undefined;
|
|
}
|
|
return map;
|
|
};
|
|
|
|
helpers.fieldToString = function(field) {
|
|
if(field === null || field === undefined) {
|
|
return field;
|
|
}
|
|
|
|
if(typeof field !== 'string') {
|
|
field = field.toString();
|
|
}
|
|
// if there is a '.' in the field name it inserts subdocument in mongo, replace '.'s with \uff0E
|
|
field = field.replace(/\./g, '\uff0E');
|
|
return field;
|
|
};
|
|
|
|
helpers.valueToString = function(value) {
|
|
if(value === null || value === undefined) {
|
|
return value;
|
|
}
|
|
|
|
return value.toString();
|
|
};
|
|
|
|
helpers.noop = function() {};
|
|
|
|
module.exports = helpers; |