Skip to content

Commit cb6eae7

Browse files
Merge pull request #2795 from Shopify/update-session-storage-readmes
Update session storage Readmes
2 parents 5c0e626 + 9c9eddc commit cb6eae7

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

  • packages/apps/session-storage

packages/apps/session-storage/shopify-app-session-storage-mongodb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ const shopify = shopifyApp({
2727
});
2828
```
2929

30-
If you prefer to use your own implementation of a session storage mechanism that is compatible with the `@shopify/shopify-app-express` package, see the [implementing session storage guide](../shopify-app-session-storage/implementing-session-storage.md).
30+
If you prefer to use your own implementation of a session storage mechanism that uses the `SessionStorage` interface, see the [implementing session storage guide](../shopify-app-session-storage/implementing-session-storage.md).

packages/apps/session-storage/shopify-app-session-storage-prisma/README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,38 @@ Here are some possible solutions for this issue:
103103
1. Ensure you've copied the schema above into your `prisma.schema` file.
104104
1. If you've made changes to the table, make sure it's still called `Session`.
105105

106-
### Error: The "mongodb" provider is not supported with this command
106+
### MongoDB
107107

108-
MongoDB does not support the [prisma migrate](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/overview) command. If you are using MongoDB please see the [Prisma documentation](https://www.prisma.io/docs/orm/overview/databases/mongodb) for configuring your database.
108+
If you choose to use MongoDB with prisma, MongoDB support in Prisma has some gotchas that you should be aware of.
109+
110+
Alternatively you can use a MongoDB database directly with the [MongoDB session storage adapter](https://www.npmjs.com/package/@shopify/shopify-app-session-storage-mongodb).
111+
112+
#### Mapping the id field
113+
114+
In MongoDB, an ID must be a single field that defines an `@id` attribute and a `@map("\_id")` attribute. The prisma adapter expects the ID field to be the ID of the session, and not the \_id field of the document.
115+
116+
You'll need to make some modifications to the schema and prisma configuration. For more information please see the [Prisma MongoDB documentation](https://www.prisma.io/docs/orm/overview/databases/mongodb).
117+
118+
To make this work add a new field to the schema that maps the \_id field to the id field. For more information see the [Prisma documentation](https://www.prisma.io/docs/orm/prisma-schema/data-model/models#defining-an-id-field)
119+
120+
```prisma
121+
model Session {
122+
session_id String @id @default(auto()) @map("_id") @db.ObjectId
123+
id String @unique
124+
...
125+
}
126+
```
127+
128+
#### Error: The "mongodb" provider is not supported with this command
129+
130+
MongoDB does not support the [prisma migrate](https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/overview) command. Instead, you can use the [prisma db push](https://www.prisma.io/docs/orm/reference/prisma-cli-reference#db-push) command and update the `shopify.web.toml` file with the following commands. If you are using MongoDB please see the [Prisma documentation](https://www.prisma.io/docs/orm/overview/databases/mongodb) for more information.
131+
132+
```toml
133+
[commands]
134+
predev = "npx prisma generate && npx prisma db push"
135+
dev = "npx prisma migrate deploy && npm exec react-router dev"
136+
```
137+
138+
#### Prisma needs to perform transactions, which requires your mongodb server to be run as a replica set
139+
140+
See the [Prisma documentation](https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/mongodb/connect-your-database-node-mongodb) for connecting to a MongoDB database.

0 commit comments

Comments
 (0)