Change updated_at and created_at preference. Insert data can override them.

This commit is contained in:
Benjamin Toby 2026-04-19 11:10:41 +01:00
parent 95d567d4dd
commit 47f85d8343
5 changed files with 5 additions and 5 deletions

View File

@ -5,9 +5,9 @@ export default async function DbInsert({ table, data, update_on_duplicate, }) {
let sqlObj = null;
try {
const finalData = data.map((d) => ({
...d,
created_at: Date.now(),
updated_at: Date.now(),
...d,
}));
sqlObj =
sqlInsertGenerator({

View File

@ -23,8 +23,8 @@ export default async function DbUpdate({ table, data, query, targetId, }) {
if (whereClause) {
let sql = `UPDATE ${table} SET`;
const finalData = {
...data,
updated_at: Date.now(),
...data,
};
const keys = Object.keys(finalData);
for (let i = 0; i < keys.length; i++) {

View File

@ -1,6 +1,6 @@
{
"name": "@moduletrace/bun-sqlite",
"version": "1.1.7",
"version": "1.1.8",
"description": "SQLite manager for Bun",
"author": "Benjamin Toby",
"main": "dist/index.js",

View File

@ -24,9 +24,9 @@ export default async function DbInsert<
try {
const finalData: { [k: string]: any }[] = data.map((d) => ({
...d,
created_at: Date.now(),
updated_at: Date.now(),
...d,
}));
sqlObj =

View File

@ -57,8 +57,8 @@ export default async function DbUpdate<
let sql = `UPDATE ${table} SET`;
const finalData: { [k: string]: SQLInsertGenValueType } = {
...data,
updated_at: Date.now(),
...data,
};
const keys = Object.keys(finalData);