payload icon indicating copy to clipboard operation
payload copied to clipboard

payload.db.beginTransaction() not available in payload cloud

Open carstenblt opened this issue 10 months ago • 3 comments

Link to reproduction

No response

Describe the Bug

Calling beginTransaction() works well on a local dev server, however fails on payload cloud with

payload_1.default.db.beginTransaction is not a function

To Reproduce

E.g.

const transaction = await payload.db.beginTransaction();
await payload.create(...);
await payload.update(...);
await payload.db.commitTransaction(transaction);

Payload Version

2.11.2

Adapters and Plugins

No response

carstenblt avatar Apr 01 '24 18:04 carstenblt

Can you provide your payload config, especially the db adapter section for troubleshooting?

denolfe avatar Apr 02 '24 20:04 denolfe

Sure, here it is, hopefully without anything relevant left out:

import path from "path";

import { payloadCloud } from "@payloadcms/plugin-cloud";
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { webpackBundler } from "@payloadcms/bundler-webpack";
import { lexicalEditor } from "@payloadcms/richtext-lexical";
import seoPlugin from "@payloadcms/plugin-seo";
import { buildConfig } from "payload/config";

import { Icon } from "./payload-components/Icon";

import Users from "./collections/Users";
import { Logo } from "./payload-components/Logo";

import { Config } from "./payload-types";

declare module "payload" {
  export interface GeneratedTypes extends Config {}
}

export default buildConfig({
  cors: [
    "xxx",
  ],
  csrf: [
    "xxx",
  ],
  admin: {
    user: Users.slug,
    bundler: webpackBundler(),
    meta: {
      titleSuffix: "- xxx",
      favicon: "/assets/icon.svg",
      ogImage: "/assets/icon.svg",
    },
    components: {
      graphics: {
        Icon,
        Logo,
      },
    },
    livePreview: {
      breakpoints: [
        ...
      ],
    },
  },
  editor: lexicalEditor({}),
  localization: {
    locales: ["de", "en"],
    defaultLocale: "de",
    fallback: true,
  },
  collections: [
    xxx
  ],
  globals: [xxx],
  plugins: [
    payloadCloud(),
    seoPlugin({
      collections: ["xxx"],
      tabbedUI: true,
      fieldOverrides: {
        title: {
          localized: true,
        },
        description: {
          localized: true,
        },
      },
    }),
  ],
  serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL,
  db: mongooseAdapter({
    url: process.env.DATABASE_URI,
  }),
});

carstenblt avatar Apr 02 '24 21:04 carstenblt

I don't see anything in particular that would cause this type of issue. You could try upgrading to 2.14.2 to see if you still get this error.

denolfe avatar Apr 29 '24 14:04 denolfe

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 07 '24 04:09 github-actions[bot]