MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / _generateId

Function _generateId

services/cloudObjects.js:784–823  ·  view source on GitHub ↗
(document, reqType)

Source from the content-addressed store, hash-verified

782}
783
784function _generateId(document, reqType) {
785 try {
786 if (document._type) {
787 if (!document._id) {
788 let id;
789 if (document._hash) {
790 id = document._hash;
791 delete document._hash;
792 } else id = util.getId();
793 document._id = id;
794 reqType.save.push(id);
795 } else {
796 reqType.update.push(document._id);
797 }
798 }
799 for (const key in document) {
800 if (document[key]) {
801 if (document[key].constructor === Array && document[key].length) {
802 for (let i = 0; i < document[key].length; i++) {
803 if (document[key][i]._tableName) {
804 _generateId(document[key][i], reqType);
805 }
806 }
807 }
808 if (typeof document[key] === 'object' && document[key] != null) {
809 if (document[key]._type) {
810 _generateId(document[key], reqType);
811 }
812 }
813 }
814 }
815 return document;
816 } catch (err) {
817 winston.log('error', {
818 error: String(err),
819 stack: new Error().stack,
820 });
821 return null;
822 }
823}
824
825function _getModifiedDocs(document, unModDoc) {
826 try {

Callers 2

saveFunction · 0.85
_saveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected