MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / prepareData

Function prepareData

web/pgadmin/static/js/SchemaView/common.js:91–113  ·  view source on GitHub ↗
(val, createMode=false)

Source from the content-addressed store, hash-verified

89}
90
91export function prepareData(val, createMode=false) {
92 if(_.isPlainObject(val)) {
93 _.forIn(val, function (el) {
94 if (_.isObject(el)) {
95 prepareData(el, createMode);
96 }
97 });
98 } else if(_.isArray(val)) {
99 val.forEach(function(el) {
100 if (_.isPlainObject(el)) {
101 /* The each row in collection need to have an id to identify them uniquely
102 This helps in easily getting what has changed */
103 /* Nested collection rows may or may not have idAttribute.
104 So to decide whether row is new or not set, the cid starts with
105 nn (not new) for existing rows. Newly added will start with 'c' (created)
106 */
107 el['cid'] = createMode ? _.uniqueId('c') : _.uniqueId('nn');
108 prepareData(el, createMode);
109 }
110 });
111 }
112 return val;
113}
114
115export const flatternObject = (obj, base=[]) => Object.keys(obj).sort((a, b)=>a.localeCompare(b)).reduce(
116 (r, k) => {

Callers 3

TableFunction · 0.90
initialiseMethod · 0.90
useSchemaStateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected