Better Sandbox API

This commit is contained in:
nkaputnik
2022-07-28 14:54:08 +02:00
parent 9c2a7598f2
commit 44880c7745
3 changed files with 7 additions and 17 deletions

View File

@@ -8,6 +8,8 @@ async function run() {
let res = await SELECT.one`title`.from(`Books`).where(`ID=201`) let res = await SELECT.one`title`.from(`Books`).where(`ID=201`)
let { title } = res let { title } = res
let Author = req.data let Author = req.data
//await srv.read('Books')
Author.modifiedBy = "Custom Event handler changed this!" Author.modifiedBy = "Custom Event handler changed this!"
Author.placeOfDeath = " --- Somewhere over " + title + " --- create in Sandbox" Author.placeOfDeath = " --- Somewhere over " + title + " --- create in Sandbox"
//await this.emit("createdAuthor", { Author }) //await this.emit("createdAuthor", { Author })

View File

@@ -1,17 +1,5 @@
using from '..\admin-service'; using from '..\admin-service';
annotate entity AdminService.Authors with @extension.logic.insert : "async function run() {
//debugger annotate AdminService.Authors with @extension.logic: [{when: 'CREATE', code: 'async function run() {\r\n \/\/debugger\r\n \/\/while (true) {}\r\n \/\/process.exit()\r\n \/\/1.substring()\r\n \/\/ let res = await specialselect\r\n let res = await SELECT.one`title`.from(`Books`).where(`ID=201`)\r\n let { title } = res\r\n let Author = req.data\r\n Author.modifiedBy = \"Custom Event handler changed this!\"\r\n Author.placeOfDeath = \" --- Somewhere over \" + title + \" --- create in Sandbox\"\r\n \/\/await this.emit(\"createdAuthor\", { Author })\r\n return Author\r\n}\r\nrun()\r\n'},
//while (true) {} {when: 'READ', code: 'function getYear(v) {\r\n return parseInt(v.substr(0, 4))\r\n}\r\nfunction getMonth(v) {\r\n return parseInt(v.substr(5, 2))\r\n}\r\nfunction getDay(v) {\r\n return parseInt(v.substr(8, 2))\r\n}\r\n\r\nfunction getAge(from, to) {\r\n if (from === undefined || from == null) return 0\r\n if (to === undefined || to == null) to = new Date().toISOString()\r\n let year = getYear(to) - getYear(from) - 1\r\n if (\r\n getMonth(to) > getMonth(from) ||\r\n (getMonth(to) === getMonth(from) && getDay(to) >= getDay(from))\r\n ) {\r\n year++\r\n }\r\n return year\r\n}\r\n\r\nconst result_ = Array.isArray(result) ? result : [result]\r\nfor (const row of result_) {\r\n row.modifiedBy += \" --- read in sandbox\"\r\n row.age = getAge(row.dateOfBirth, row.dateOfDeath)\r\n}'}
//process.exit() ];
//1.substring()
// let res = await specialselect
let res = await SELECT.one`title`.from(`Books`).where(`ID=201`)
let { title } = res
let Author = req.data
Author.modifiedBy = "Custom Event handler changed this!"
Author.placeOfDeath = " --- Somewhere over " + title + " --- create in Sandbox"
//await this.emit("createdAuthor", { Author })
return Author
}
run()
"

View File

@@ -1,6 +1,6 @@
@server = http://localhost:4004 @server = http://localhost:4004
@me = Authorization: Basic {{$processEnv USER}}: @me = Authorization: Basic {{$processEnv USER}}:
@id = 1113 @id = 2000
### ------------------------------------------------------------------------ ### ------------------------------------------------------------------------