mirror of
https://github.com/Ratstail91/sineql-demo.git
synced 2026-05-05 23:30:11 +10:00
Fixed update handler
This commit is contained in:
@@ -97,6 +97,7 @@ const createBook = async (query, typeGraph) => {
|
||||
|
||||
const updateBookFields = (query) => {
|
||||
const final = [];
|
||||
let fields = [];
|
||||
|
||||
query.forEach((q) => {
|
||||
//the array of objects to update
|
||||
@@ -133,14 +134,15 @@ const updateBookFields = (query) => {
|
||||
;
|
||||
|
||||
final.push({ ...updates, ...where });
|
||||
fields = fields.concat(Object.keys(updates));
|
||||
});
|
||||
|
||||
return { updates: final, updateOnDuplicate: Object.keys(updates) };
|
||||
return { updates: final, updateOnDuplicate: fields };
|
||||
};
|
||||
|
||||
const updateBook = async (query, typeGraph) => {
|
||||
const { updates, ...opts } = updateBookFields(query);
|
||||
|
||||
console.log(opts)
|
||||
try {
|
||||
await Book.bulkCreate(
|
||||
updates,
|
||||
|
||||
Reference in New Issue
Block a user