save shop data in mongodb with prisma

Topic summary

A developer is trying to save Shopify shop data (retrieved from the REST API’s shop.json endpoint) into MongoDB using Prisma during app installation. While session data saves successfully, shop details are not being stored.

Current Setup:

  • Using Remix framework
  • Prisma schema includes two models: Session (storing authentication data) and Shop (designed to store shop details like domain, name, email, country, currency, plan, etc.)
  • MongoDB as the database

Solution Provided:
Use Shopify’s afterAuth hook, which triggers after merchant installation. Within this hook:

  • Retrieve shop data via GraphQL or REST API
  • Save the data to MongoDB using the existing Prisma schema

Status: Issue resolved with guidance pointing to Shopify’s documentation for the afterAuth hook implementation.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

i want to save shop data which we get by shopify rest api shop.json in mongodb while installing the app my session is saved in db bu shop details is not saved. this is my schema.prisma

generator client {
provider = “prisma-client-js”
}

datasource db {
provider = “mongodb”
url = env(“DATABASE_URL”)
}

model Session {
session_id String @Id @Default (auto()) @MAP (“_id”) @db .ObjectId
id String @Unique_2
shop String @Unique_2
state String
isOnline Boolean @Default (false)
scope String?
expires DateTime?
accessToken String
userId BigInt?
firstName String?
lastName String?
email String?
accountOwner Boolean @Default (false)
locale String?
collaborator Boolean? @Default (false)
emailVerified Boolean? @Default (false)
}

model Shop {
id String @Id @Default (auto()) @MAP (“_id”) @db .ObjectId
myshopify_domain String @Unique_2
shop_id BigInt @Unique_2
name String
email String?
country String
currency String
plan_name String
shop_owner String
timezone String
primary_locale String
accessToken String?
}

how will i able to also save shop data in my db while installing the app. anyone help me with the code.(i m using remix)

Hi, @damonrcr , Shopify provides a hook called “afterAuth” that triggers after merchants install your app. To save the shop data in MongoDB, you can retrieve it via GraphQL or Rest API in the “afterAuth” hook and then save it in your db. For more information, please read this: https://shopify.dev/docs/api/shopify-app-remix/v3/entrypoints/shopifyapp

1 Like

thank you so much for your support @B2Bridge