new(basic.gblib): TABLE keyword #375.
This commit is contained in:
parent
0012fd0f89
commit
1a3a6e0d01
2 changed files with 31 additions and 2 deletions
|
@ -1003,7 +1003,7 @@ export class KeywordsExpressions {
|
||||||
$4 = $4.substr(2);
|
$4 = $4.substr(2);
|
||||||
const fields = $4.split(',').
|
const fields = $4.split(',').
|
||||||
|
|
||||||
return `await sys.save({pid: pid, file: "${$3}", args: [${$4}]}, fields)`;
|
return `await sys.saveToStorage({pid: pid, file: "${$3}", args: [${$4}]}, fields)`;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -640,13 +640,42 @@ export class SystemKeywords {
|
||||||
/**
|
/**
|
||||||
* Takes note inside a notes.xlsx of .gbdata.
|
* Takes note inside a notes.xlsx of .gbdata.
|
||||||
*
|
*
|
||||||
* @exaple NOTE "text"
|
* @example NOTE "text"
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async note({ pid, text }): Promise<any> {
|
public async note({ pid, text }): Promise<any> {
|
||||||
await this.save({pid, file:"Notes.xlsx", args:[text]} );
|
await this.save({pid, file:"Notes.xlsx", args:[text]} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves variables to storage, not a worksheet.
|
||||||
|
*
|
||||||
|
* @example SAVE "Billing", columnName1, columnName2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async saveToStorage({pid, table, fields, fieldsNames}){
|
||||||
|
|
||||||
|
const fieldRegExp = /(?:.*\.)(.*)/gim;
|
||||||
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
|
const definition = minBoot.core.sequelize.models[table];
|
||||||
|
|
||||||
|
let data = {};
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
fields.forEach(field => {
|
||||||
|
|
||||||
|
// Extracts only the last part of the variable like 'column'
|
||||||
|
// from 'row.column'.
|
||||||
|
|
||||||
|
let name = fieldsNames[index];
|
||||||
|
name = fieldRegExp.exec(name)[2];
|
||||||
|
|
||||||
|
data[name] = field;
|
||||||
|
});
|
||||||
|
|
||||||
|
return await definition.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the content of several variables to a new row in a tabular file.
|
* Saves the content of several variables to a new row in a tabular file.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue