Skip to content

Commit

Permalink
fix: seeder trying to call typesense before schema exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarendorff committed Nov 25, 2023
1 parent a94fb21 commit 4358b9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/cms/src/collections/groupchats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export const Groupchats: CollectionConfig = {
],
hooks: {
afterChange: [
async ({ doc }) => {
async ({ doc, context }) => {
if ('dataseeder' in context && context.dataseeder) return;

const typesenseDoc = {
...doc,
keywords: doc.keywords.map((k) => k.value),
Expand Down
4 changes: 2 additions & 2 deletions packages/cms/src/dataseeder/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export const upsert = async <T extends CollectionKey>(
if (totalDocs > 1) throw new Error("Key is not unique");
if (totalDocs === 1) {
const id = docs[0].id;
await payload.update({ id, ...options });
await payload.update({ id, ...options, context: { dataseeder: true } });
console.info(`${collection}: Updated ${keyValue}`);
} else {
await payload.create({ ...options });
await payload.create({ ...options, context: { dataseeder: true } });
console.info(`${collection}: Created ${keyValue}`);
}
};

0 comments on commit 4358b9d

Please sign in to comment.