autoblogger 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1328,7 +1328,21 @@ function createPostsData(prisma, hooks) {
|
|
|
1328
1328
|
return result;
|
|
1329
1329
|
},
|
|
1330
1330
|
async update(id, data) {
|
|
1331
|
-
const {
|
|
1331
|
+
const {
|
|
1332
|
+
tagIds,
|
|
1333
|
+
tags,
|
|
1334
|
+
revisions,
|
|
1335
|
+
topic,
|
|
1336
|
+
topicId,
|
|
1337
|
+
// Handle separately as relation
|
|
1338
|
+
id: _id,
|
|
1339
|
+
// Don't update the ID
|
|
1340
|
+
createdAt: _createdAt,
|
|
1341
|
+
// Don't update createdAt
|
|
1342
|
+
wordCount: _wordCount,
|
|
1343
|
+
// Computed field, don't save
|
|
1344
|
+
...postData
|
|
1345
|
+
} = data;
|
|
1332
1346
|
if (postData.status === "published") {
|
|
1333
1347
|
const existing = await prisma.post.findUnique({ where: { id } });
|
|
1334
1348
|
if (existing?.status !== "published") {
|
|
@@ -1341,9 +1355,13 @@ function createPostsData(prisma, hooks) {
|
|
|
1341
1355
|
if (postData.slug) {
|
|
1342
1356
|
postData.slug = await generateUniqueSlug(prisma, postData.slug, id);
|
|
1343
1357
|
}
|
|
1358
|
+
const updatePayload = { ...postData };
|
|
1359
|
+
if (topicId !== void 0) {
|
|
1360
|
+
updatePayload.topic = topicId ? { connect: { id: topicId } } : { disconnect: true };
|
|
1361
|
+
}
|
|
1344
1362
|
const post = await prisma.post.update({
|
|
1345
1363
|
where: { id },
|
|
1346
|
-
data:
|
|
1364
|
+
data: updatePayload
|
|
1347
1365
|
});
|
|
1348
1366
|
if (tagIds !== void 0) {
|
|
1349
1367
|
await prisma.postTag.deleteMany({ where: { postId: id } });
|