Search code examples
nestjstypeormprisma

TypeORM not getting data saved by Prisma


I started migration TypeORM (using Nest.js) to Prisma queries.

At some point I noticed that data saved with Prisma is not accessible by TypeORM.

After saving the data using this Prisma query:

await this.prisma.recipeFilter.create({
      include: { options: true },
      data: {
        label: options.label,
        schemaType: options.schemaType,
        store: { connect: { id: storeId } },
      },
    });

I cannot fetch it using TypeORM:

return this.recipeFilterRepository
      .createQueryBuilder('c')
      .where('c.store = :storeId', { storeId })
      .leftJoinAndMapMany('c.options', 'c.options', 'o')
      .loadRelationCountAndMap('c.publishedRecipesCount', 'o.recipes', 'r', (qb) => {
        return qb.andWhere('r.draft = false');
      })
      .getMany();

When I run the query that TypeORM generates in the database, I get results:

SELECT "c"."id" AS "c_id", "c"."createdAt" AS "c_createdAt", "c"."updatedAt" AS "c_updatedAt", "c"."label" AS "c_label", "c"."schemaType" AS "c_schemaType", "c"."storeId" AS "c_storeId", "o"."id" AS "o_id", "o"."createdAt" AS "o_createdAt", "o"."updatedAt" AS "o_updatedAt", "o"."name" AS "o_name", "o"."slug" AS "o_slug", "o"."filterId" AS "o_filterId" FROM "recipe_filter" "c" LEFT JOIN "recipe_filter_option" "o" ON "o"."filterId"="c"."id" WHERE "c"."storeId" = $1

Even after many minutes of waiting, the TypeORM query doesn't show results running inside the app, though.

What could be happening here?


Solution

  • As @Samathingamajig pointed out, it was indeed a different database!

    Wow. Just wow!