|
7 | 7 | # the file licenses/APL2.txt. |
8 | 8 | parameters: |
9 | 9 | - $ref: ../../components/parameters.yaml#/keyspace |
10 | | -get: |
| 10 | +post: |
11 | 11 | summary: Run a doc body through the sync function and return sync data. |
12 | 12 | description: |- |
13 | | - Run a document body through the sync function and return document sync data. |
| 13 | + Runs a document body through the sync function and returns document sync |
| 14 | + data. If no custom sync function is provided in the request body, the |
| 15 | + default or user-defined sync function for the collection is used. |
| 16 | + | Document | DocID | Behaviour | |
| 17 | + | -------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 18 | + | Yes | No | The document passed will be considered as newDoc and oldDoc will be empty | |
| 19 | + | Yes | Yes | The document passed in the body will be newDoc and DocID will be read from the bucket/collection and will be passed as the oldDoc. If DocID doesn't exist, then oldDoc will be empty | |
| 20 | + | No | No | Will throw an error | |
| 21 | + | No | Yes | The docID will be passed in as the newDoc and oldDoc will be empty. If the document is not found, an error will be returned | |
| 22 | +
|
14 | 23 | * Sync Gateway Application Read Only |
15 | 24 | requestBody: |
16 | 25 | content: |
17 | 26 | application/json: |
18 | 27 | schema: |
19 | | - $ref: ../../components/schemas.yaml#/Document |
| 28 | + type: object |
| 29 | + properties: |
| 30 | + sync_function: |
| 31 | + description: |- |
| 32 | + A JavaScript function that defines custom access, channel, and |
| 33 | + validation logic for documents. This function will be evaluated |
| 34 | + by the Sync Gateway to determine document routing, access |
| 35 | + grants, and validation outcomes during synchronization. |
| 36 | + type: string |
| 37 | + example: |- |
| 38 | + function (doc, oldDoc) { |
| 39 | + channel(doc.channels); |
| 40 | + } |
| 41 | + doc: |
| 42 | + $ref: ../../components/schemas.yaml#/Document |
20 | 43 | responses: |
21 | 44 | '200': |
22 | 45 | description: Document Processed by sync function successfully |
|
0 commit comments