const insertQuery = this.ctDb
.insert(someTable)
.values(opts)
.getSQL();
insertQuery.append(sql` RETURNING *`);
const execResult = await this.ctDb.execute(insertQuery);
const resultList = execResult[0] as any;
const result = resultList[0] as any;
// For creating this entity I would like to use the mapper
const entity = {
id: result.id,
systemName: result.system_name,
};
/*
Exec result looks like this:
[
[
{
id: 96,
system_name: 'test-24533',
}
],
[
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`system_name` VARCHAR(20) NOT NULL UNIQUE_KEY,
]
]
*/
const insertQuery = this.ctDb
.insert(someTable)
.values(opts)
.getSQL();
insertQuery.append(sql` RETURNING *`);
const execResult = await this.ctDb.execute(insertQuery);
const resultList = execResult[0] as any;
const result = resultList[0] as any;
// For creating this entity I would like to use the mapper
const entity = {
id: result.id,
systemName: result.system_name,
};
/*
Exec result looks like this:
[
[
{
id: 96,
system_name: 'test-24533',
}
],
[
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
`system_name` VARCHAR(20) NOT NULL UNIQUE_KEY,
]
]
*/