You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: usage/tools/cloudcode.mdx
+8-10Lines changed: 8 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,29 +184,27 @@ The body of the request payload should look like this:
184
184
}
185
185
```
186
186
187
-
The `op` refers to the type of operation recorded by the PowerSync client SDK (`PUT`, `PATCH` or `DELETE`). Refer to [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for details.
187
+
*`batch` should be an array of operations from the PowerSync client SDK.
188
+
*`op` refers to the type of each operation recorded by the PowerSync client SDK (`PUT`, `PATCH` or `DELETE`). Refer to [Writing Client Changes](/installation/app-backend-setup/writing-client-changes) for details.
188
189
189
190
The API will respond with HTTP status `200` if the write was successful.
190
191
191
192
192
-
## Customization required
193
+
## Customization
193
194
194
-
You can make changes to the way the `upload` task writes data to the source MongoDB database. At a minimum, at this time you will need to modify it to take your specific MongoDB database "schema" into consideration (Note: We are working on updating the template to not require adapting it to your schema. We will update this documentation page accordingly once that change is shipped).
195
+
You can make changes to the way the `upload` task writes data to the source MongoDB database.
195
196
196
197
Here is how:
197
198
198
-
1.Open the**CloudCode**section at the top of the IDE.
199
+
1.Go to**CloudCode** at the top of the IDE in your JourneyApps Platform project
199
200
2. Select and expand the `upload` task in the panel on the left.
200
-
3. The `index.ts` contains the entry point function that accepts the HTTP request and has a `MongoDBStorage` class which interacts with the MongoDB database to perform inserts, updates and deletes. To adjust how updates are performed take a look at the `updateBatch` function.
201
+
3. The `index.ts` contains the entry point function that accepts the HTTP request and has a `MongoDBStorage` class which interacts with the MongoDB database to perform inserts, updates and deletes. To adjust how updates are performed, take a look at the `updateBatch` function.
201
202
202
203
## Production considerations
203
204
204
205
Before going into production with this solution, you will need to set up authentication on the HTTP endpoints exposed by the CloudCode tasks.
205
206
206
-
If you need more data validations and/or authorization than what is provided by the template, that will need to be customized too.
207
+
If you need more data validations and/or authorization than what is provided by the template, that will need to be customized too. Consider introducing schema validation of the data being written to the source MongoDB database. You should use a [purpose-built](https://json-schema.org/tools?query=&sortBy=name&sortOrder=ascending&groupBy=toolingTypes&licenses=&languages=&drafts=&toolingTypes=&environments=&showObsolete=false) library for this, and use [MongoDB Schema Validation](https://www.mongodb.com/docs/manual/core/schema-validation/) to enforce the types in the database.
207
208
208
-
For production applications you would also want to consider introducing schema validation of the data being written to the source MongoDB database.
209
-
You should use a [purpose-built](https://json-schema.org/tools?query=&sortBy=name&sortOrder=ascending&groupBy=toolingTypes&licenses=&languages=&drafts=&toolingTypes=&environments=&showObsolete=false) library for this, and use MongoDB Schema Validation to enforce the types in the database.
210
-
211
-
Please [contact us](/resources/contact-us) for assistance on either of the above.
209
+
Please [contact us](/resources/contact-us) for assistance on any of the above.
0 commit comments