Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars-Erik Roald committed Dec 20, 2023
1 parent bfc10e7 commit 34e5a09
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/client/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5481,6 +5481,8 @@ function rdbClient(options = {}) {
getOne,
getById,
proxify,
update,
updateChanges,
insert,
insertAndForget,
delete: _delete,
Expand Down Expand Up @@ -5586,6 +5588,41 @@ function rdbClient(options = {}) {
return adapter.post(body);
}

async function update(rows, ...rest) {
const concurrency = undefined;
const args = [concurrency].concat(rest);
if (Array.isArray(rows)) {
const proxy = await getMany.apply(null, [rows, ...rest]);
proxy.splice.apply(proxy, [0, proxy.length, ...rows]);
await proxy.saveChanges.apply(proxy, args);
return proxy;
}
else {
const proxy = await getMany.apply(null, [[rows], ...rest]);
proxy.splice.apply(proxy, [0, 1, rows]);
await proxy.saveChanges.apply(proxy, args);
return proxify(proxy[0], args[0]);
}
}

async function updateChanges(rows, oldRows, ...rest) {
const concurrency = undefined;
const args = [concurrency].concat(rest);
if (Array.isArray(rows)) {
//todo
const proxy = await getMany.apply(null, [rows, ...rest]);
proxy.splice.apply(proxy, [0, proxy.length, ...rows]);
await proxy.saveChanges.apply(proxy, args);
return proxy;
}
else {
let proxy = proxify([oldRows], args[0]);
proxy.splice.apply(proxy, [0, 1, rows]);
await proxy.saveChanges.apply(proxy, args);
return proxify(proxy[0], args[0]);
}
}

async function insert(rows, ...rest) {
const concurrency = undefined;
const args = [concurrency].concat(rest);
Expand Down

0 comments on commit 34e5a09

Please sign in to comment.