Last active
February 9, 2024 21:29
-
-
Save kendrelaxman/dbcd033f568892ef70ea36e3e1b9aac3 to your computer and use it in GitHub Desktop.
build dynamic schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: please restart the page if syntax highlighting works bad. | |
let el = document.querySelector('#header') | |
let msg: string = 'Hi friend, try edit me!' | |
el.innerHTML = msg | |
console.log('it shows results as you type') | |
class ExampleA{ | |
private records ={ | |
age: 18, | |
occupation: 'salaried', | |
job: 'jpmc' | |
}; | |
private cachedRecods = null; | |
private schema = { | |
schemaName: 'Omon', | |
options: | |
{ | |
topicName : 'sec', | |
Fields:[ | |
{ | |
getKey: 'age', | |
displayKey: 'myage', | |
}, | |
{ | |
getKey: 'occupation', | |
displayKey: 'myoccupation', | |
}, | |
{ | |
getKey: 'job', | |
displayKey: 'myhomejob', | |
isPrimary:true, | |
formatter:(el) =>{ | |
return ['unique','age', 'job'] | |
} | |
} | |
] | |
} | |
} | |
constructor(){ | |
this.setRecords(); | |
} | |
private setRecords(){ | |
const rec = this.records; | |
let payload = {}; | |
this.schema.options.Fields.map(element =>{ | |
if(element.formatter){ | |
const retValue = element.formatter(element); | |
console.log(retValue[1]) | |
payload[retValue[0]] = `${rec[retValue[1]]}` + `${rec[retValue[2]]}` | |
} | |
else { | |
payload[element.displayKey] = rec[element.getKey] | |
} | |
}) | |
console.log(payload); | |
} | |
} | |
const instance = new ExampleA(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git rev-list --all | xargs -n1 git ls-tree --full-name -r --name-only | grep "your_filename"