Skip to content

Instantly share code, notes, and snippets.

@kendrelaxman
Last active February 9, 2024 21:29
Show Gist options
  • Save kendrelaxman/dbcd033f568892ef70ea36e3e1b9aac3 to your computer and use it in GitHub Desktop.
Save kendrelaxman/dbcd033f568892ef70ea36e3e1b9aac3 to your computer and use it in GitHub Desktop.
build dynamic schema
// 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();
@kendrelaxman
Copy link
Author

git rev-list --all | xargs -n1 git ls-tree --full-name -r --name-only | grep "your_filename"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment