(doc *Document, newDoc *Document)
| 2281 | } |
| 2282 | |
| 2283 | func (db *DatabaseCollectionWithUser) prepareSyncFn(doc *Document, newDoc *Document) (mutableBody Body, metaMap map[string]interface{}, newRevID string, err error) { |
| 2284 | // Marshal raw user xattrs for use in Sync Fn. If this fails we can bail out so we should do early as possible. |
| 2285 | metaMap, err = doc.GetMetaMap(db.UserXattrKey()) |
| 2286 | if err != nil { |
| 2287 | return |
| 2288 | } |
| 2289 | |
| 2290 | mutableBody, err = newDoc.GetDeepMutableBody() |
| 2291 | if err != nil { |
| 2292 | return |
| 2293 | } |
| 2294 | |
| 2295 | err = validateNewBody(mutableBody) |
| 2296 | if err != nil { |
| 2297 | return |
| 2298 | } |
| 2299 | |
| 2300 | newRevID = newDoc.RevID |
| 2301 | |
| 2302 | mutableBody[BodyId] = doc.ID |
| 2303 | mutableBody[BodyRev] = newRevID |
| 2304 | if newDoc.Deleted { |
| 2305 | mutableBody[BodyDeleted] = true |
| 2306 | } |
| 2307 | |
| 2308 | return |
| 2309 | } |
| 2310 | |
| 2311 | // Run the sync function on the given document and body. Need to inject the document ID and rev ID temporarily to run |
| 2312 | // the sync function. |
no test coverage detected