Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
import { jobsCollectionSlug } from '../queues/config/collection.js';
|
|
export const defaultUpdateJobs = async function updateMany({ id, data, limit, req, returning, where }) {
|
|
const updatedJobs = [];
|
|
const jobsToUpdate = (id ? [
|
|
await this.findOne({
|
|
collection: jobsCollectionSlug,
|
|
req,
|
|
where: {
|
|
id: {
|
|
equals: id
|
|
}
|
|
}
|
|
})
|
|
] : (await this.find({
|
|
collection: jobsCollectionSlug,
|
|
limit,
|
|
pagination: false,
|
|
req,
|
|
where
|
|
})).docs).filter(Boolean);
|
|
if (!jobsToUpdate) {
|
|
return null;
|
|
}
|
|
for (const job of jobsToUpdate){
|
|
const updateData = {
|
|
...job,
|
|
...data
|
|
};
|
|
const updatedJob = await this.updateOne({
|
|
id: job.id,
|
|
collection: jobsCollectionSlug,
|
|
data: updateData,
|
|
req,
|
|
returning
|
|
});
|
|
updatedJobs.push(updatedJob);
|
|
}
|
|
return updatedJobs;
|
|
};
|
|
|
|
//# sourceMappingURL=defaultUpdateJobs.js.map |