DB
This commit is contained in:
28
tests/base/case1-payload.js
Normal file
28
tests/base/case1-payload.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
async function insert() {
|
||||
const res = await asyncCall(
|
||||
db,
|
||||
squel.insert().into("testTable").set("col", "test me now").toString()
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function createSQL(id) {
|
||||
return squel.select().from("testTable").where("id = ?", id).toString();
|
||||
}
|
||||
|
||||
async function main(input) {
|
||||
const inserted = await insert();
|
||||
|
||||
log(inserted);
|
||||
|
||||
const sql = createSQL(inserted.rows.insertId);
|
||||
const res = await asyncCall(db, sql);
|
||||
|
||||
log(res.rows);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -1,14 +1,17 @@
|
||||
import createProject from "../functions/createProject";
|
||||
import createQuery from "../functions/createQuery";
|
||||
import runQuery from "../functions/runQuery";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const project = await createProject("Test Project");
|
||||
|
||||
const payloadPath = path.join(__dirname, "case1-payload.js");
|
||||
const query = await createQuery(
|
||||
project,
|
||||
"async function main(input) { return `Hello, ${input.name}!`; }"
|
||||
fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
||||
);
|
||||
|
||||
console.log(query);
|
||||
|
||||
Reference in New Issue
Block a user